Commit 6bd395f7 authored by Tanmoy Mollik's avatar Tanmoy Mollik Committed by Commit Bot

[Android] Get rid of explicit register/unregister in SyncPromoPreference

Replace register and unregister with onAttached and onDetached methods
in SyncPromoPreference

Bug: 1109713
Change-Id: I1bf58fc31e74798a614afdb57179726545ed249d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2401522Reviewed-by: default avatarAlice Wang <aliceywang@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806611}
parent ebc84283
......@@ -125,7 +125,6 @@ public class MainSettings extends PreferenceFragmentCompat
Profile.getLastUsedRegularProfile());
if (signinManager.isSigninSupported()) {
signinManager.addSignInStateObserver(this);
mSyncPromoPreference.registerForUpdates();
mSignInPreference.registerForUpdates();
}
ProfileSyncService syncService = ProfileSyncService.get();
......@@ -141,7 +140,6 @@ public class MainSettings extends PreferenceFragmentCompat
Profile.getLastUsedRegularProfile());
if (signinManager.isSigninSupported()) {
signinManager.removeSignInStateObserver(this);
mSyncPromoPreference.unregisterForUpdates();
mSignInPreference.unregisterForUpdates();
}
ProfileSyncService syncService = ProfileSyncService.get();
......
......@@ -69,11 +69,9 @@ public class SyncPromoPreference extends Preference
setVisible(false);
}
/**
* Starts listening for updates to the sign-in and sync state.
* TODO(https://crbug.com/1109713): Remove this method and use onAttached() instead
*/
public void registerForUpdates() {
@Override
public void onAttached() {
super.onAttached();
mAccountManagerFacade.addObserver(this);
mProfileDataCache.addObserver(this);
FirstRunSignInProcessor.updateSigninManagerFirstRunCheckDone();
......@@ -86,12 +84,9 @@ public class SyncPromoPreference extends Preference
update();
}
/**
* Stops listening for updates to the sign-in and sync state. Every call to registerForUpdates()
* must be matched with a call to this method.
* TODO(https://crbug.com/1109713): Remove this method and use onAttached() instead
*/
public void unregisterForUpdates() {
@Override
public void onDetached() {
super.onDetached();
mAccountManagerFacade.removeObserver(this);
mProfileDataCache.removeObserver(this);
AndroidSyncSettings.get().unregisterObserver(this);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment