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