Pause Periodic List Refresh when View is not Visible

Closes #553
This commit is contained in:
Torsten Grote
2016-07-29 16:09:39 -03:00
committed by akwizgran
parent 2577b2ab2a
commit 15d139afd4
6 changed files with 30 additions and 16 deletions

View File

@@ -119,7 +119,7 @@ public class ForumActivity extends BriarActivity implements
forumAdapter = new ForumAdapter(
forumController.getForumEntries());
recyclerView.setAdapter(forumAdapter);
recyclerView.periodicallyUpdateContent();
recyclerView.startPeriodicUpdate();
if (state != null) {
byte[] replyId =
state.getByteArray(KEY_REPLY_ID);
@@ -250,12 +250,18 @@ public class ForumActivity extends BriarActivity implements
super.onResume();
notificationManager.blockNotification(groupId);
notificationManager.clearForumPostNotification(groupId);
if (recyclerView.getRecyclerView().getAdapter() != null) {
recyclerView.startPeriodicUpdate();
}
}
@Override
public void onPause() {
super.onPause();
notificationManager.unblockNotification(groupId);
if (recyclerView.getRecyclerView().getAdapter() != null) {
recyclerView.stopPeriodicUpdate();
}
}
public void sendMessage(View view) {

View File

@@ -84,7 +84,6 @@ public class ForumListFragment extends BaseEventFragment implements
list.setLayoutManager(new LinearLayoutManager(getActivity()));
list.setAdapter(adapter);
list.setEmptyText(getString(R.string.no_forums));
list.periodicallyUpdateContent();
snackbar = Snackbar.make(list, "", LENGTH_INDEFINITE);
snackbar.getView().setBackgroundResource(R.color.briar_primary);
@@ -111,6 +110,7 @@ public class ForumListFragment extends BaseEventFragment implements
loadForumHeaders();
loadAvailableForums();
list.startPeriodicUpdate();
}
@Override
@@ -118,6 +118,7 @@ public class ForumListFragment extends BaseEventFragment implements
super.onPause();
adapter.clear();
list.stopPeriodicUpdate();
}
@Override