Commit c7a70407 authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Signin][Android] Move AccountPickerMediator.start/stop to ctor/destroy

This CL replaces the AccountPickerMediator.start()/stop() methods
to its constructor and destroy().

Bug: 1075880
Change-Id: I9dc3bf4b7af74813889e33e798165ffaa802e30b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2193683
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#768806}
parent 78e99eda
...@@ -44,21 +44,6 @@ public class AccountPickerDialogFragment extends DialogFragment { ...@@ -44,21 +44,6 @@ public class AccountPickerDialogFragment extends DialogFragment {
return result; return result;
} }
@Override
public void onStart() {
super.onStart();
// TODO(https://crbug.com/1075880):
// Investigate move this method to account picker mediator ctor
// and stop() to mediator.destroy()
mCoordinator.start();
}
@Override
public void onStop() {
super.onStop();
mCoordinator.stop();
}
@Override @Override
@NonNull @NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
...@@ -76,6 +61,12 @@ public class AccountPickerDialogFragment extends DialogFragment { ...@@ -76,6 +61,12 @@ public class AccountPickerDialogFragment extends DialogFragment {
.create(); .create();
} }
@Override
public void onDestroy() {
super.onDestroy();
mCoordinator.destroy();
}
/** /**
* Updates the selected account. * Updates the selected account.
* @param selectedAccountName The name of the account that should be marked as selected. * @param selectedAccountName The name of the account that should be marked as selected.
......
...@@ -64,17 +64,10 @@ public class AccountPickerCoordinator { ...@@ -64,17 +64,10 @@ public class AccountPickerCoordinator {
} }
/** /**
* Starts the coordinator. * Destroys the resources used by the coordinator.
*/ */
public void start() { public void destroy() {
mMediator.start(); mMediator.destroy();
}
/**
* Stops the coordinator.
*/
public void stop() {
mMediator.stop();
} }
/** /**
......
...@@ -50,21 +50,16 @@ class AccountPickerMediator { ...@@ -50,21 +50,16 @@ class AccountPickerMediator {
context, context.getResources().getDimensionPixelSize(R.dimen.user_picture_size)); context, context.getResources().getDimensionPixelSize(R.dimen.user_picture_size));
mSelectedAccountName = selectedAccountName; mSelectedAccountName = selectedAccountName;
mAccountManagerFacade = AccountManagerFacadeProvider.getInstance(); mAccountManagerFacade = AccountManagerFacadeProvider.getInstance();
}
/**
* Starts the mediator.
* TODO(https://crbug.com/1075880):
* Investigate move this method to account picker mediator ctor
* and stop() to mediator.destroy()
*/
void start() {
mAccountManagerFacade.addObserver(mAccountsChangeObserver); mAccountManagerFacade.addObserver(mAccountsChangeObserver);
mProfileDataCache.addObserver(mProfileDataObserver); mProfileDataCache.addObserver(mProfileDataObserver);
updateAccounts(); updateAccounts();
} }
void stop() { /**
* Unregisters the observers used by the mediator.
*/
void destroy() {
mProfileDataCache.removeObserver(mProfileDataObserver); mProfileDataCache.removeObserver(mProfileDataObserver);
mAccountManagerFacade.removeObserver(mAccountsChangeObserver); mAccountManagerFacade.removeObserver(mAccountsChangeObserver);
} }
......
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