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