List of usage examples for android.view MotionEvent ACTION_MASK
int ACTION_MASK
To view the source code for android.view MotionEvent ACTION_MASK.
Click Source Link
From source file:com.xyczero.customswipelistview.CustomSwipeListView.java
@Override public boolean onTouchEvent(MotionEvent ev) { // Just response single finger action. final int action = ev.getAction() & MotionEvent.ACTION_MASK; final int x = (int) ev.getX(); if (action == MotionEvent.ACTION_DOWN && ev.getEdgeFlags() != 0) { ev.setAction(MotionEvent.ACTION_CANCEL); return super.onTouchEvent(ev); }// w w w . j av a 2 s .com if (mSelectedPosition != INVALID_POSITION) { addVelocityTrackerMotionEvent(ev); switch (action) { case MotionEvent.ACTION_DOWN: Log.d(TAG, "onTouchEvent:ACTION_DOWN"); // If there is a itemswipeview and then don't click it // by the next down action,it will first return to original // state and cancel to response the following actions. if (isItemSwipeViewVisible) { if (!isClickItemSwipeView) { mLastItemSwipeView.setVisibility(GONE); mLastItemMainView.scrollTo(0, 0); } isItemSwipeViewVisible = false; ev.setAction(MotionEvent.ACTION_CANCEL); return super.onTouchEvent(ev); } break; case MotionEvent.ACTION_MOVE: Log.d(TAG, "onTouchEvent:ACTION_MOVE"); mVelocityTracker.getYVelocity(); // determine whether the swipe action. if (Math.abs(getScrollXVelocity()) > mMinimumVelocity || (Math.abs(ev.getX() - mDownMotionX) > mTouchSlop && Math.abs(ev.getY() - mDownMotionY) < mTouchSlop)) { isSwiping = true; } if (isSwiping) { int deltaX = (int) mDownMotionX - x; if (deltaX > 0 && mEnableSwipeItemLeft || deltaX < 0 && mEnableSwipeItemRight) { mDownMotionX = x; mCurItemMainView.scrollBy(deltaX, 0); } // if super.onTouchEvent() that been called there,it might // lead to the specified item out of focus due to the // function might call itemClick function in the sliding. return true; } break; case MotionEvent.ACTION_UP: Log.d(TAG, "onTouchEvent:ACTION_UP"); if (isSwiping) { mLastItemMainView = mCurItemMainView; mLastItemSwipeView = mCurItemSwipeView; final int velocityX = getScrollXVelocity(); if (velocityX > mMinimumVelocity) { scrollByTouchSwipeMode(TOUCH_SWIPE_RIGHT, -mScreenWidth); } else if (velocityX < -mMinimumVelocity) { scrollByTouchSwipeMode(TOUCH_SWIPE_LEFT, getItemSwipeViewWidth(mLastItemSwipeView)); } else { scrollByTouchSwipeMode(TOUCH_SWIPE_AUTO, Integer.MIN_VALUE); } recycleVelocityTracker(); // TODO:To be optimized for not calling computeScroll // function. if (mScroller.isFinished()) { isSwiping = false; } // prevent to trigger OnItemClick by transverse sliding // distance too slow or too small OnItemClick events when in // swipe mode. ev.setAction(MotionEvent.ACTION_CANCEL); return super.onTouchEvent(ev); } break; default: break; } } return super.onTouchEvent(ev); }
From source file:org.witness.informacam.app.editors.image.ImageRegion.java
public boolean onTouch(View v, MotionEvent event) { fingerCount = event.getPointerCount(); // Log.v(LOGTAG,"onTouch: fingers=" + fingerCount); switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: mImageEditor.doRealtimePreview = true; mImageEditor.updateDisplayImage(); //mTmpBounds = new RectF(mBounds); if (fingerCount == 1) { //float[] points = {event.getX(), event.getY()}; //iMatrix.mapPoints(points); //mStartPoint = new PointF(points[0],points[1]); mStartPoint = new PointF(event.getX(), event.getY()); //Log.v(LOGTAG,"startPoint: " + mStartPoint.x + " " + mStartPoint.y); }/*from www .j a v a 2s . c om*/ moved = false; return false; case MotionEvent.ACTION_POINTER_UP: Log.v(LOGTAG, "second finger removed - pointer up!"); return moved; case MotionEvent.ACTION_UP: mImageEditor.doRealtimePreview = true; mImageEditor.updateDisplayImage(); //mTmpBounds = null; return moved; case MotionEvent.ACTION_MOVE: if (fingerCount > 1) { float[] points = { event.getX(0), event.getY(0), event.getX(1), event.getY(1) }; iMatrix.mapPoints(points); mStartPoint = new PointF(points[0], points[1]); RectF newBox = new RectF(); newBox.left = Math.min(points[0], points[2]); newBox.top = Math.min(points[1], points[3]); newBox.right = Math.max(points[0], points[2]); newBox.bottom = Math.max(points[1], points[3]); moved = true; if (newBox.left != newBox.right && newBox.top != newBox.bottom) { updateBounds(newBox.left, newBox.top, newBox.right, newBox.bottom); } } else if (fingerCount == 1) { if (Math.abs(mStartPoint.x - event.getX()) > MIN_MOVE) { moved = true; float[] points = { mStartPoint.x, mStartPoint.y, event.getX(), event.getY() }; iMatrix.mapPoints(points); float diffX = points[0] - points[2]; float diffY = points[1] - points[3]; float left = 0, top = 0, right = 0, bottom = 0; if (cornerMode == CORNER_NONE) { left = mBounds.left - diffX; top = mBounds.top - diffY; right = mBounds.right - diffX; bottom = mBounds.bottom - diffY; } else if (cornerMode == CORNER_UPPER_LEFT) { left = mBounds.left - diffX; top = mBounds.top - diffY; right = mBounds.right; bottom = mBounds.bottom; } else if (cornerMode == CORNER_LOWER_LEFT) { left = mBounds.left - diffX; top = mBounds.top; right = mBounds.right; bottom = mBounds.bottom - diffY; } else if (cornerMode == CORNER_UPPER_RIGHT) { left = mBounds.left; top = mBounds.top - diffY; right = mBounds.right - diffX; bottom = mBounds.bottom; } else if (cornerMode == CORNER_LOWER_RIGHT) { left = mBounds.left; top = mBounds.top; right = mBounds.right - diffX; bottom = mBounds.bottom - diffY; } if ((left + CORNER_MAX) > right || (top + CORNER_MAX) > bottom) return false; //updateBounds(Math.min(left, right), Math.min(top,bottom), Math.max(left, right), Math.max(top, bottom)); updateBounds(left, top, right, bottom); mStartPoint = new PointF(event.getX(), event.getY()); } else { moved = false; } } mImageEditor.updateDisplayImage(); return true; } return false; }
From source file:com.nextgis.maplibui.fragment.ReorderedLayerView.java
@Override public boolean onTouchEvent(@NonNull MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: mDownX = (int) event.getX(); mDownY = (int) event.getY(); mActivePointerId = event.getPointerId(0); break;//from www. j a va2 s. co m case MotionEvent.ACTION_MOVE: if (mActivePointerId == NOT_FOUND) { break; } int pointerIndex = event.findPointerIndex(mActivePointerId); mLastEventY = (int) event.getY(pointerIndex); int deltaY = mLastEventY - mDownY; if (mCellIsMobile) { int top = mHoverCellOriginalBounds.top + deltaY + mTotalOffset; mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, top); mHoverCell.setBounds(mHoverCellCurrentBounds); invalidate(); handleCellSwitch(); mIsMobileScrolling = false; handleMobileCellScroll(); return false; } break; case MotionEvent.ACTION_UP: touchEventsEnded(); setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); ((LayersListAdapter) getAdapter()).notifyDataChanged(); break; case MotionEvent.ACTION_CANCEL: touchEventsCancelled(); setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); break; case MotionEvent.ACTION_POINTER_UP: /* If a multitouch event took place and the original touch dictating * the movement of the hover cell has ended, then the dragging event * ends and the hover cell is animated to its corresponding position * in the listview. */ pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; final int pointerId = event.getPointerId(pointerIndex); if (pointerId == mActivePointerId) { touchEventsEnded(); } setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); break; default: break; } return super.onTouchEvent(event); }
From source file:com.dgnt.dominionCardPicker.view.DynamicListView.java
@Override public boolean onTouchEvent(MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: mDownX = (int) event.getX(); mDownY = (int) event.getY(); mActivePointerId = event.getPointerId(0); break;//from ww w. ja v a 2 s.c o m case MotionEvent.ACTION_MOVE: if (mActivePointerId == INVALID_POINTER_ID) { break; } int pointerIndex = event.findPointerIndex(mActivePointerId); mLastEventY = (int) event.getY(pointerIndex); int deltaY = mLastEventY - mDownY; if (mCellIsMobile) { mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mHoverCellOriginalBounds.top + deltaY + mTotalOffset); mHoverCell.setBounds(mHoverCellCurrentBounds); invalidate(); handleCellSwitch(); mIsMobileScrolling = false; handleMobileCellScroll(); return false; } break; case MotionEvent.ACTION_UP: touchEventsEnded(); break; case MotionEvent.ACTION_CANCEL: touchEventsCancelled(); break; case MotionEvent.ACTION_POINTER_UP: /* If a multitouch event took place and the original touch dictating * the movement of the hover cell has ended, then the dragging event * ends and the hover cell is animated to its corresponding position * in the listview. */ pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; final int pointerId = event.getPointerId(pointerIndex); if (pointerId == mActivePointerId) { touchEventsEnded(); } break; default: break; } return super.onTouchEvent(event); }
From source file:com.example.customview.DynamicListView.java
@Override public boolean onTouchEvent(MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: mDownX = (int) event.getX(); mDownY = (int) event.getY(); mActivePointerId = event.getPointerId(0); break;/*www . j av a 2 s . c om*/ case MotionEvent.ACTION_MOVE: if (mActivePointerId == INVALID_POINTER_ID) { break; } int pointerIndex = event.findPointerIndex(mActivePointerId); mLastEventY = (int) event.getY(pointerIndex); int deltaY = mLastEventY - mDownY; if (mCellIsMobile) { mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mHoverCellOriginalBounds.top + deltaY + mTotalOffset); mHoverCell.setBounds(mHoverCellCurrentBounds); invalidate(); handleCellSwitch(); mIsMobileScrolling = false; handleMobileCellScroll(); return false; } break; case MotionEvent.ACTION_UP: touchEventsEnded(); drawLayoutSetUnlock(); break; case MotionEvent.ACTION_CANCEL: touchEventsCancelled(); break; case MotionEvent.ACTION_POINTER_UP: /* If a multitouch event took place and the original touch dictating * the movement of the hover cell has ended, then the dragging event * ends and the hover cell is animated to its corresponding position * in the listview. */ pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; final int pointerId = event.getPointerId(pointerIndex); if (pointerId == mActivePointerId) { touchEventsEnded(); } drawLayoutSetUnlock(); break; default: break; } return super.onTouchEvent(event); }
From source file:org.que.activities.fragments.MapImageFragment.java
/** * The onTouch method which will be called if an onTouch event appears. * /*w w w .j av a 2 s . c o m*/ * @param view the view which was touched * @param event the touch event * @return true if the touch event was handled, false otherwise */ public boolean onTouch(View view, MotionEvent event) { Boolean consumed; ImageView image = (ImageView) view; switch (event.getAction() & MotionEvent.ACTION_MASK) //bitwise and with mask { case MotionEvent.ACTION_DOWN: saved.set(m); p.set(event.getX(), event.getY()); mode = TOUCH_MODE.DRAG; consumed = true; break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: mode = TOUCH_MODE.NONE; consumed = true; break; case MotionEvent.ACTION_POINTER_DOWN: saved.set(m); mode = TOUCH_MODE.ZOOM; oldDis = euclideanDistance(event); p = calcMidPoint(p, event); consumed = true; break; case MotionEvent.ACTION_MOVE: if (mode == TOUCH_MODE.ZOOM) { m.set(saved); newDis = euclideanDistance(event); scale = newDis / oldDis; m.postScale(scale, scale, p.x, p.y); float[] values = new float[9]; m.getValues(values); float mscale = values[Matrix.MSCALE_X]; if (mscale < MIN_ZOOM) { m.setScale(MIN_ZOOM, MIN_ZOOM, p.x, p.y); } else if (mscale > MAX_ZOOM) { m.setScale(MAX_ZOOM, MAX_ZOOM, p.x, p.y); } } else if (mode == TOUCH_MODE.DRAG) { m.set(saved); m.postTranslate(event.getX() - p.x, event.getY() - p.y); } consumed = true; break; default: consumed = false; } image.setImageMatrix(m); return consumed; }
From source file:ucsc.hci.rankit.DynamicListView.java
@Override public boolean onTouchEvent(MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: mDownX = (int) event.getX(); mDownY = (int) event.getY(); mActivePointerId = event.getPointerId(0); // This part has been copied from OnItemLongClickListener code above (which has now // been commented out). mTotalOffset = 0;//from w w w .j ava 2 s . c o m int position = pointToPosition(mDownX, mDownY); int itemNum = position - getFirstVisiblePosition(); View selectedView = getChildAt(itemNum); mMobileItemId = getAdapter().getItemId(position); mHoverCell = getAndAddHoverView(selectedView); selectedView.setVisibility(INVISIBLE); mCellIsMobile = true; updateNeighborViewsForID(mMobileItemId); // End of copy-paste from OnItemLongClickListener break; case MotionEvent.ACTION_MOVE: if (mActivePointerId == INVALID_POINTER_ID) { break; } int pointerIndex = event.findPointerIndex(mActivePointerId); mLastEventY = (int) event.getY(pointerIndex); int deltaY = mLastEventY - mDownY; if (mCellIsMobile) { mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mHoverCellOriginalBounds.top + deltaY + mTotalOffset); try { mHoverCell.setBounds(mHoverCellCurrentBounds); } catch (Exception e) { e.printStackTrace(); } invalidate(); handleCellSwitch(); mIsMobileScrolling = false; handleMobileCellScroll(); return false; } break; case MotionEvent.ACTION_UP: touchEventsEnded(); break; case MotionEvent.ACTION_CANCEL: touchEventsCancelled(); break; case MotionEvent.ACTION_POINTER_UP: /* If a multitouch event took place and the original touch dictating * the movement of the hover cell has ended, then the dragging event * ends and the hover cell is animated to its corresponding position * in the listview. */ pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; final int pointerId = event.getPointerId(pointerIndex); if (pointerId == mActivePointerId) { touchEventsEnded(); } break; default: break; } return super.onTouchEvent(event); }
From source file:com.spatialnetworks.fulcrum.widget.DynamicListView.java
@Override public boolean onTouchEvent(@NonNull MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: mDownX = (int) event.getX(); mDownY = (int) event.getY(); mActivePointerId = event.getPointerId(0); /*//w w w .ja v a2 s.co m * get the touch position. if it's valid and drag and drop is enabled, then get the view * and determine if the touch was on the drag and drop view. if so, set up for dragging */ int position = pointToPosition((int) event.getX(), (int) event.getY()); if (position != INVALID_POSITION && mDragAndDropEnabled) { View downView = getChildAt(position - getFirstVisiblePosition()); assert downView != null; if (onDraggable(downView, event.getX() - downView.getX(), event.getY() - downView.getY())) { setUpDrag(); } } break; case MotionEvent.ACTION_MOVE: if (mActivePointerId == INVALID_POINTER_ID) { break; } int pointerIndex = event.findPointerIndex(mActivePointerId); mLastEventY = (int) event.getY(pointerIndex); int deltaY = mLastEventY - mDownY; if (mCellIsMobile) { mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mHoverCellOriginalBounds.top + deltaY + mTotalOffset); mHoverCell.setBounds(mHoverCellCurrentBounds); invalidate(); handleCellSwitch(); mIsMobileScrolling = false; handleMobileCellScroll(); return false; } break; case MotionEvent.ACTION_UP: touchEventsEnded(); break; case MotionEvent.ACTION_CANCEL: touchEventsCancelled(); break; case MotionEvent.ACTION_POINTER_UP: /* If a multitouch event took place and the original touch dictating * the movement of the hover cell has ended, then the dragging event * ends and the hover cell is animated to its corresponding position * in the listview. */ pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; final int pointerId = event.getPointerId(pointerIndex); if (pointerId == mActivePointerId) { touchEventsEnded(); } break; default: break; } return super.onTouchEvent(event); }
From source file:jp.ac.anan_nct.TabletInterphone.Fragment.VisiterInteractionFragment.java
@Override protected void onCreate(View view) { businessTextView = (TextView) view.findViewById(R.id.interactionTextView); //changePackman(view); changeSpeaker(view);//w w w .ja va 2s . c om changeCamera(view, sharedVariable.interval); cameraLayout = view.findViewById(R.id.cameraLayout); loadBusiness(); view.findViewById(R.id.waitLayout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { sharedVariable.wifiSocket.writeObject(Const.INTERACTION_WAIT); //7/20 sharedVariable.writeReaction("???"); // Log.d("Vis", String.valueOf(sharedVariable.wifiSocket.readObject())); AfterInteractionFragment fragment = new AfterInteractionFragment(); Bundle args = new Bundle(); args.putString("Interaction", "????"); fragment.setArguments(args); changeLeftFragment(fragment); } }); view.findViewById(R.id.getOutLayout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { sharedVariable.wifiSocket.writeObject(Const.INTERACTION_GET_OUT); //7/20 sharedVariable.writeReaction("???"); // AfterInteractionFragment fragment = new AfterInteractionFragment(); Bundle args = new Bundle(); args.putString("Interaction", "?????????"); fragment.setArguments(args); changeLeftFragment(fragment); } }); view.findViewById(R.id.moreLayout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { sharedVariable.wifiSocket.writeObject(Const.INTERACTION_MORE); AfterInteractionFragment fragment = new AfterInteractionFragment(); //7/20 sharedVariable.writeReaction("?"); // Bundle args = new Bundle(); args.putString("Interaction", "???????" + "\n\n?"); fragment.setArguments(args); changeLeftFragment(fragment); } }); cameraLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!isMikeTouch && License) { License = false; switch (cameraStatus) { case -1: sharedVariable.wifiSocket.writeObject(Const.INTERACTION_CAMERA_IDLE); changeCamera(view, 1); //sharedVariable.interval = 1; break; case 1: sharedVariable.wifiSocket.writeObject(Const.INTERACTION_CAMERA_ON); changeCamera(view, 0); //sharedVariable.interval = 0; break; case 0: sharedVariable.wifiSocket.writeObject(Const.INTERACTION_CAMERA_OFF); changeCamera(view, -1); //sharedVariable.interval = -1; break; default: Log.d("ellor", "ellor" + cameraStatus); break; } License = true; } } }); view.findViewById(R.id.shutDownLayout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { sharedVariable.wifiSocket.writeObject(Const.INTERACTION_STOP); sharedVariable.service.stopService(666); } }); view.findViewById(R.id.shutDownLayout).setVisibility(view.INVISIBLE); //8/31 view.findViewById(R.id.nameCheckLayout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { sharedVariable.visiterCheckActivity.setImage(sharedVariable.getWserial()); } catch (NullPointerException e) { } } }); view.findViewById(R.id.nameLayout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { sharedVariable.wifiSocket.writeObject(Const.INTERACTION_SHOW_NAME); sharedVariable.writeReaction("??"); AfterInteractionFragment fragment = new AfterInteractionFragment(); Bundle args = new Bundle(); args.putString("Interaction", "???????????"); fragment.setArguments(args); changeLeftFragment(fragment); } }); view.findViewById(R.id.finishLayout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { sharedVariable.wifiSocket.writeObject(Const.INTERACTION_FINISH); //AfterInteractionFragment fragment = new AfterInteractionFragment(); //Bundle args = new Bundle(); //args.putString("Interaction", "????????"); //fragment.setArguments(args); //changeLeftFragment(fragment); changeCamera(cameraLayout, 1); //sharedVariable.interval = -1; } }); view.findViewById(R.id.LightLayout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { sharedVariable.wifiSocket.writeObject(Const.INTERACTION_LIGHT_ON); } }); /* view.findViewById(R.id.voiceChatLayout).setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view){ //sharedVariable.wifiSocket.writeObject(Const.INTERACTION_PHONE_CALL); //sharedVariable.service.startTrackAndRecord(); changeLeftFragment(new VoiceChatFragment()); //changeLeftFragment(new PhoneCallFragment()); } }); */ view.findViewById(R.id.speakerLayout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!isMikeTouch && License) { License = false; switch (sharedVariable.phoneCallStatus(0)) { case Const.INTERACTION_PHONE_CALL_END: try { sharedVariable.service.endTrackAndRecord(); sharedVariable.wifiSocket.writeObject(Const.VOICE_CHAT_SPEAK_ONLY); sharedVariable.service.startTrackAndRecord(Const.VOICE_CHAT_LISTEN_ONLY); sharedVariable.phoneCallStatus(Const.VOICE_CHAT_LISTEN_ONLY); changeSpeaker(view); } catch (Exception e) { } break; case Const.VOICE_CHAT_LISTEN_ONLY: try { sharedVariable.phoneCallStatus(Const.INTERACTION_PHONE_CALL_END); sharedVariable.wifiSocket.writeObject(Const.INTERACTION_PHONE_CALL_END); sharedVariable.service.endTrackAndRecord(); sharedVariable.phoneCallStatus(Const.INTERACTION_PHONE_CALL_END); changeSpeaker(view); } catch (Exception e) { } break; default: break; } License = true; } } }); view.findViewById(R.id.mikeLayout).setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (License) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: isMikeTouch = true; try { sharedVariable.service.endTrackAndRecord(); if (isSpeakerClick) { sharedVariable.wifiSocket.writeObject(Const.VOICE_CHAT_DUAL); sharedVariable.service.startTrackAndRecord(Const.VOICE_CHAT_DUAL); } else { sharedVariable.wifiSocket.writeObject(Const.VOICE_CHAT_LISTEN_ONLY); sharedVariable.service.startTrackAndRecord(Const.VOICE_CHAT_SPEAK_ONLY); } } catch (Exception e) { Log.d("ontouch", "ontouch03"); } changeMike(view, true); break; case MotionEvent.ACTION_UP: try { if (isSpeakerClick) { sharedVariable.service.endTrackAndRecord(); sharedVariable.wifiSocket.writeObject(Const.VOICE_CHAT_SPEAK_ONLY); sharedVariable.service.startTrackAndRecord(Const.VOICE_CHAT_LISTEN_ONLY); } else { sharedVariable.wifiSocket.writeObject(Const.INTERACTION_PHONE_CALL_END); sharedVariable.service.endTrackAndRecord(); } } catch (Exception e) { Log.d("ontouch", "ontouch04"); } isMikeTouch = false; changeMike(view, false); break; default: break; } } return true; } }); view.findViewById(R.id.writeLayout).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { changeLeftFragment(new WriteFragment()); } }); IntentFilter filter = new IntentFilter(Const.INSIDE_CAMERA_CHANGE); LocalBroadcastManager.getInstance(sharedVariable.currentTIActivity).registerReceiver(receiver, filter); }
From source file:com.yanzhenjie.durban.view.OverlayView.java
@Override public boolean onTouchEvent(MotionEvent event) { if (mCropViewRect.isEmpty() || mFreestyleCropMode == FREESTYLE_CROP_MODE_DISABLE) { return false; }//from w ww . j a va 2 s.co m float x = event.getX(); float y = event.getY(); if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) { mCurrentTouchCornerIndex = getCurrentTouchIndex(x, y); boolean shouldHandle = mCurrentTouchCornerIndex != -1; if (!shouldHandle) { mPreviousTouchX = -1; mPreviousTouchY = -1; } else if (mPreviousTouchX < 0) { mPreviousTouchX = x; mPreviousTouchY = y; } return shouldHandle; } if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_MOVE) { if (event.getPointerCount() == 1 && mCurrentTouchCornerIndex != -1) { x = Math.min(Math.max(x, getPaddingLeft()), getWidth() - getPaddingRight()); y = Math.min(Math.max(y, getPaddingTop()), getHeight() - getPaddingBottom()); updateCropViewRect(x, y); mPreviousTouchX = x; mPreviousTouchY = y; return true; } } if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) { mPreviousTouchX = -1; mPreviousTouchY = -1; mCurrentTouchCornerIndex = -1; if (mCallback != null) { mCallback.onCropRectUpdated(mCropViewRect); } } return false; }