use of com.caverock.androidsvg.SVG in project android by nextcloud.
the class ActivityListAdapter method downloadIcon.
private void downloadIcon(Activity activity, ImageView itemViewType) {
GenericRequestBuilder<Uri, InputStream, SVG, Bitmap> requestBuilder = Glide.with(context).using(Glide.buildStreamModelLoader(Uri.class, context), InputStream.class).from(Uri.class).as(SVG.class).transcode(new SvgBitmapTranscoder(128, 128), Bitmap.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);
Uri uri = Uri.parse(activity.getIcon());
requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE).load(uri).into(itemViewType);
}
use of com.caverock.androidsvg.SVG 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.caverock.androidsvg.SVG in project android by nextcloud.
the class SvgBitmapTranscoder method transcode.
@Override
public Resource<Bitmap> transcode(Resource<SVG> toTranscode) {
SVG svg = toTranscode.get();
try {
svg.setDocumentHeight("100%");
svg.setDocumentWidth("100%");
} catch (SVGParseException e) {
Log_OC.e(this, "Could not set document size. Output might have wrong size");
}
// Create a canvas to draw onto
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
// Render our document onto our canvas
svg.renderToCanvas(canvas);
return new SimpleResource<>(bitmap);
}
use of com.caverock.androidsvg.SVG 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.caverock.androidsvg.SVG in project openhab-android by openhab.
the class MyWebImage method getBitmapFromSvgInputstream.
private Bitmap getBitmapFromSvgInputstream(InputStream is) {
Bitmap bitmap = null;
try {
SVG svg = SVG.getFromInputStream(is);
double width = 16;
double height = 16;
if (svg.getDocumentViewBox() != null) {
width = svg.getDocumentViewBox().width();
height = svg.getDocumentViewBox().height();
} else {
Log.d(TAG, "DocumentViewBox is null. assuming width and heigh of 16px.");
}
bitmap = Bitmap.createBitmap((int) Math.ceil(width), (int) Math.ceil(height), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
// drawARGB(0,0,0,0);//drawRGB(255, 255, 255);
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
svg.renderToCanvas(canvas);
} catch (SVGParseException e) {
Log.e(TAG, e.getMessage(), e);
}
return bitmap;
}
Aggregations