Search in sources :

Example 1 with PictureDrawable

use of android.graphics.drawable.PictureDrawable in project glide by bumptech.

the class SvgDrawableTranscoder method transcode.

@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
    SVG svg = toTranscode.get();
    Picture picture = svg.renderToPicture();
    PictureDrawable drawable = new PictureDrawable(picture);
    return new SimpleResource<PictureDrawable>(drawable);
}
Also used : SVG(com.caverock.androidsvg.SVG) Picture(android.graphics.Picture) PictureDrawable(android.graphics.drawable.PictureDrawable) SimpleResource(com.bumptech.glide.load.resource.SimpleResource)

Example 2 with PictureDrawable

use of android.graphics.drawable.PictureDrawable in project android by nextcloud.

the class DisplayUtils method downloadSVGIcon.

private static void downloadSVGIcon(Context context, String iconUrl, SimpleTarget imageView, int placeholder, int width, int height) {
    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(height, width))).decoder(new SvgDecoder(height, width)).placeholder(placeholder).error(placeholder).animate(android.R.anim.fade_in);
    Uri uri = Uri.parse(iconUrl);
    requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE).load(uri).into(imageView);
}
Also used : 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 PictureDrawable

use of android.graphics.drawable.PictureDrawable 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 4 with PictureDrawable

use of android.graphics.drawable.PictureDrawable 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 5 with PictureDrawable

use of android.graphics.drawable.PictureDrawable in project PocketHub by pockethub.

the class SvgDrawableTranscoder method transcode.

@Nullable
@Override
public Resource<Drawable> transcode(@NonNull Resource<SVG> toTranscode, @NonNull Options options) {
    SVG svg = toTranscode.get();
    float ratio = svg.getDocumentAspectRatio();
    int width = svg.getDocumentWidth() > 0 ? (int) svg.getDocumentWidth() : 1024;
    int height = (int) (svg.getDocumentHeight() > 0 ? svg.getDocumentHeight() : (width / ratio));
    Picture picture = svg.renderToPicture(width, height);
    PictureDrawable drawable = new PictureDrawable(picture);
    return new SimpleResource<>(drawable);
}
Also used : SVG(com.caverock.androidsvg.SVG) Picture(android.graphics.Picture) PictureDrawable(android.graphics.drawable.PictureDrawable) SimpleResource(com.bumptech.glide.load.resource.SimpleResource) Nullable(androidx.annotation.Nullable)

Aggregations

PictureDrawable (android.graphics.drawable.PictureDrawable)8 SVG (com.caverock.androidsvg.SVG)8 Picture (android.graphics.Picture)4 Uri (android.net.Uri)4 StreamEncoder (com.bumptech.glide.load.model.StreamEncoder)4 SimpleResource (com.bumptech.glide.load.resource.SimpleResource)4 SvgDecoder (com.owncloud.android.utils.svg.SvgDecoder)4 SvgDrawableTranscoder (com.owncloud.android.utils.svg.SvgDrawableTranscoder)4 InputStream (java.io.InputStream)4 FileToStreamDecoder (com.bumptech.glide.load.resource.file.FileToStreamDecoder)2 Nullable (android.support.annotation.Nullable)1 Nullable (androidx.annotation.Nullable)1 CustomGlideUriLoader (com.owncloud.android.utils.glide.CustomGlideUriLoader)1