List of usage examples for android.view MotionEvent getAction
public final int getAction()
From source file:cn.iotguard.GalleryWidget.GalleryViewPager.java
@Override public boolean onInterceptTouchEvent(MotionEvent event) { if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) { super.onInterceptTouchEvent(event); }// w w w .j a va 2s .c om float[] difference = handleMotionEvent(event); if (mCurrentView.pagerCanScroll()) { return super.onInterceptTouchEvent(event); } else { if (difference != null && mCurrentView.onRightSide && difference[0] < 0) //move right { return super.onInterceptTouchEvent(event); } if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) //move left { return super.onInterceptTouchEvent(event); } if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) { return super.onInterceptTouchEvent(event); } } return false; }
From source file:cn.iotguard.GalleryWidget.GalleryViewPager.java
@Override public boolean onTouchEvent(MotionEvent event) { if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) { super.onTouchEvent(event); }//w ww . ja v a 2 s. c o m float[] difference = handleMotionEvent(event); if (mCurrentView.pagerCanScroll()) { return super.onTouchEvent(event); } else { if (difference != null && mCurrentView.onRightSide && difference[0] < 0) //move right { return super.onTouchEvent(event); } if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) //move left { return super.onTouchEvent(event); } if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) { return super.onTouchEvent(event); } } return false; }
From source file:cn.iotguard.GalleryWidget.GalleryViewPager.java
private float[] handleMotionEvent(MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: last = new PointF(event.getX(0), event.getY(0)); ///*from www .j av a 2 s . co m*/ if (GalleryFileActivity.ll_dibumenu != null && GalleryFileActivity.ll_dibumenu.getVisibility() == View.GONE) { GalleryFileActivity.ll_dibumenu.setVisibility(View.VISIBLE); } if (Show_bigpic2.ll_dibumenu != null && Show_bigpic2.ll_dibumenu.getVisibility() == View.GONE) { Show_bigpic2.ll_dibumenu.setVisibility(View.VISIBLE); } // if (GalleryFileActivity.timeCount != null) { GalleryFileActivity.timeCount.cancel(); } GalleryFileActivity.timeCount = new TimeCount_pic_dibu(Millis.pic_dibus, 1000); GalleryFileActivity.timeCount.start(); System.out.println("pic "); if (Show_bigpic2.timeCount != null) { Show_bigpic2.timeCount.cancel(); } Show_bigpic2.timeCount = new TimeCount_pic_dibu_showbigpic2(Millis.pic_dibus, 1000); Show_bigpic2.timeCount.start(); break; case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_UP: PointF curr = new PointF(event.getX(0), event.getY(0)); return new float[] { curr.x - last.x, curr.y - last.y }; } return null; }
From source file:com.android.cts.uiautomator.TestGenericDetailFragment.java
private int getPointerIndex(MotionEvent event) { return ((event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT); }
From source file:android.support.v13.view.DragStartHelper.java
/** * Handle a touch event./* w w w. ja v a 2s .c om*/ * @param v The view the touch event has been dispatched to. * @param event The MotionEvent object containing full information about * the event. * @return True if the listener has consumed the event, false otherwise. */ public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) { mLastTouchX = (int) event.getX(); mLastTouchY = (int) event.getY(); } if (event.getAction() == MotionEvent.ACTION_MOVE && MotionEventCompat.isFromSource(event, InputDeviceCompat.SOURCE_MOUSE) && (MotionEventCompat.getButtonState(event) & MotionEventCompat.BUTTON_PRIMARY) != 0) { return mListener.onDragStart(v, this); } return false; }
From source file:cn.dreamtobe.touchgallery.GalleryWidget.GalleryViewPager.java
@TargetApi(Build.VERSION_CODES.ECLAIR) private float[] handleMotionEvent(MotionEvent event) { switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: last = new PointF(event.getX(0), event.getY(0)); break;// w w w . ja v a2 s. c om case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_UP: PointF curr = new PointF(event.getX(0), event.getY(0)); return new float[] { curr.x - last.x, curr.y - last.y }; } return null; }
From source file:ca.uqac.florentinth.speakerauthentication.CreateActivity.java
private void initGUI() { view = findViewById(R.id.create_layout); usernameInput = (EditText) findViewById(R.id.username_input); passwordInput = (EditText) findViewById(R.id.password_input); visibilityImage = (ImageView) findViewById(R.id.visibility); femaleRadio = (RadioButton) findViewById(R.id.radio_female); maleRadio = (RadioButton) findViewById(R.id.radio_male); createBtn = (Button) findViewById(R.id.btn_create); usernameInput.setText("user" + StringUtils.getCurrentDateTime()); visibilityImage.setOnTouchListener(new View.OnTouchListener() { @Override//from w w w .j av a2 s.c om public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { passwordInput.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } else { if (event.getAction() == MotionEvent.ACTION_UP) { passwordInput .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } } return true; } }); createBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { submit(); } }); }
From source file:com.android.cts.uiautomator.Test5DetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { View rootView = inflater.inflate(R.layout.test5_detail_fragment, container, false); // Set the content description for the following Spinner spinner = (Spinner) rootView.findViewById(R.id.test_5_spinner); spinner.setContentDescription("Spinner"); ImageButton imageButton = (ImageButton) rootView.findViewById(R.id.test_5_imageButton); imageButton.setContentDescription("Image button"); // Each time this view is displayed, reset the following states SeekBar seekBar = (SeekBar) rootView.findViewById(R.id.test_5_seekBar); seekBar.setProgress(50);// w w w .ja va2 s . c o m seekBar.setContentDescription("Progress is 50 %"); CheckBox checkbox = (CheckBox) rootView.findViewById(R.id.test_5_checkBox); checkbox.setChecked(false); // Register click event handlers for the following Button button = (Button) rootView.findViewById(R.id.test_5_button1); button.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { // we want an artificial crash throw new RuntimeException("Artificial crash to test UiWatcher"); } }); imageButton.setOnTouchListener(new ImageButton.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { resetTouchResults(); collectStartAction(event, v); } else if (event.getAction() == MotionEvent.ACTION_UP) { collectEndAction(event, v); displayTouchResults(); } return false; } }); return rootView; }
From source file:cn.dreamtobe.touchgallery.GalleryWidget.GalleryViewPager.java
@Override public boolean onInterceptTouchEvent(MotionEvent event) { if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) { //super.onInterceptTouchEvent(event); float endX = event.getX(); float endY = event.getY(); if (isAClick(startX, endX, startY, endY)) { if (mOnItemClickListener != null) { mOnItemClickListener.onItemClicked(mCurrentView, getCurrentItem()); }/* ww w . j ava 2 s . c o m*/ } else { super.onInterceptTouchEvent(event); } } if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) { startX = event.getX(); startY = event.getY(); } float[] difference = handleMotionEvent(event); if (mCurrentView.pagerCanScroll()) { return super.onInterceptTouchEvent(event); } else { if (difference != null && mCurrentView.onRightSide && difference[0] < 0) //move right { return super.onInterceptTouchEvent(event); } if (difference != null && mCurrentView.onLeftSide && difference[0] > 0) //move left { return super.onInterceptTouchEvent(event); } if (difference == null && (mCurrentView.onLeftSide || mCurrentView.onRightSide)) { return super.onInterceptTouchEvent(event); } } return false; }
From source file:cn.nekocode.camerafilter.MainActivity.java
void setupCameraPreviewView() { renderer = new CameraRenderer(this); textureView = (TextureView) findViewById(R.id.textureView); assert textureView != null; textureView.setSurfaceTextureListener(renderer); // Show original frame when touch the view textureView.setOnTouchListener(new View.OnTouchListener() { @Override/*from w w w . j ava 2s . c om*/ public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: renderer.setSelectedFilter(R.id.filter0); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: renderer.setSelectedFilter(filterId); break; } return true; } }); textureView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { renderer.onSurfaceTextureSizeChanged(null, v.getWidth(), v.getHeight()); } }); }