示例#1
0
 @Override
 protected void onDraw(Canvas canvas) {
     mCoreView.onSize(mViewAdapter, this.getWidth(), this.getHeight());
     
     if (mCanvasAdapter.beginPaint(canvas)) {
         mCoreView.drawAll(mViewAdapter, mCanvasAdapter);
         if (mDynDrawView == null) {
             mCoreView.dynDraw(mViewAdapter, mCanvasAdapter);
         }
         mCanvasAdapter.endPaint();
     }
     mEndPaintTime = android.os.SystemClock.uptimeMillis();
     mDrawnTime = mEndPaintTime - mBeginTime;
 }
示例#2
0
 public GraphView(Context context) {
     super(context);
     mCanvasAdapter = new CanvasAdapter(this);
     mViewAdapter = new ViewAdapter();
     mCoreView = new GiCoreView(null);
     mCoreView.createView(mViewAdapter, 0);
     
     DisplayMetrics dm = context.getApplicationContext().getResources().getDisplayMetrics();
     GiCoreView.setScreenDpi(dm.densityDpi);
     
     this.setOnTouchListener(new OnTouchListener() {
         public boolean onTouch(View v, MotionEvent event) {
             if (event.getAction() == MotionEvent.ACTION_DOWN) {
                 mCoreView.onGesture(mViewAdapter, GiGestureType.kGiGesturePan, 
                         GiGestureState.kGiGestureBegan, event.getX(), event.getY());
             }
             else if (event.getAction() == MotionEvent.ACTION_UP) {
                 mCoreView.onGesture(mViewAdapter, GiGestureType.kGiGesturePan, 
                         GiGestureState.kGiGestureEnded, event.getX(), event.getY());
                 showTime();
             }
             else if (mDynDrawView != null
                     && event.getEventTime() > mDynDrawView.getEndPaintTime()) {
                 mCoreView.onGesture(mViewAdapter, GiGestureType.kGiGesturePan, 
                         GiGestureState.kGiGestureMoved, event.getX(), event.getY());
                 showTime();
             }
             else if (mDynDrawView == null && event.getEventTime() > mEndPaintTime) {
                 mCoreView.onGesture(mViewAdapter, GiGestureType.kGiGesturePan, 
                         GiGestureState.kGiGestureMoved, event.getX(), event.getY());
                 showTime();
             }
             return true;
         }
     });
 }
示例#3
0
 @Override
 protected void onDetachedFromWindow() {
     if (mDynDrawView != null) {
         mDynDrawView.setCoreView(null, null);
         mDynDrawView = null;
     }
     if (mViewAdapter != null) {
         mViewAdapter.delete();
         mViewAdapter = null;
     }
     if (mCoreView != null) {
         mCoreView.delete();
         mCoreView = null;
     }
     if (mCanvasAdapter != null) {
         mCanvasAdapter.delete();
         mCanvasAdapter = null;
     }
     super.onDetachedFromWindow();
 }