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 ...@@ -125,7 +125,6 @@ public class MainSettings extends PreferenceFragmentCompat
Profile.getLastUsedRegularProfile()); Profile.getLastUsedRegularProfile());
if (signinManager.isSigninSupported()) { if (signinManager.isSigninSupported()) {
signinManager.addSignInStateObserver(this); signinManager.addSignInStateObserver(this);
mSyncPromoPreference.registerForUpdates();
mSignInPreference.registerForUpdates(); mSignInPreference.registerForUpdates();
} }
ProfileSyncService syncService = ProfileSyncService.get(); ProfileSyncService syncService = ProfileSyncService.get();
...@@ -141,7 +140,6 @@ public class MainSettings extends PreferenceFragmentCompat ...@@ -141,7 +140,6 @@ public class MainSettings extends PreferenceFragmentCompat
Profile.getLastUsedRegularProfile()); Profile.getLastUsedRegularProfile());
if (signinManager.isSigninSupported()) { if (signinManager.isSigninSupported()) {
signinManager.removeSignInStateObserver(this); signinManager.removeSignInStateObserver(this);
mSyncPromoPreference.unregisterForUpdates();
mSignInPreference.unregisterForUpdates(); mSignInPreference.unregisterForUpdates();
} }
ProfileSyncService syncService = ProfileSyncService.get(); ProfileSyncService syncService = ProfileSyncService.get();
......
...@@ -69,11 +69,9 @@ public class SyncPromoPreference extends Preference ...@@ -69,11 +69,9 @@ public class SyncPromoPreference extends Preference
setVisible(false); setVisible(false);
} }
/** @Override
* Starts listening for updates to the sign-in and sync state. public void onAttached() {
* TODO(https://crbug.com/1109713): Remove this method and use onAttached() instead super.onAttached();
*/
public void registerForUpdates() {
mAccountManagerFacade.addObserver(this); mAccountManagerFacade.addObserver(this);
mProfileDataCache.addObserver(this); mProfileDataCache.addObserver(this);
FirstRunSignInProcessor.updateSigninManagerFirstRunCheckDone(); FirstRunSignInProcessor.updateSigninManagerFirstRunCheckDone();
...@@ -86,12 +84,9 @@ public class SyncPromoPreference extends Preference ...@@ -86,12 +84,9 @@ public class SyncPromoPreference extends Preference
update(); update();
} }
/** @Override
* Stops listening for updates to the sign-in and sync state. Every call to registerForUpdates() public void onDetached() {
* must be matched with a call to this method. super.onDetached();
* TODO(https://crbug.com/1109713): Remove this method and use onAttached() instead
*/
public void unregisterForUpdates() {
mAccountManagerFacade.removeObserver(this); mAccountManagerFacade.removeObserver(this);
mProfileDataCache.removeObserver(this); mProfileDataCache.removeObserver(this);
AndroidSyncSettings.get().unregisterObserver(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