Stop listening to database changes in conversation list when not visible.
This commit is contained in:
parent
4d985255a8
commit
62d85e6878
2 changed files with 10 additions and 2 deletions
|
@ -320,6 +320,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
super.onStart();
|
||||
ConversationFragment.prepare(requireContext());
|
||||
ApplicationDependencies.getAppForegroundObserver().addListener(appForegroundObserver);
|
||||
viewModel.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -335,6 +336,7 @@ public class ConversationListFragment extends MainFragment implements ActionMode
|
|||
public void onStop() {
|
||||
super.onStop();
|
||||
ApplicationDependencies.getAppForegroundObserver().removeListener(appForegroundObserver);
|
||||
viewModel.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -96,8 +96,6 @@ class ConversationListViewModel extends ViewModel {
|
|||
return DatabaseFactory.getThreadDatabase(application).getArchivedConversationListCount() == 0;
|
||||
}
|
||||
});
|
||||
|
||||
ApplicationDependencies.getDatabaseObserver().registerConversationListObserver(observer);
|
||||
}
|
||||
|
||||
public LiveData<Boolean> hasNoConversations() {
|
||||
|
@ -142,6 +140,14 @@ class ConversationListViewModel extends ViewModel {
|
|||
coldStart = false;
|
||||
}
|
||||
|
||||
void onStart() {
|
||||
ApplicationDependencies.getDatabaseObserver().registerConversationListObserver(observer);
|
||||
}
|
||||
|
||||
void onStop() {
|
||||
ApplicationDependencies.getDatabaseObserver().unregisterObserver(observer);
|
||||
}
|
||||
|
||||
void onMegaphoneCompleted(@NonNull Megaphones.Event event) {
|
||||
megaphone.postValue(null);
|
||||
megaphoneRepository.markFinished(event);
|
||||
|
|
Loading…
Add table
Reference in a new issue