fix placeholder not resetting itself after a load failed
This commit is contained in:
parent
74d6736afc
commit
52dd9559d6
2 changed files with 13 additions and 14 deletions
|
@ -539,6 +539,18 @@ public class NotificationsFragment extends SFragment implements
|
||||||
swipeRefreshLayout.setRefreshing(false);
|
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,
|
private void update(@Nullable List<Notification> newNotifications, @Nullable String fromId,
|
||||||
@Nullable String uptoId) {
|
@Nullable String uptoId) {
|
||||||
if (ListUtils.isEmpty(newNotifications)) {
|
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) {
|
private void fulfillAnyQueuedFetches(FetchEnd fetchEnd) {
|
||||||
switch (fetchEnd) {
|
switch (fetchEnd) {
|
||||||
case BOTTOM: {
|
case BOTTOM: {
|
||||||
|
|
|
@ -627,7 +627,7 @@ public class TimelineFragment extends SFragment implements
|
||||||
swipeRefreshLayout.setRefreshing(false);
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
|
|
||||||
if (fetchEnd == FetchEnd.MIDDLE && !statuses.get(position).isRight()) {
|
if (fetchEnd == FetchEnd.MIDDLE && !statuses.get(position).isRight()) {
|
||||||
StatusViewData newViewData = new StatusViewData.Placeholder(true);
|
StatusViewData newViewData = new StatusViewData.Placeholder(false);
|
||||||
statuses.setPairedItem(position, newViewData);
|
statuses.setPairedItem(position, newViewData);
|
||||||
adapter.changeItem(position, newViewData, true);
|
adapter.changeItem(position, newViewData, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue