@Override public int insertImageFromFile(String filename) { final BaseViewAdapter adapter = internalAdapter(); if (adapter == null || filename == null) return 0; String name = filename.substring(filename.lastIndexOf('/') + 1).toLowerCase(Locale.US); Drawable d; if (name.endsWith(".svg")) { d = mView.getImageCache().addSVGFile(filename, name); } else { d = mView.getImageCache().addBitmapFile(getContext().getResources(), filename, name); } if (d != null) { final String destPath = adapter.getRecordPath(); if (destPath != null) { ImageCache.copyFileTo(filename, destPath); } synchronized (mView.coreView()) { int w = ImageCache.getWidth(d); int h = ImageCache.getHeight(d); return mView.coreView().addImageShape(name, w, h); } } return 0; }
@Override public int insertBitmapFromResource(String name) { int id = ResourceUtil.getDrawableIDFromName(getContext(), name); name = ImageCache.BITMAP_PREFIX + name; final Drawable d = mView.getImageCache().addBitmap(getContext().getResources(), id, name); synchronized (mView.coreView()) { return d == null ? 0 : mView.coreView().addImageShape(name, ImageCache.getWidth(d), ImageCache.getHeight(d)); } }
@Override public int insertSVGFromResource(String name, int xc, int yc) { int id = ResourceUtil.getResIDFromName(getContext(), "raw", name); name = ImageCache.SVG_PREFIX + name; final Drawable d = mView.getImageCache().addSVG(getContext().getResources(), id, name); synchronized (mView.coreView()) { return d == null ? 0 : mView .coreView() .addImageShape(name, xc, yc, ImageCache.getWidth(d), ImageCache.getHeight(d)); } }