Search in sources :

Example 26 with Notification

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();
}
Also used : Either(com.keylesspalace.tusky.util.Either) Notification(com.keylesspalace.tusky.entity.Notification)

Example 27 with Notification

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");
    }
}
Also used : NotificationViewData(com.keylesspalace.tusky.viewdata.NotificationViewData) Notification(com.keylesspalace.tusky.entity.Notification)

Aggregations

Notification (com.keylesspalace.tusky.entity.Notification)27 Status (com.keylesspalace.tusky.entity.Status)11 NotificationViewData (com.keylesspalace.tusky.viewdata.NotificationViewData)8 Either (com.keylesspalace.tusky.util.Either)5 StatusViewData (com.keylesspalace.tusky.viewdata.StatusViewData)4 AccountEntity (com.keylesspalace.tusky.db.AccountEntity)3 AccountManager (com.keylesspalace.tusky.db.AccountManager)2 Activity (android.app.Activity)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 Log (android.util.Log)1 SparseBooleanArray (android.util.SparseBooleanArray)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ArrayAdapter (android.widget.ArrayAdapter)1 Button (android.widget.Button)1 ListView (android.widget.ListView)1