use of com.bumptech.glide.load.resource.file.FileToStreamDecoder in project android by nextcloud.
the class NotificationListAdapter method downloadIcon.
private void downloadIcon(String icon, ImageView itemViewType) {
GenericRequestBuilder<Uri, InputStream, SVG, PictureDrawable> requestBuilder = Glide.with(notificationsActivity).using(Glide.buildStreamModelLoader(Uri.class, notificationsActivity), InputStream.class).from(Uri.class).as(SVG.class).transcode(new SvgDrawableTranscoder(), PictureDrawable.class).sourceEncoder(new StreamEncoder()).cacheDecoder(new FileToStreamDecoder<>(new SvgDecoder())).decoder(new SvgDecoder()).placeholder(R.drawable.ic_notification).error(R.drawable.ic_notification).animate(android.R.anim.fade_in).listener(new SvgSoftwareLayerSetter<>());
Uri uri = Uri.parse(icon);
requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE).load(uri).into(itemViewType);
}
use of com.bumptech.glide.load.resource.file.FileToStreamDecoder in project android by nextcloud.
the class ActivityListAdapter method downloadIcon.
private void downloadIcon(String icon, ImageView itemViewType) {
GenericRequestBuilder<Uri, InputStream, SVG, PictureDrawable> requestBuilder = Glide.with(context).using(Glide.buildStreamModelLoader(Uri.class, context), InputStream.class).from(Uri.class).as(SVG.class).transcode(new SvgDrawableTranscoder(), PictureDrawable.class).sourceEncoder(new StreamEncoder()).cacheDecoder(new FileToStreamDecoder<>(new SvgDecoder())).decoder(new SvgDecoder()).placeholder(R.drawable.ic_activity).error(R.drawable.ic_activity).animate(android.R.anim.fade_in).listener(new SvgSoftwareLayerSetter<>());
Uri uri = Uri.parse(icon);
requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE).load(uri).into(itemViewType);
}
use of com.bumptech.glide.load.resource.file.FileToStreamDecoder in project android by nextcloud.
the class DrawerActivity method updateHeader.
public void updateHeader() {
if (getAccount() != null && getStorageManager().getCapability(getAccount().name).getServerBackground() != null) {
OCCapability capability = getStorageManager().getCapability(getAccount().name);
String logo = capability.getServerLogo();
int primaryColor = ThemeColorUtils.primaryColor(getAccount(), false, this);
// set background to primary color
LinearLayout drawerHeader = mNavigationViewHeader.findViewById(R.id.drawer_header_view);
drawerHeader.setBackgroundColor(ThemeColorUtils.unchangedPrimaryColor(getAccount(), this));
if (!TextUtils.isEmpty(logo) && URLUtil.isValidUrl(logo)) {
// background image
GenericRequestBuilder<Uri, InputStream, SVGorImage, Bitmap> requestBuilder = Glide.with(this).using(Glide.buildStreamModelLoader(Uri.class, this), InputStream.class).from(Uri.class).as(SVGorImage.class).transcode(new SvgOrImageBitmapTranscoder(128, 128), Bitmap.class).sourceEncoder(new StreamEncoder()).cacheDecoder(new FileToStreamDecoder<>(new SvgOrImageDecoder())).decoder(new SvgOrImageDecoder());
// background image
SimpleTarget target = new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
Bitmap logo = resource;
int width = resource.getWidth();
int height = resource.getHeight();
int max = Math.max(width, height);
if (max > MAX_LOGO_SIZE_PX) {
logo = BitmapUtils.scaleBitmap(resource, MAX_LOGO_SIZE_PX, width, height, max);
}
Drawable[] drawables = { new ColorDrawable(primaryColor), new BitmapDrawable(logo) };
LayerDrawable layerDrawable = new LayerDrawable(drawables);
String name = capability.getServerName();
setDrawerHeaderLogo(layerDrawable, name);
}
};
requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE).load(Uri.parse(logo)).into(target);
}
}
}
Aggregations