use of com.owncloud.android.lib.resources.activities.model.RichObject in project android by nextcloud.
the class ActivityListAdapter method createThumbnailNew.
private ImageView createThumbnailNew(PreviewObject previewObject, List<RichObject> richObjectList) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(px, px);
params.setMargins(10, 10, 10, 10);
ImageView imageView = new ImageView(context);
imageView.setLayoutParams(params);
for (RichObject object : richObjectList) {
int objectId = -1;
try {
objectId = Integer.parseInt(object.getId());
} catch (NumberFormatException e) {
// object.getId() can also be a string if RichObjects refers to an user
}
if (objectId == previewObject.getFileId()) {
imageView.setOnClickListener(v -> activityListInterface.onActivityClicked(object));
break;
}
}
if (MimeTypeUtil.isImageOrVideo(previewObject.getMimeType())) {
int placeholder;
if (MimeTypeUtil.isImage(previewObject.getMimeType())) {
placeholder = R.drawable.file_image;
} else {
placeholder = R.drawable.file_movie;
}
Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider.getUser(), clientFactory)).load(previewObject.getSource()).placeholder(placeholder).error(placeholder).diskCacheStrategy(DiskCacheStrategy.NONE).skipMemoryCache(true).into(imageView);
} else {
if (MimeTypeUtil.isFolder(previewObject.getMimeType())) {
imageView.setImageDrawable(MimeTypeUtil.getDefaultFolderIcon(context));
} else {
imageView.setImageDrawable(MimeTypeUtil.getFileTypeIcon(previewObject.getMimeType(), "", context));
}
}
return imageView;
}
use of com.owncloud.android.lib.resources.activities.model.RichObject in project android by nextcloud.
the class ActivityListAdapter method addClickablePart.
private SpannableStringBuilder addClickablePart(RichElement richElement) {
String text = richElement.getRichSubject();
SpannableStringBuilder ssb = new SpannableStringBuilder(text);
int idx1 = text.indexOf('{');
int idx2;
while (idx1 != -1) {
idx2 = text.indexOf('}', idx1) + 1;
final String clickString = text.substring(idx1 + 1, idx2 - 1);
final RichObject richObject = searchObjectByName(richElement.getRichObjectList(), clickString);
if (richObject != null) {
String name = richObject.getName();
ssb.replace(idx1, idx2, name);
text = ssb.toString();
idx2 = idx1 + name.length();
ssb.setSpan(new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
activityListInterface.onActivityClicked(richObject);
}
@Override
public void updateDrawState(@NonNull TextPaint ds) {
ds.setUnderlineText(false);
}
}, idx1, idx2, 0);
ssb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), idx1, idx2, 0);
ssb.setSpan(new ForegroundColorSpan(context.getResources().getColor(R.color.text_color)), idx1, idx2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
idx1 = text.indexOf('{', idx2);
}
return ssb;
}
Aggregations