Search in sources :

Example 1 with Notification

use of com.keylesspalace.tusky.entity.Notification in project Tusky by Vavassor.

the class NotificationsAdapter method removeAllByAccountId.

public void removeAllByAccountId(String id) {
    for (int i = 0; i < notifications.size(); ) {
        Notification notification = notifications.get(i);
        if (id.equals(notification.account.id)) {
            notifications.remove(i);
            notifyItemRemoved(i);
        } else {
            i += 1;
        }
    }
}
Also used : Notification(com.keylesspalace.tusky.entity.Notification)

Example 2 with Notification

use of com.keylesspalace.tusky.entity.Notification in project Tusky by Vavassor.

the class NotificationsAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
    if (position < notifications.size()) {
        Notification notification = notifications.get(position);
        Notification.Type type = notification.type;
        switch(type) {
            case MENTION:
                {
                    StatusViewHolder holder = (StatusViewHolder) viewHolder;
                    Status status = notification.status;
                    holder.setupWithStatus(status, statusListener);
                    break;
                }
            case FAVOURITE:
            case REBLOG:
                {
                    StatusNotificationViewHolder holder = (StatusNotificationViewHolder) viewHolder;
                    holder.setMessage(type, notification.account.getDisplayName(), notification.status);
                    holder.setupButtons(notificationActionListener, notification.account.id);
                    break;
                }
            case FOLLOW:
                {
                    FollowViewHolder holder = (FollowViewHolder) viewHolder;
                    holder.setMessage(notification.account.getDisplayName(), notification.account.username, notification.account.avatar);
                    holder.setupButtons(notificationActionListener, notification.account.id);
                    break;
                }
        }
    }
}
Also used : Status(com.keylesspalace.tusky.entity.Status) Notification(com.keylesspalace.tusky.entity.Notification)

Example 3 with Notification

use of com.keylesspalace.tusky.entity.Notification in project Tusky by tuskyapp.

the class NotificationsFragment method onFavourite.

@Override
public void onFavourite(final boolean favourite, final int position) {
    final Notification notification = notifications.get(position).getAsRight();
    final Status status = notification.getStatus();
    timelineCases.favouriteWithCallback(status, favourite, new Callback<Status>() {

        @Override
        public void onResponse(@NonNull Call<Status> call, @NonNull retrofit2.Response<Status> response) {
            if (response.isSuccessful()) {
                status.setFavourited(favourite);
                if (status.getReblog() != null) {
                    status.getReblog().setFavourited(favourite);
                }
                NotificationViewData.Concrete viewdata = (NotificationViewData.Concrete) notifications.getPairedItem(position);
                StatusViewData.Builder viewDataBuilder = new StatusViewData.Builder(viewdata.getStatusViewData());
                viewDataBuilder.setFavourited(favourite);
                NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(viewdata.getType(), viewdata.getId(), viewdata.getAccount(), viewDataBuilder.createStatusViewData(), viewdata.isExpanded());
                notifications.setPairedItem(position, newViewData);
                adapter.updateItemWithNotify(position, newViewData, false);
            }
        }

        @Override
        public void onFailure(@NonNull Call<Status> call, @NonNull Throwable t) {
            Log.d(getClass().getSimpleName(), "Failed to favourite status: " + status.getId(), t);
        }
    });
}
Also used : Status(com.keylesspalace.tusky.entity.Status) StatusViewData(com.keylesspalace.tusky.viewdata.StatusViewData) Notification(com.keylesspalace.tusky.entity.Notification) NotificationViewData(com.keylesspalace.tusky.viewdata.NotificationViewData)

Example 4 with Notification

use of com.keylesspalace.tusky.entity.Notification in project Tusky by tuskyapp.

the class NotificationsFragment method onViewThread.

@Override
public void onViewThread(int position) {
    Notification notification = notifications.get(position).getAsRight();
    super.viewThread(notification.getStatus());
}
Also used : Notification(com.keylesspalace.tusky.entity.Notification)

Example 5 with Notification

use of com.keylesspalace.tusky.entity.Notification in project Tusky by tuskyapp.

the class NotificationsFragment method onMore.

@Override
public void onMore(View view, int position) {
    Notification notification = notifications.get(position).getAsRight();
    super.more(notification.getStatus(), view, position);
}
Also used : 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