예제 #1
0
  @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;
  }
예제 #2
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));
   }
 }
예제 #3
0
 @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));
   }
 }
예제 #4
0
  @Override
  public void tearDown() {
    if (mViewAdapter == null) {
      return;
    }

    ViewUtil.onRemoveView(this);
    mViewAdapter.stop(null);

    if (mImageCache != null) {
      synchronized (mImageCache) {
        mImageCache.clear();
      }
      mImageCache = null;
    }
    if (mRegenBitmap != null) {
      synchronized (mRegenBitmap) {
        mRegenBitmap.recycle();
      }
      mRegenBitmap = null;
    }
    if (mCachedBitmap != null) {
      synchronized (mCachedBitmap) {
        mCachedBitmap.recycle();
      }
      mCachedBitmap = null;
    }
    synchronized (GiCoreView.class) {
      mCoreView.destoryView(mViewAdapter);
      mViewAdapter.delete();
      mViewAdapter = null;
      mCoreView.delete();
      mCoreView = null;
    }
    if (mCanvasOnDraw != null) {
      mCanvasOnDraw.delete();
      mCanvasOnDraw = null;
    }
    if (mCanvasRegen != null) {
      mCanvasRegen.delete();
      mCanvasRegen = null;
    }
    if (mGestureListener != null) {
      mGestureListener.release();
      mGestureListener = null;
    }
    mGestureDetector = null;
    mMainView = null;
  }