Search in sources :

Example 1 with Activity

use of com.owncloud.android.lib.resources.activities.model.Activity in project android by nextcloud.

the class ActivitiesPresenterTest method setupActivitiesPresenter.

@Before
public void setupActivitiesPresenter() {
    MockitoAnnotations.initMocks(this);
    activitiesPresenter = new ActivitiesPresenter(activitiesRepository, filesRepository, view);
    activitiesList = new ArrayList<>();
    activitiesList.add(new Activity());
}
Also used : BaseActivity(com.owncloud.android.ui.activity.BaseActivity) Activity(com.owncloud.android.lib.resources.activities.model.Activity) Before(org.junit.Before)

Example 2 with Activity

use of com.owncloud.android.lib.resources.activities.model.Activity in project android by nextcloud.

the class ActivityListAdapter method setActivityItems.

public void setActivityItems(List<Object> activityItems, NextcloudClient client, boolean clear) {
    this.client = client;
    String sTime = "";
    if (clear) {
        values.clear();
    }
    for (Object o : activityItems) {
        Activity activity = (Activity) o;
        String time;
        if (activity.getDatetime() != null) {
            time = getHeaderDateString(context, activity.getDatetime().getTime()).toString();
        } else if (activity.getDate() != null) {
            time = getHeaderDateString(context, activity.getDate().getTime()).toString();
        } else {
            time = context.getString(R.string.date_unknown);
        }
        if (sTime.equalsIgnoreCase(time)) {
            values.add(activity);
        } else {
            sTime = time;
            values.add(sTime);
            values.add(activity);
        }
    }
    notifyDataSetChanged();
}
Also used : Activity(com.owncloud.android.lib.resources.activities.model.Activity) RichObject(com.owncloud.android.lib.resources.activities.model.RichObject) PreviewObject(com.owncloud.android.lib.resources.activities.models.PreviewObject)

Example 3 with Activity

use of com.owncloud.android.lib.resources.activities.model.Activity 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)

Example 4 with Activity

use of com.owncloud.android.lib.resources.activities.model.Activity in project android by nextcloud.

the class ActivityAndVersionListAdapter method setActivityAndVersionItems.

public void setActivityAndVersionItems(List<Object> items, NextcloudClient newClient, boolean clear) {
    if (client == null) {
        client = newClient;
    }
    if (clear) {
        values.clear();
        Collections.sort(items, (o1, o2) -> {
            long o1Date;
            long o2Date;
            if (o1 instanceof Activity) {
                o1Date = ((Activity) o1).getDatetime().getTime();
            } else {
                o1Date = ((FileVersion) o1).getModifiedTimestamp();
            }
            if (o2 instanceof Activity) {
                o2Date = ((Activity) o2).getDatetime().getTime();
            } else {
                o2Date = ((FileVersion) o2).getModifiedTimestamp();
            }
            return -1 * Long.compare(o1Date, o2Date);
        });
    }
    String sTime = "";
    for (Object item : items) {
        String time;
        if (item instanceof Activity) {
            Activity activity = (Activity) item;
            if (activity.getDatetime() != null) {
                time = getHeaderDateString(context, activity.getDatetime().getTime()).toString();
            } else if (activity.getDate() != null) {
                time = getHeaderDateString(context, activity.getDate().getTime()).toString();
            } else {
                time = context.getString(R.string.date_unknown);
            }
        } else {
            FileVersion version = (FileVersion) item;
            time = getHeaderDateString(context, version.getModifiedTimestamp()).toString();
        }
        if (sTime.equalsIgnoreCase(time)) {
            values.add(item);
        } else {
            sTime = time;
            values.add(sTime);
            values.add(item);
        }
    }
    notifyDataSetChanged();
}
Also used : FileVersion(com.owncloud.android.lib.resources.files.model.FileVersion) Activity(com.owncloud.android.lib.resources.activities.model.Activity)

Aggregations

Activity (com.owncloud.android.lib.resources.activities.model.Activity)4 PreviewObject (com.owncloud.android.lib.resources.activities.models.PreviewObject)2 TextPaint (android.text.TextPaint)1 ImageView (android.widget.ImageView)1 RichObject (com.owncloud.android.lib.resources.activities.model.RichObject)1 FileVersion (com.owncloud.android.lib.resources.files.model.FileVersion)1 BaseActivity (com.owncloud.android.ui.activity.BaseActivity)1 Before (org.junit.Before)1