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;
}
}
}
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;
}
}
}
}
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);
}
});
}
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());
}
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);
}
Aggregations