use of com.keylesspalace.tusky.util.HttpHeaderLink in project Tusky by Vavassor.
the class NotificationsFragment method onFetchNotificationsSuccess.
private void onFetchNotificationsSuccess(List<Notification> notifications, String linkHeader, FetchEnd fetchEnd, int pos) {
List<HttpHeaderLink> links = HttpHeaderLink.parse(linkHeader);
HttpHeaderLink next = HttpHeaderLink.findByRelationType(links, "next");
String fromId = null;
if (next != null) {
fromId = next.uri.getQueryParameter("max_id");
}
switch(fetchEnd) {
case TOP:
{
update(notifications, this.notifications.isEmpty() ? fromId : null);
break;
}
case MIDDLE:
{
replacePlaceholderWithNotifications(notifications, pos);
break;
}
case BOTTOM:
{
if (!this.notifications.isEmpty() && !this.notifications.get(this.notifications.size() - 1).isRight()) {
this.notifications.remove(this.notifications.size() - 1);
updateAdapter();
}
if (adapter.getItemCount() > 1) {
addItems(notifications, fromId);
} else {
update(notifications, fromId);
}
break;
}
}
saveNewestNotificationId(notifications);
if (fetchEnd == FetchEnd.TOP) {
topLoading = false;
}
if (fetchEnd == FetchEnd.BOTTOM) {
bottomLoading = false;
}
if (notifications.size() == 0 && adapter.getItemCount() == 0) {
this.statusView.setVisibility(View.VISIBLE);
this.statusView.setup(R.drawable.elephant_friend_empty, R.string.message_empty, null);
} else {
swipeRefreshLayout.setEnabled(true);
}
updateFilterVisibility();
swipeRefreshLayout.setRefreshing(false);
progressBar.setVisibility(View.GONE);
}
Aggregations