fix notification tab loading bottom notifications forever (#807)

This commit is contained in:
Konrad Pozniak 2018-08-26 21:10:38 +02:00 committed by GitHub
parent 937436091b
commit 1f972debff

View File

@ -207,7 +207,7 @@ public class NotificationsFragment extends SFragment implements
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false); ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
setupNothingView(); setupNothingView();
sendFetchNotificationsRequest(null, topId, FetchEnd.TOP, -1); sendFetchNotificationsRequest(null, topId, FetchEnd.BOTTOM, -1);
return rootView; return rootView;
} }
@ -551,6 +551,10 @@ public class NotificationsFragment extends SFragment implements
} }
private void onLoadMore() { private void onLoadMore() {
if(bottomId == null) {
// already loaded everything
return;
}
Either<Placeholder, Notification> last = notifications.get(notifications.size() - 1); Either<Placeholder, Notification> last = notifications.get(notifications.size() - 1);
if (last.isRight()) { if (last.isRight()) {
notifications.add(Either.left(Placeholder.getInstance())); notifications.add(Either.left(Placeholder.getInstance()));
@ -741,12 +745,10 @@ public class NotificationsFragment extends SFragment implements
} }
private void addItems(List<Notification> newNotifications, @Nullable String fromId) { private void addItems(List<Notification> newNotifications, @Nullable String fromId) {
bottomId = fromId;
if (ListUtils.isEmpty(newNotifications)) { if (ListUtils.isEmpty(newNotifications)) {
return; return;
} }
if (fromId != null) {
bottomId = fromId;
}
int end = notifications.size(); int end = notifications.size();
List<Either<Placeholder, Notification>> liftedNew = liftNotificationList(newNotifications); List<Either<Placeholder, Notification>> liftedNew = liftNotificationList(newNotifications);
Either<Placeholder, Notification> last = notifications.get(end - 1); Either<Placeholder, Notification> last = notifications.get(end - 1);