Search in sources :

Example 1 with FileToStreamDecoder

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);
}
Also used : FileToStreamDecoder(com.bumptech.glide.load.resource.file.FileToStreamDecoder) SVG(com.caverock.androidsvg.SVG) SvgDrawableTranscoder(com.owncloud.android.utils.svg.SvgDrawableTranscoder) InputStream(java.io.InputStream) PictureDrawable(android.graphics.drawable.PictureDrawable) SvgDecoder(com.owncloud.android.utils.svg.SvgDecoder) Uri(android.net.Uri) StreamEncoder(com.bumptech.glide.load.model.StreamEncoder)

Example 2 with FileToStreamDecoder

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);
}
Also used : FileToStreamDecoder(com.bumptech.glide.load.resource.file.FileToStreamDecoder) SVG(com.caverock.androidsvg.SVG) SvgDrawableTranscoder(com.owncloud.android.utils.svg.SvgDrawableTranscoder) InputStream(java.io.InputStream) PictureDrawable(android.graphics.drawable.PictureDrawable) SvgDecoder(com.owncloud.android.utils.svg.SvgDecoder) Uri(android.net.Uri) StreamEncoder(com.bumptech.glide.load.model.StreamEncoder)

Example 3 with FileToStreamDecoder

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);
        }
    }
}
Also used : SVGorImage(com.owncloud.android.utils.svg.SVGorImage) FileToStreamDecoder(com.bumptech.glide.load.resource.file.FileToStreamDecoder) OCCapability(com.owncloud.android.lib.resources.status.OCCapability) InputStream(java.io.InputStream) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) LayerDrawable(android.graphics.drawable.LayerDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation) Uri(android.net.Uri) MenuSimpleTarget(com.owncloud.android.utils.svg.MenuSimpleTarget) SimpleTarget(com.bumptech.glide.request.target.SimpleTarget) Bitmap(android.graphics.Bitmap) SvgOrImageDecoder(com.owncloud.android.utils.svg.SvgOrImageDecoder) ColorDrawable(android.graphics.drawable.ColorDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) SvgOrImageBitmapTranscoder(com.owncloud.android.utils.svg.SvgOrImageBitmapTranscoder) LinearLayout(android.widget.LinearLayout) StreamEncoder(com.bumptech.glide.load.model.StreamEncoder)

Aggregations

Uri (android.net.Uri)3 StreamEncoder (com.bumptech.glide.load.model.StreamEncoder)3 FileToStreamDecoder (com.bumptech.glide.load.resource.file.FileToStreamDecoder)3 InputStream (java.io.InputStream)3 PictureDrawable (android.graphics.drawable.PictureDrawable)2 SVG (com.caverock.androidsvg.SVG)2 SvgDecoder (com.owncloud.android.utils.svg.SvgDecoder)2 SvgDrawableTranscoder (com.owncloud.android.utils.svg.SvgDrawableTranscoder)2 Bitmap (android.graphics.Bitmap)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 LayerDrawable (android.graphics.drawable.LayerDrawable)1 LinearLayout (android.widget.LinearLayout)1 GlideAnimation (com.bumptech.glide.request.animation.GlideAnimation)1 SimpleTarget (com.bumptech.glide.request.target.SimpleTarget)1 OCCapability (com.owncloud.android.lib.resources.status.OCCapability)1 MenuSimpleTarget (com.owncloud.android.utils.svg.MenuSimpleTarget)1 SVGorImage (com.owncloud.android.utils.svg.SVGorImage)1 SvgOrImageBitmapTranscoder (com.owncloud.android.utils.svg.SvgOrImageBitmapTranscoder)1