@Override
 public Resource<Bitmap> transcode(Resource<SVG> toTranscode) {
   SVG svg = toTranscode.get();
   Picture picture = svg.renderToPicture();
   PictureDrawable drawable = new PictureDrawable(picture);
   return new SimpleResource<>(pictureDrawableToBitmap(drawable));
 }
Ejemplo n.º 2
0
 @Override
 public void run() {
   try {
     for (int resource : mSvgResources) {
       SVG item = SVG.getFromResource(mContext, resource);
       addSvgToCache(resource, item);
     }
   } catch (SVGParseException e) {
     Logger.log(e);
   }
 }
Ejemplo n.º 3
0
  /** This method is called on creation of the activity. */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // ADD SVG COAT OF ARMS BY SETTING ImageView in the layout
    // SVG SOURCE:
    // https://commons.wikimedia.org/wiki/File:Coat_of_Arms_of_the_Russian_Federation_bw2.svg
    // SVG AUTHOR: Федеральный конституционный закон «О Государственном гербе Российской Федерации»
    SVG svg = null;
    try {
      svg = SVG.getFromResource(this, R.raw.coat);
    } catch (SVGParseException e) {
      e.printStackTrace();
    }
    SVGImageView svgImageView = new SVGImageView(this);
    Drawable drawableCoat = new PictureDrawable(svg.renderToPicture());
    ImageView coatImage = (ImageView) findViewById(R.id.coatImage);
    coatImage.setImageDrawable(drawableCoat);
  }
Ejemplo n.º 4
0
 @Override
 protected int sizeOf(final Integer key, final SVG value) {
   return value.toString().length();
 }