use of com.owncloud.android.utils.glide.CustomGlideStreamLoader in project android by nextcloud.
the class ActivityListAdapter method setBitmap.
private void setBitmap(OCFile file, ImageView fileIcon) {
// No Folder
if (!file.isFolder()) {
if ((MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file))) {
int placeholder;
if (MimeTypeUtil.isImage(file)) {
placeholder = R.drawable.file_image;
} else {
placeholder = R.drawable.file_movie;
}
String uri = mClient.getBaseUri() + "/index.php/apps/files/api/v1/thumbnail/" + px + "/" + px + Uri.encode(file.getRemotePath(), "/");
Glide.with(context).using(new CustomGlideStreamLoader()).load(uri).placeholder(placeholder).error(placeholder).into(// using custom fetcher
fileIcon);
} else {
fileIcon.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimetype(), file.getFileName(), null));
}
} else {
// Folder
fileIcon.setImageDrawable(MimeTypeUtil.getFolderTypeIcon(file.isSharedWithMe() || file.isSharedWithSharee(), file.isSharedViaLink(), file.isEncrypted(), file.getMountType()));
}
}
use of com.owncloud.android.utils.glide.CustomGlideStreamLoader 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;
}
Aggregations