use of com.keylesspalace.tusky.entity.Notification in project Tusky by Vavassor.
the class NotificationsFragment method removeAllByAccountId.
private void removeAllByAccountId(String accountId) {
// using iterator to safely remove items while iterating
Iterator<Either<Placeholder, Notification>> iterator = notifications.iterator();
while (iterator.hasNext()) {
Either<Placeholder, Notification> notification = iterator.next();
Notification maybeNotification = notification.asRightOrNull();
if (maybeNotification != null && maybeNotification.getAccount().getId().equals(accountId)) {
iterator.remove();
}
}
updateAdapter();
}
use of com.keylesspalace.tusky.entity.Notification in project Tusky by Vavassor.
the class NotificationsFragment method onLoadMore.
@Override
public void onLoadMore(int position) {
// check bounds before accessing list,
if (notifications.size() >= position && position > 0) {
Notification previous = notifications.get(position - 1).asRightOrNull();
Notification next = notifications.get(position + 1).asRightOrNull();
if (previous == null || next == null) {
Log.e(TAG, "Failed to load more, invalid placeholder position: " + position);
return;
}
sendFetchNotificationsRequest(previous.getId(), next.getId(), FetchEnd.MIDDLE, position);
Placeholder placeholder = notifications.get(position).asLeft();
NotificationViewData notificationViewData = new NotificationViewData.Placeholder(placeholder.id, true);
notifications.setPairedItem(position, notificationViewData);
updateAdapter();
} else {
Log.d(TAG, "error loading more");
}
}
Aggregations