Beispiel #1
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));
   }
 }
Beispiel #2
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));
   }
 }
Beispiel #3
0
  protected void initView(Context context) {
    mGestureListener = new GestureListener(mCoreView, mViewAdapter, this);
    mGestureDetector = new GestureDetector(context, mGestureListener);
    ResourceUtil.setContextImages(context);

    final DisplayMetrics dm = context.getApplicationContext().getResources().getDisplayMetrics();
    GiCoreView.setScreenDpi(dm.densityDpi, dm.density);
    if (mCanvasRegen != null) {
      // 避免路径太大不能渲染
      setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    this.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent e) {
            if (mCoreView == null || !mGestureEnable) {
              return false;
            }
            if (e.getActionMasked() == MotionEvent.ACTION_DOWN) {
              activateView();
            }

            boolean ret;

            if (mCoreView.isCommand("splines")) {
              ret = mGestureListener.onTouchDrag(v, e.getActionMasked(), e.getX(0), e.getY(0));
            } else {
              ret = mGestureListener.onTouch(v, e) || mGestureDetector.onTouchEvent(e);
              if (mGestureListener.getLastGesture() == GiGestureType.kGiGestureTap) {
                v.performClick();
              }
            }
            return ret;
          }
        });
  }
Beispiel #4
0
 @Override
 public int insertBitmapFromResource(int id, int xc, int yc) {
   return insertBitmapFromResource(ResourceUtil.getResName(getContext(), id), xc, yc);
 }
Beispiel #5
0
 @Override
 public int insertSVGFromResource(int id) {
   return insertSVGFromResource(ResourceUtil.getResName(getContext(), id));
 }
Beispiel #6
0
 @Override
 public void setExtraContextImages(Context context, int[] ids) {
   ResourceUtil.setExtraContextImages(context, ids);
 }