Search in sources :

Example 1 with Notification

use of com.owncloud.android.lib.resources.notifications.models.Notification in project android by nextcloud.

the class NotificationsActivity method fetchAndSetData.

private void fetchAndSetData() {
    Thread t = new Thread(() -> {
        initializeAdapter();
        RemoteOperation getRemoteNotificationOperation = new GetNotificationsRemoteOperation();
        final RemoteOperationResult result = getRemoteNotificationOperation.execute(client);
        if (result.isSuccess() && result.getNotificationData() != null) {
            final List<Notification> notifications = result.getNotificationData();
            runOnUiThread(() -> populateList(notifications));
        } else {
            Log_OC.d(TAG, result.getLogMessage());
            // show error
            runOnUiThread(() -> setEmptyContent(getString(R.string.notifications_no_results_headline), result.getLogMessage()));
        }
        hideRefreshLayoutLoader();
    });
    t.start();
}
Also used : RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) GetNotificationsRemoteOperation(com.owncloud.android.lib.resources.notifications.GetNotificationsRemoteOperation) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) GetNotificationsRemoteOperation(com.owncloud.android.lib.resources.notifications.GetNotificationsRemoteOperation) Notification(com.owncloud.android.lib.resources.notifications.models.Notification)

Example 2 with Notification

use of com.owncloud.android.lib.resources.notifications.models.Notification 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

Notification (com.owncloud.android.lib.resources.notifications.models.Notification)2 Intent (android.content.Intent)1 RemoteOperation (com.owncloud.android.lib.common.operations.RemoteOperation)1 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)1 GetNotificationsRemoteOperation (com.owncloud.android.lib.resources.notifications.GetNotificationsRemoteOperation)1 RichObject (com.owncloud.android.lib.resources.notifications.models.RichObject)1 DeleteNotificationTask (com.owncloud.android.ui.asynctasks.DeleteNotificationTask)1