Search in sources :

Example 1 with Notification

use of me.zhanghai.android.douya.network.api.info.frodo.Notification in project Douya by DreaminginCodeZH.

the class NotificationAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    final Context context = RecyclerViewUtils.getContext(holder);
    final Notification notification = getItem(position);
    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (mListener != null) {
                mListener.onMarkNotificationAsRead(notification);
            }
            UriHandler.open(notification.targetUri, context);
        }
    });
    holder.textText.setText(notification.text);
    holder.textText.setTextColor(notification.read ? mTextColorSecondary : mTextColorPrimary);
    holder.timeText.setDoubanTime(notification.time);
}
Also used : Context(android.content.Context) TimeTextView(me.zhanghai.android.douya.ui.TimeTextView) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Notification(me.zhanghai.android.douya.network.api.info.frodo.Notification)

Example 2 with Notification

use of me.zhanghai.android.douya.network.api.info.frodo.Notification in project Douya by DreaminginCodeZH.

the class NotificationListResource method onNotificationDeleted.

@Subscribe(threadMode = ThreadMode.POSTING)
public void onNotificationDeleted(NotificationDeletedEvent event) {
    if (event.isFromMyself(this) || isEmpty()) {
        return;
    }
    List<Notification> notificationList = get();
    for (int i = 0, size = notificationList.size(); i < size; ) {
        Notification notification = notificationList.get(i);
        if (notification.id == event.notificationId) {
            notificationList.remove(i);
            getListener().onNotificationRemoved(getRequestCode(), i);
            --size;
        } else {
            ++i;
        }
    }
}
Also used : Notification(me.zhanghai.android.douya.network.api.info.frodo.Notification) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 3 with Notification

use of me.zhanghai.android.douya.network.api.info.frodo.Notification in project Douya by DreaminginCodeZH.

the class NotificationListResource method setAndNotifyListener.

protected void setAndNotifyListener(List<Notification> notificationList, boolean notifyFinished) {
    // HACK: This cannot handle unread count > 20, or read elsewhere.
    if (has()) {
        for (Notification notification : get()) {
            if (!notification.read) {
                for (Notification newNotification : notificationList) {
                    if (newNotification.id == notification.id) {
                        newNotification.read = false;
                        break;
                    }
                }
            }
        }
    }
    set(notificationList);
    if (notifyFinished) {
        getListener().onLoadNotificationListFinished(getRequestCode());
    }
    getListener().onNotificationListChanged(getRequestCode(), Collections.unmodifiableList(notificationList));
}
Also used : Notification(me.zhanghai.android.douya.network.api.info.frodo.Notification)

Example 4 with Notification

use of me.zhanghai.android.douya.network.api.info.frodo.Notification in project Douya by DreaminginCodeZH.

the class NotificationListResource method onNotificationUpdated.

@Subscribe(threadMode = ThreadMode.POSTING)
public void onNotificationUpdated(NotificationUpdatedEvent event) {
    if (event.isFromMyself(this) || isEmpty()) {
        return;
    }
    List<Notification> notificationList = get();
    for (int i = 0, size = notificationList.size(); i < size; ++i) {
        Notification notification = notificationList.get(i);
        if (notification.id == event.notification.id) {
            notificationList.set(i, event.notification);
            getListener().onNotificationChanged(getRequestCode(), i, notificationList.get(i));
        }
    }
}
Also used : Notification(me.zhanghai.android.douya.network.api.info.frodo.Notification) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 5 with Notification

use of me.zhanghai.android.douya.network.api.info.frodo.Notification in project Douya by DreaminginCodeZH.

the class NotificationListResource method setAndNotifyListener.

protected void setAndNotifyListener(List<Notification> notificationList) {
    // HACK: This cannot handle unread count > 20, or read elsewhere.
    if (has()) {
        for (Notification notification : get()) {
            if (!notification.read) {
                for (Notification newNotification : notificationList) {
                    if (newNotification.id == notification.id) {
                        newNotification.read = false;
                        break;
                    }
                }
            }
        }
    }
    set(notificationList);
    getListener().onNotificationListChanged(getRequestCode(), Collections.unmodifiableList(notificationList));
}
Also used : Notification(me.zhanghai.android.douya.network.api.info.frodo.Notification)

Aggregations

Notification (me.zhanghai.android.douya.network.api.info.frodo.Notification)5 Subscribe (org.greenrobot.eventbus.Subscribe)2 Context (android.content.Context)1 View (android.view.View)1 TextView (android.widget.TextView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 BindView (butterknife.BindView)1 TimeTextView (me.zhanghai.android.douya.ui.TimeTextView)1