Search in sources :

Example 1 with DeleteNotificationTask

use of com.owncloud.android.ui.asynctasks.DeleteNotificationTask in project android by nextcloud.

the class NotificationListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull NotificationViewHolder holder, int position) {
    Notification notification = notificationsList.get(position);
    holder.binding.datetime.setText(DisplayUtils.getRelativeTimestamp(notificationsActivity, notification.getDatetime().getTime()));
    RichObject file = notification.subjectRichParameters.get(FILE);
    String subject = notification.getSubject();
    if (file == null && !TextUtils.isEmpty(notification.getLink())) {
        subject = subject + " ↗";
        holder.binding.subject.setTypeface(holder.binding.subject.getTypeface(), Typeface.BOLD);
        holder.binding.subject.setOnClickListener(v -> openLink(notification.getLink()));
        holder.binding.subject.setText(subject);
    } else {
        if (!TextUtils.isEmpty(notification.subjectRich)) {
            holder.binding.subject.setText(makeSpecialPartsBold(notification));
        } else {
            holder.binding.subject.setText(subject);
        }
        if (file != null && !TextUtils.isEmpty(file.id)) {
            holder.binding.subject.setOnClickListener(v -> {
                Intent intent = new Intent(notificationsActivity, FileDisplayActivity.class);
                intent.setAction(Intent.ACTION_VIEW);
                intent.putExtra(FileDisplayActivity.KEY_FILE_ID, file.id);
                notificationsActivity.startActivity(intent);
            });
        }
    }
    holder.binding.message.setText(notification.getMessage());
    if (!TextUtils.isEmpty(notification.getIcon())) {
        downloadIcon(notification.getIcon(), holder.binding.icon);
    }
    int nightModeFlag = notificationsActivity.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
    if (Configuration.UI_MODE_NIGHT_YES == nightModeFlag) {
        holder.binding.icon.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
    } else {
        holder.binding.icon.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN);
    }
    setButtons(holder, notification);
    holder.binding.dismiss.setOnClickListener(v -> new DeleteNotificationTask(client, notification, holder, notificationsActivity).execute());
}
Also used : RichObject(com.owncloud.android.lib.resources.notifications.models.RichObject) DeleteNotificationTask(com.owncloud.android.ui.asynctasks.DeleteNotificationTask) Intent(android.content.Intent) Notification(com.owncloud.android.lib.resources.notifications.models.Notification)

Aggregations

Intent (android.content.Intent)1 Notification (com.owncloud.android.lib.resources.notifications.models.Notification)1 RichObject (com.owncloud.android.lib.resources.notifications.models.RichObject)1 DeleteNotificationTask (com.owncloud.android.ui.asynctasks.DeleteNotificationTask)1