#635 - Make sure that we're unregistering lifecycle observers to avoid memory leaks
This commit is contained in:
parent
38a5ca656c
commit
ba2f911909
1 changed files with 17 additions and 8 deletions
|
@ -66,6 +66,7 @@ public class AuthenticateActivity extends BaseActivity
|
||||||
private String newEncryption = "";
|
private String newEncryption = "";
|
||||||
private String existingAuthCredentials;
|
private String existingAuthCredentials;
|
||||||
private boolean isAuthUpgrade = false;
|
private boolean isAuthUpgrade = false;
|
||||||
|
private ProcessLifecycleObserver observer;
|
||||||
|
|
||||||
private TextInputLayout passwordLayout;
|
private TextInputLayout passwordLayout;
|
||||||
private TextInputEditText passwordInput;
|
private TextInputEditText passwordInput;
|
||||||
|
@ -109,8 +110,9 @@ public class AuthenticateActivity extends BaseActivity
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
observer = new ProcessLifecycleObserver();
|
||||||
ProcessLifecycleOwner.get().getLifecycle()
|
ProcessLifecycleOwner.get().getLifecycle()
|
||||||
.addObserver(new ProcessLifecycleObserver());
|
.addObserver(observer);
|
||||||
|
|
||||||
getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||||
}
|
}
|
||||||
|
@ -174,6 +176,15 @@ public class AuthenticateActivity extends BaseActivity
|
||||||
setupUiForTaskState(false);
|
setupUiForTaskState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ProcessLifecycleObserver implements DefaultLifecycleObserver {
|
||||||
|
@Override
|
||||||
|
public void onStop(LifecycleOwner owner) {
|
||||||
|
if (settings.getRelockOnBackground()) {
|
||||||
|
cancelBackgroundTask();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
@ -201,13 +212,11 @@ public class AuthenticateActivity extends BaseActivity
|
||||||
unlockProgress.setVisibility(isTaskRunning ? View.VISIBLE : View.GONE);
|
unlockProgress.setVisibility(isTaskRunning ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ProcessLifecycleObserver implements DefaultLifecycleObserver {
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop(LifecycleOwner owner) {
|
protected void onDestroy() {
|
||||||
if (settings.getRelockOnBackground()) {
|
super.onDestroy();
|
||||||
cancelBackgroundTask();
|
ProcessLifecycleOwner.get().getLifecycle()
|
||||||
}
|
.removeObserver(observer);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue