fix placeholder not resetting itself after a load failed

main
Conny Duck 7 years ago
parent 6baa187976
commit 4fa8dcc8be
  1. 25
      app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java
  2. 2
      app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java

@ -539,6 +539,18 @@ public class NotificationsFragment extends SFragment implements
swipeRefreshLayout.setRefreshing(false);
}
private void onFetchNotificationsFailure(Exception exception, FetchEnd fetchEnd, int position) {
swipeRefreshLayout.setRefreshing(false);
if (fetchEnd == FetchEnd.MIDDLE && !notifications.get(position).isRight()) {
NotificationViewData placeholderVD =
new NotificationViewData.Placeholder(false);
notifications.setPairedItem(position, placeholderVD);
adapter.updateItemWithNotify(position, placeholderVD, true);
}
Log.e(TAG, "Fetch failure: " + exception.getMessage());
fulfillAnyQueuedFetches(fetchEnd);
}
private void update(@Nullable List<Notification> newNotifications, @Nullable String fromId,
@Nullable String uptoId) {
if (ListUtils.isEmpty(newNotifications)) {
@ -593,19 +605,6 @@ public class NotificationsFragment extends SFragment implements
}
}
private void onFetchNotificationsFailure(Exception exception, FetchEnd fetchEnd, int position) {
swipeRefreshLayout.setRefreshing(false);
if (fetchEnd == FetchEnd.MIDDLE && !notifications.get(position).isRight()) {
NotificationViewData placeholderVD =
new NotificationViewData.Placeholder(false);
notifications.setPairedItem(position, placeholderVD);
adapter.updateItemWithNotify(position, placeholderVD, true);
}
Log.e(TAG, "Fetch failure: " + exception.getMessage());
fulfillAnyQueuedFetches(fetchEnd);
}
private void fulfillAnyQueuedFetches(FetchEnd fetchEnd) {
switch (fetchEnd) {
case BOTTOM: {

@ -627,7 +627,7 @@ public class TimelineFragment extends SFragment implements
swipeRefreshLayout.setRefreshing(false);
if (fetchEnd == FetchEnd.MIDDLE && !statuses.get(position).isRight()) {
StatusViewData newViewData = new StatusViewData.Placeholder(true);
StatusViewData newViewData = new StatusViewData.Placeholder(false);
statuses.setPairedItem(position, newViewData);
adapter.changeItem(position, newViewData, true);
}

Loading…
Cancel
Save