Example #1
0
 @Override
 public boolean onDoubleTap(MotionEvent e) {
   Log.d(TAG, "############## Inside of onDoubleTap() : " + e.toString());
   Toast.makeText(MainActivity.this, "Double Tap", Toast.LENGTH_SHORT).show();
   // handle double tap
   return true;
 }
 @Override
 public final boolean onTouchEvent(MotionEvent event) {
   if (DEBUG) {
     Log.d(LOG_TAG, "onTouchEvent. " + event.toString());
   }
   if (isEnabled() && mPullToRefreshAttacher != null) {
     return mPullToRefreshAttacher.onTouchEvent(event);
   }
   return super.onTouchEvent(event);
 }
 @Override
 public final boolean onInterceptTouchEvent(MotionEvent event) {
   if (DEBUG) {
     Log.d(LOG_TAG, "onInterceptTouchEvent. " + event.toString());
   }
   if (isEnabled() && mPullToRefreshAttacher != null && getChildCount() > 0) {
     return mPullToRefreshAttacher.onInterceptTouchEvent(event);
   }
   return false;
 }
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    float eventX = event.getX();
    float eventY = event.getY();

    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        path.moveTo(eventX, eventY);
        lastTouchX = eventX;
        lastTouchY = eventY;
        // There is no end point yet, so don't waste cycles invalidating.
        return true;

      case MotionEvent.ACTION_MOVE:
      case MotionEvent.ACTION_UP:
        // Start tracking the dirty region.
        resetDirtyRect(eventX, eventY);

        // When the hardware tracks events faster than they are delivered, the
        // event will contain a history of those skipped points.
        int historySize = event.getHistorySize();
        for (int i = 0; i < historySize; i++) {
          float historicalX = event.getHistoricalX(i);
          float historicalY = event.getHistoricalY(i);
          expandDirtyRect(historicalX, historicalY);
          path.lineTo(historicalX, historicalY);
        }

        // After replaying history, connect the line to the touch point.
        path.lineTo(eventX, eventY);
        break;

      default:
        Log.d("default", "Ignored touch event: " + event.toString());
        return false;
    }

    // Include half the stroke width to avoid clipping.
    invalidate(
        (int) (dirtyRect.left - HALF_STROKE_WIDTH),
        (int) (dirtyRect.top - HALF_STROKE_WIDTH),
        (int) (dirtyRect.right + HALF_STROKE_WIDTH),
        (int) (dirtyRect.bottom + HALF_STROKE_WIDTH));

    lastTouchX = eventX;
    lastTouchY = eventY;

    return true;
  }
  @Override
  public boolean dispatchTouchEvent(MotionEvent ev) {
    Log.i(LOG_STRING, "touch event: " + ev.toString());
    // + " eventTime: " + ev.getEventTime() + " downtime: " + ev.getDownTime());
    //  + " xraw: " + ev.getRawX() +" x: "+ev.getX()
    //  + " yraw: " + ev.getRawY() +" y: "+ev.getY());
    // mDemonstration.addMotionEvent(ev);
    Parcel parcel = Parcel.obtain();
    parcel.writeParcelable(ev, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
    // add motionevent to parcel
    try {
      if (mBinder == null) {
        Log.e(LOG_STRING, "Null binder!");
      }
      mBinder.transact(DemonstrationService.MOTION_EVENT_CODE, parcel, null, IBinder.FLAG_ONEWAY);
    } catch (RemoteException e) {
      Log.e(LOG_STRING, "Error transacting with demonstration service: " + e.toString());
    }

    if (mExplorationEnabled) {
      int pointers = ev.getPointerCount();

      if (ev.getPointerCount() == 1) {
        ViewGroup target = this;

        if (ev.getAction() == MotionEvent.ACTION_OUTSIDE) {
          ev.setAction(MotionEvent.ACTION_DOWN);
          mDetector.onTouchEvent(ev);
          ev.setAction(MotionEvent.ACTION_UP);
        }

        mDetector.onTouchEvent(ev);

        return true;
      }

      ev = stripLastPointer(ev);
    }

    return super.dispatchTouchEvent(ev);
  }
Example #6
0
  @Override
  public boolean onTouchEvent(MotionEvent event) {
    String tag = "Seekbar";
    Log.d(tag, event.toString());
    Log.d(tag, "------------");
    requestParentTouchRecursive(getParent(), true);

    if (!isEnabled()) {
      return false;
    }

    switch (event.getAction()) {
      case MotionEvent.ACTION_UP:
        onSeekBarChangeListener.onStopTrackingTouch(this);
        invalidate();
        requestParentTouchRecursive(getParent(), false);
        break;
      case MotionEvent.ACTION_DOWN:
        onSeekBarChangeListener.onStartTrackingTouch(this);
        invalidate();
        break;
      case MotionEvent.ACTION_MOVE:
        int pos = (int) (getMax() * event.getX() / getWidth());
        Log.d(tag, "pos => " + pos);
        setProgress(pos);
        onSeekBarChangeListener.onProgressChanged(this, pos, true);
        // onSizeChanged(getWidth(), getHeight(), 0, 0);
        invalidate();
        break;

      default:
      case MotionEvent.ACTION_CANCEL:
        onSeekBarChangeListener.onProgressChanged(this, getProgress(), true);
        requestParentTouchRecursive(getParent(), false);
        invalidate();
        break;
    }
    return true;
  }
 @Override
 public boolean dispatchTrackballEvent(MotionEvent ev) {
   Log.i(LOG_STRING, "trackball event: " + ev.toString());
   return super.dispatchTrackballEvent(ev);
 }
 @Override
 public boolean onTouchEvent(MotionEvent event) {
   // TODO Auto-generated method stub
   Log.d("TOUCH", event.toString());
   return super.onTouchEvent(event);
 }
Example #9
0
 @Override
 public void onLongPress(MotionEvent e) {
   Log.d(TAG, "############## Inside of onLongPress() : " + e.toString());
   Toast.makeText(MainActivity.this, "Long Pressed", Toast.LENGTH_SHORT).show();
 }
Example #10
0
 @Override
 public boolean onSingleTapConfirmed(MotionEvent e) {
   Log.d(TAG, "############## Inside of onSingleTapConfirmed() : " + e.toString());
   Toast.makeText(MainActivity.this, "Single TAP", Toast.LENGTH_SHORT).show();
   return true;
 }