Search in sources :

Example 1 with PreviewObject

use of com.owncloud.android.lib.resources.activities.models.PreviewObject in project android by nextcloud.

the class ActivityListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof ActivityViewHolder) {
        final ActivityViewHolder activityViewHolder = (ActivityViewHolder) holder;
        Activity activity = (Activity) values.get(position);
        if (activity.getDatetime() != null) {
            activityViewHolder.binding.datetime.setVisibility(View.VISIBLE);
            activityViewHolder.binding.datetime.setText(DateFormat.format("HH:mm", activity.getDatetime().getTime()));
        } else {
            activityViewHolder.binding.datetime.setVisibility(View.GONE);
        }
        if (activity.getRichSubjectElement() != null && !TextUtils.isEmpty(activity.getRichSubjectElement().getRichSubject())) {
            activityViewHolder.binding.subject.setVisibility(View.VISIBLE);
            activityViewHolder.binding.subject.setMovementMethod(LinkMovementMethod.getInstance());
            activityViewHolder.binding.subject.setText(addClickablePart(activity.getRichSubjectElement()), TextView.BufferType.SPANNABLE);
            activityViewHolder.binding.subject.setVisibility(View.VISIBLE);
        } else if (!TextUtils.isEmpty(activity.getSubject())) {
            activityViewHolder.binding.subject.setVisibility(View.VISIBLE);
            activityViewHolder.binding.subject.setText(activity.getSubject());
        } else {
            activityViewHolder.binding.subject.setVisibility(View.GONE);
        }
        if (!TextUtils.isEmpty(activity.getMessage())) {
            activityViewHolder.binding.message.setText(activity.getMessage());
            activityViewHolder.binding.message.setVisibility(View.VISIBLE);
        } else {
            activityViewHolder.binding.message.setVisibility(View.GONE);
        }
        if (!TextUtils.isEmpty(activity.getIcon())) {
            downloadIcon(activity, activityViewHolder.binding.icon);
        }
        int nightModeFlag = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
        if (!"file_created".equalsIgnoreCase(activity.getType()) && !"file_deleted".equalsIgnoreCase(activity.getType())) {
            if (Configuration.UI_MODE_NIGHT_YES == nightModeFlag) {
                activityViewHolder.binding.icon.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
            } else {
                activityViewHolder.binding.icon.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN);
            }
        }
        if (activity.getRichSubjectElement() != null && activity.getRichSubjectElement().getRichObjectList().size() > 0) {
            activityViewHolder.binding.list.setVisibility(View.VISIBLE);
            activityViewHolder.binding.list.removeAllViews();
            activityViewHolder.binding.list.post(() -> {
                int w = activityViewHolder.binding.list.getMeasuredWidth();
                int elPxSize = px + 20;
                int totalColumnCount = w / elPxSize;
                try {
                    activityViewHolder.binding.list.setColumnCount(totalColumnCount);
                } catch (IllegalArgumentException e) {
                    Log_OC.e(TAG, "error setting column count to " + totalColumnCount);
                }
            });
            for (PreviewObject previewObject : activity.getPreviews()) {
                if (!isDetailView || MimeTypeUtil.isImageOrVideo(previewObject.getMimeType()) || MimeTypeUtil.isVideo(previewObject.getMimeType())) {
                    ImageView imageView = createThumbnailNew(previewObject, activity.getRichSubjectElement().getRichObjectList());
                    activityViewHolder.binding.list.addView(imageView);
                }
            }
        } else {
            activityViewHolder.binding.list.removeAllViews();
            activityViewHolder.binding.list.setVisibility(View.GONE);
        }
    } else {
        ActivityViewHeaderHolder activityViewHeaderHolder = (ActivityViewHeaderHolder) holder;
        activityViewHeaderHolder.binding.header.setText((String) values.get(position));
    }
}
Also used : PreviewObject(com.owncloud.android.lib.resources.activities.models.PreviewObject) Activity(com.owncloud.android.lib.resources.activities.model.Activity) ImageView(android.widget.ImageView) TextPaint(android.text.TextPaint)

Aggregations

TextPaint (android.text.TextPaint)1 ImageView (android.widget.ImageView)1 Activity (com.owncloud.android.lib.resources.activities.model.Activity)1 PreviewObject (com.owncloud.android.lib.resources.activities.models.PreviewObject)1