コード例 #1
0
 protected Picture doInBackground(Integer... resourceId) {
   try {
     SVG svg = SVG.getFromResource(getContext(), resourceId[0]);
     return svg.renderToPicture();
   } catch (SVGParseException e) {
     Log.e(
         "SVGImageView",
         String.format("Error loading resource 0x%x: %s", resourceId, e.getMessage()));
   }
   return null;
 }
コード例 #2
0
    protected Picture doInBackground(String... filename) {
      try {
        SVG svg = SVG.getFromAsset(getContext().getAssets(), filename[0]);

        return svg.renderToPicture();
      } catch (SVGParseException e) {
        Log.e("SVGImageView", "Error loading file " + filename + ": " + e.getMessage());
      } catch (FileNotFoundException e) {
        Log.e("SVGImageView", "File not found: " + filename);
      } catch (IOException e) {
        Log.e("SVGImageView", "Unable to load asset file: " + filename, e);
      }
      return null;
    }
コード例 #3
0
    protected Picture doInBackground(InputStream... is) {
      try {

        Log.w("in LOADURITASK", "Loading URI");

        SVG svg = SVG.getFromInputStream(is[0]);
        return svg.renderToPicture();
      } catch (SVGParseException e) {
        Log.e("SVGImageView", "Parse error loading URI: " + e.getMessage());
      } finally {
        try {
          is[0].close();
        } catch (IOException e) {
          /* do nothing */
        }
      }
      return null;
    }
コード例 #4
0
  /** Directly set the SVG. */
  public void setSVG(SVG mysvg) {
    if (mysvg == null) throw new IllegalArgumentException("Null value passed to setSVG()");

    setSoftwareLayerType();
    setImageDrawable(new PictureDrawable(mysvg.renderToPicture()));
  }