List of usage examples for android.view MotionEvent getAction
public final int getAction()
From source file:com.df.kia.procedures.CarRecogniseLayout.java
private void init(final Context context) { rootView = LayoutInflater.from(context).inflate(R.layout.car_recognise_layout, this); deleteLastLicensePhoto();//from w ww .j av a 2 s. c om mCarSettings = InputProceduresLayout.mCarSettings; licenseRecognise = new LicenseRecognise(context, AppCommon.licensePhotoPath); licenseImageView = (ImageView) findViewById(R.id.licenseImage); licenseImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { licenseRecognise.takePhoto(mHandler); } }); // recogniseButton = (Button) rootView.findViewById(R.id.recognise_button); recogniseButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { // ??? if (!mCarSettings.getBrandString().equals("")) { reRecognise(R.string.reRecognise1); } else if (!getEditViewText(rootView, R.id.plateNumber_edit).equals("")) { reRecognise(R.string.reRecognise); } else { //fillInDummyData(); if (licensePhotoExist()) recogniseLicense(); else Toast.makeText(context, "???", Toast.LENGTH_SHORT).show(); } } }); // vin Button vinConfirmButton = (Button) rootView.findViewById(R.id.vinConfirm_button); vinConfirmButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { // VIN?? if (getEditViewText(rootView, R.id.vin_edit).equals("")) { Toast.makeText(rootView.getContext(), "VIN?", Toast.LENGTH_SHORT).show(); } else { checkVinAndGetCarSettings(); } } }); // ? Button brandSelectButton = (Button) rootView.findViewById(R.id.brand_select_button); brandSelectButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { selectCarManually(); } }); vehicleTypeEdit = (EditText) rootView.findViewById(R.id.vehicleType_edit); vehicleTypeEdit.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case MotionEvent.ACTION_UP: choose(R.array.vehicleType_items, R.id.vehicleType_edit); break; } return false; } }); useCharacterEdit = (EditText) rootView.findViewById(R.id.useCharacter_edit); useCharacterEdit.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case MotionEvent.ACTION_UP: choose(R.array.useCharacter_items, R.id.useCharacter_edit); break; } return false; } }); // vin??? InputFilter alphaNumericFilter = new InputFilter() { @Override public CharSequence filter(CharSequence arg0, int arg1, int arg2, Spanned arg3, int arg4, int arg5) { for (int k = arg1; k < arg2; k++) { if (!Character.isLetterOrDigit(arg0.charAt(k))) { return ""; } } return null; } }; EditText vin_edit = (EditText) findViewById(R.id.vin_edit); vin_edit.setFilters(new InputFilter[] { alphaNumericFilter, new InputFilter.AllCaps(), new InputFilter.LengthFilter(17) }); EditText plateNumberEdit = (EditText) findViewById(R.id.plateNumber_edit); plateNumberEdit .setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(10) }); EditText licenseModelEdit = (EditText) findViewById(R.id.licenseModel_edit); licenseModelEdit .setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(22) }); EditText engineSerialEdit = (EditText) findViewById(R.id.engineSerial_edit); engineSerialEdit .setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(17) }); vehicleModel = MainActivity.vehicleModel; }
From source file:com.android.launcher3.folder.FolderIcon.java
@Override public boolean onTouchEvent(MotionEvent event) { // Call the superclass onTouchEvent first, because sometimes it changes the state to // isPressed() on an ACTION_UP boolean result = super.onTouchEvent(event); // Check for a stylus button press, if it occurs cancel any long press checks. if (mStylusEventHelper.onMotionEvent(event)) { mLongPressHelper.cancelLongPress(); return true; }//w w w . ja v a 2 s . c om switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mLongPressHelper.postCheckForLongPress(); break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: mLongPressHelper.cancelLongPress(); break; case MotionEvent.ACTION_MOVE: if (!Utilities.pointInView(this, event.getX(), event.getY(), mSlop)) { mLongPressHelper.cancelLongPress(); } break; } return result; }
From source file:cn.com.zzwfang.view.directionalviewpager.DirectionalViewPager.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { /*/*from ww w .j av a2 s . co m*/ * This method JUST determines whether we want to intercept the motion. * If we return true, onMotionEvent will be called and we do the actual * scrolling there. */ final int action = ev.getAction() & MotionEventCompat.ACTION_MASK; // Always take care of the touch gesture being complete. if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) { // Release the drag. if (DEBUG) Log.v(TAG, "Intercept done!"); mIsBeingDragged = false; mIsUnableToDrag = false; mActivePointerId = INVALID_POINTER; return false; } // Nothing more to do here if we have decided whether or not we // are dragging. if (action != MotionEvent.ACTION_DOWN) { if (mIsBeingDragged) { if (DEBUG) Log.v(TAG, "Intercept returning true!"); return true; } if (mIsUnableToDrag) { if (DEBUG) Log.v(TAG, "Intercept returning false!"); return false; } } switch (action) { case MotionEvent.ACTION_MOVE: { /* * mIsBeingDragged == false, otherwise the shortcut would have caught it. Check * whether the user has moved far enough from his original down touch. */ /* * Locally do absolute value. mLastMotionY is set to the y value * of the down event. */ final int activePointerId = mActivePointerId; if (activePointerId == INVALID_POINTER && Build.VERSION.SDK_INT > Build.VERSION_CODES.DONUT) { // If we don't have a valid id, the touch down wasn't on content. break; } final int pointerIndex = MotionEventCompat.findPointerIndex(ev, activePointerId); final float x = MotionEventCompat.getX(ev, pointerIndex); final float y = MotionEventCompat.getY(ev, pointerIndex); final float xDiff = Math.abs(x - mLastMotionX); final float yDiff = Math.abs(y - mLastMotionY); float primaryDiff; float secondaryDiff; if (mOrientation == HORIZONTAL) { primaryDiff = xDiff; secondaryDiff = yDiff; } else { primaryDiff = yDiff; secondaryDiff = xDiff; } if (DEBUG) Log.v(TAG, "Moved x to " + x + "," + y + " diff=" + xDiff + "," + yDiff); if (primaryDiff > mTouchSlop && primaryDiff > secondaryDiff) { if (DEBUG) Log.v(TAG, "Starting drag!"); mIsBeingDragged = true; setScrollState(SCROLL_STATE_DRAGGING); if (mOrientation == HORIZONTAL) { mLastMotionX = x; } else { mLastMotionY = y; } setScrollingCacheEnabled(true); } else { if (secondaryDiff > mTouchSlop) { // The finger has moved enough in the vertical // direction to be counted as a drag... abort // any attempt to drag horizontally, to work correctly // with children that have scrolling containers. if (DEBUG) Log.v(TAG, "Starting unable to drag!"); mIsUnableToDrag = true; } } break; } case MotionEvent.ACTION_DOWN: { /* * Remember location of down touch. * ACTION_DOWN always refers to pointer index 0. */ if (mOrientation == HORIZONTAL) { mLastMotionX = mInitialMotion = ev.getX(); mLastMotionY = ev.getY(); } else { mLastMotionX = ev.getX(); mLastMotionY = mInitialMotion = ev.getY(); } mActivePointerId = MotionEventCompat.getPointerId(ev, 0); if (mScrollState == SCROLL_STATE_SETTLING) { // Let the user 'catch' the pager as it animates. mIsBeingDragged = true; mIsUnableToDrag = false; setScrollState(SCROLL_STATE_DRAGGING); } else { completeScroll(); mIsBeingDragged = false; mIsUnableToDrag = false; } if (DEBUG) Log.v(TAG, "Down at " + mLastMotionX + "," + mLastMotionY + " mIsBeingDragged=" + mIsBeingDragged + "mIsUnableToDrag=" + mIsUnableToDrag); break; } case MotionEventCompat.ACTION_POINTER_UP: onSecondaryPointerUp(ev); break; } /* * The only time we want to intercept motion events is if we are in the * drag mode. */ return mIsBeingDragged; }
From source file:com.androzic.MapFragment.java
@SuppressLint("ClickableViewAccessibility") @Override/* w w w.ja va 2 s .co m*/ public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: zoom100X = (int) event.getRawX(); zoom100Y = (int) event.getRawY(); zoomHandler.postDelayed(new Runnable() { @Override public void run() { zoom100X = 0; zoom100Y = 0; } }, 2000); break; case MotionEvent.ACTION_UP: int dx = Math.abs((int) event.getRawX() - zoom100X); int dy = (int) event.getRawY() - zoom100Y; int h = v.getHeight(); int w = v.getWidth() >> 1; if (dy > h * 0.8 && dy < h * 2 && dx < w) { wait(new Waitable() { @Override public void waitFor() { synchronized (map) { if (application.setZoom(1.)) { map.updateMapInfo(); map.updateMapCenter(); } } } }); zoom100X = 0; zoom100Y = 0; } break; } return false; }
From source file:com.df.app.procedures.CarRecogniseLayout.java
private void init(final Context context) { rootView = LayoutInflater.from(context).inflate(R.layout.car_recognise_layout, this); deleteLastLicensePhoto();/*from w w w .j a v a 2 s . co m*/ mCarSettings = CarSettings.getInstance(); licenseRecognise = new LicenseRecognise(context, AppCommon.licensePhotoPath); licenseImageView = (ImageView) findViewById(R.id.licenseImage); licenseImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { licenseRecognise.takePhoto(); } }); // recogniseButton = (Button) rootView.findViewById(R.id.recognise_button); recogniseButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { // ??? if (!mCarSettings.getBrandString().equals("")) { reRecognise(R.string.reRecognise1); } else if (!getEditViewText(rootView, R.id.plateNumber_edit).equals("")) { reRecognise(R.string.reRecognise); } else { //fillInDummyData(); if (licensePhotoExist()) recogniseLicense(); else Toast.makeText(context, "???", Toast.LENGTH_SHORT).show(); } } }); // vin Button vinConfirmButton = (Button) rootView.findViewById(R.id.vinConfirm_button); vinConfirmButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { // VIN?? if (getEditViewText(rootView, R.id.vin_edit).equals("")) { Toast.makeText(rootView.getContext(), "VIN?", Toast.LENGTH_SHORT).show(); } else { checkVinAndGetCarSettings(); } } }); // ? Button brandSelectButton = (Button) rootView.findViewById(R.id.brand_select_button); brandSelectButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { selectCarManually(); } }); vehicleTypeEdit = (EditText) rootView.findViewById(R.id.vehicleType_edit); vehicleTypeEdit.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case MotionEvent.ACTION_UP: choose(R.array.vehicleType_items, R.id.vehicleType_edit); break; } return false; } }); useCharacterEdit = (EditText) rootView.findViewById(R.id.useCharacter_edit); useCharacterEdit.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case MotionEvent.ACTION_UP: choose(R.array.useCharacter_items, R.id.useCharacter_edit); break; } return false; } }); // vin??? InputFilter alphaNumericFilter = new InputFilter() { @Override public CharSequence filter(CharSequence arg0, int arg1, int arg2, Spanned arg3, int arg4, int arg5) { for (int k = arg1; k < arg2; k++) { if (!Character.isLetterOrDigit(arg0.charAt(k))) { return ""; } } return null; } }; EditText vin_edit = (EditText) findViewById(R.id.vin_edit); vin_edit.setFilters(new InputFilter[] { alphaNumericFilter, new InputFilter.AllCaps(), new InputFilter.LengthFilter(17) }); EditText plateNumberEdit = (EditText) findViewById(R.id.plateNumber_edit); plateNumberEdit .setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(10) }); EditText licenseModelEdit = (EditText) findViewById(R.id.licenseModel_edit); licenseModelEdit .setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(22) }); EditText engineSerialEdit = (EditText) findViewById(R.id.engineSerial_edit); engineSerialEdit .setFilters(new InputFilter[] { new InputFilter.AllCaps(), new InputFilter.LengthFilter(17) }); vehicleModel = MainActivity.vehicleModel; }
From source file:app.clirnet.com.clirnetapp.activity.LoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fabric.with(this, new Crashlytics()); setContentView(R.layout.activity_login); ButterKnife.inject(this); try {// www . j a v a 2 s . c o m /*message from fcm service*/ msg = getIntent().getStringExtra("MSG"); type = getIntent().getStringExtra("TYPE"); actionPath = getIntent().getStringExtra("ACTION_PATH"); headerMsg = getIntent().getStringExtra("HEADER"); clubbingFlag = getIntent().getStringExtra("CLUBBINGFLAG"); notificationTreySize = getIntent().getIntExtra("NOTIFITREYSIZE", 0); // Log.e("Loginmsg", " " + msg + " header " + headerMsg + " " +type + " "+actionPath); /*Clearing notifications ArrayList from MyFirebaseMessagingService after clicking on it*/ MyFirebaseMessagingService.notifications.clear(); // FirebaseCrash.setCrashCollectionEnabled(false); } catch (Exception e) { appController.appendLog(appController.getDateTime() + "" + "/" + "Navigation Activity" + e + " Line Number: " + Thread.currentThread().getStackTrace()[2].getLineNumber()); } TextView btnLinkToForgetScreen = (TextView) findViewById(R.id.btnLinkToForgetScreen); DatabaseClass databaseClass = new DatabaseClass(getApplicationContext()); bannerClass = new BannerClass(getApplicationContext()); LastnameDatabaseClass lastnameDatabaseClass = new LastnameDatabaseClass(getApplicationContext()); dbController = SQLiteHandler.getInstance(getApplicationContext()); appController = new AppController(); if (md5 == null) { md5 = new MD5(); } //getCurrentDob(21); //getCurrentDob(10); //this will set value to run asynctask only once per login session new CallAsynOnce().setValue("1");//this set value which helps to call asyntask only once while app is running. // Progress dialog connectionDetector = new ConnectionDetector(getApplicationContext()); try { sInstance = SQLiteHandler.getInstance(getApplicationContext()); if (sqlController == null) { sqlController = new SQLController(getApplicationContext()); sqlController.open(); } // sInstance = SQLiteHandler.getInstance(getApplicationContext()); Boolean value = getFirstTimeLoginStatus(); if (value) { phoneNumber = sqlController.getPhoneNumber(); doctor_membership_number = sqlController.getDoctorMembershipIdNew(); docId = sqlController.getDoctorId(); } } catch (Exception e) { e.printStackTrace(); appController.appendLog(appController.getDateTimenew() + " " + "/ " + "Login Page" + e + " Line Number: " + Thread.currentThread().getStackTrace()[2].getLineNumber()); } try { databaseClass.createDataBase(); bannerClass.createDataBase(); } catch (Exception ioe) { appController.appendLog(appController.getDateTimenew() + "" + "/" + "Login Page" + ioe + " Line Number: " + Thread.currentThread().getStackTrace()[2].getLineNumber()); throw new Error("Unable to create database"); } try { databaseClass.openDataBase(); bannerClass.openDataBase(); /*This AsyncTask will Insert data from Asset folder file to data 23-03-2016*/ new InsertDataLocally().execute(); } catch (Exception e) { e.printStackTrace(); appController.appendLog(appController.getDateTimenew() + "" + "/" + "Login Page" + e + " Line Number: " + Thread.currentThread().getStackTrace()[2].getLineNumber()); } finally { databaseClass.close(); } try { lastnameDatabaseClass.createDataBase(); } catch (IOException e) { appController.appendLog(appController.getDateTimenew() + "" + "/" + "Login Page" + e + " Line Number: " + Thread.currentThread().getStackTrace()[2].getLineNumber()); throw new Error("Unable to create database"); } try { lastnameDatabaseClass.openDataBase(); getUsernamePasswordFromDatabase(); } catch (Exception e) { e.printStackTrace(); appController.appendLog(appController.getDateTimenew() + "" + "/" + "Login Page" + e + " Line Number: " + Thread.currentThread().getStackTrace()[2].getLineNumber()); } finally { lastnameDatabaseClass.close(); } btnLogin.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { hideKeyBoard(); btnLogin.setBackground(getResources().getDrawable(R.drawable.rounded_corner_withbackground)); name = inputEmail.getText().toString().trim(); strPassword = inputPassword.getText().toString().trim(); String time = appController.getDateTimenew(); AppController.getInstance().trackEvent("Login", "Login Pressed"); //This code used for Remember Me(ie. save login id and password for future ref.) rememberMe(name, strPassword, time); //save username only //rememberMeCheckbox();//Removed remeber me check box for safety concern 04-11-16 //to authenticate user credentials //Log.e("name",""+name +" savedUserName "+savedUserName+ " phoneNumber "+phoneNumber); //if(name.equals(savedUserName) || name.equals(phoneNumber)) LoginAuthentication(); // else appController.showToastMsg(getApplicationContext(),"This username is not licensed to log into this device. Please check username"); } else if (event.getAction() == MotionEvent.ACTION_DOWN) { btnLogin.setBackground( getResources().getDrawable(R.drawable.rounded_corner_withbackground_blue)); } return false; } }); /*We are updating visit date format*/ // updateVisitDateFormat(); //Commented on 10-05-2017 addVitalsIntoInvstigation(); //Commented on 10-05-2017 /* Updateing banner stats flag to 0 build no 1.3+ */ /*Updating associate master flag from 1 to 0*/ String bannerUpdateFlag = getupdateBannerClickVisitFlag0(); if (bannerUpdateFlag == null || bannerUpdateFlag.equals("true")) { updateBannerTableDataFlag(); } // Link to Register Screen btnLinkToForgetScreen.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { boolean isInternetPresent = connectionDetector.isConnectingToInternet(); if (isInternetPresent) { showChangePassDialog(); } else { appController.showToastMsg(getApplicationContext(), "Please Connect To Internet And Try Again!"); } } }); if (checkAndRequestPermissions()) { // carry on the normal flow, as the case of permissions granted. } }
From source file:com.albedinsky.android.ui.widget.ViewPagerWidget.java
/** *///from ww w. j a v a 2 s . c o m @Override public boolean onTouchEvent(@NonNull MotionEvent event) { this.ensureDecorator(); if (!mDecorator.hasPrivateFlag(PFLAG_PAGE_SWIPING_ENABLED)) { return false; } if (mDecorator.onTouchEvent(event)) { this.requestParentDisallowInterceptTouchEvent(true); return true; } if (mDecorator.hasPrivateFlag(PFLAG_PAGE_FLING_SWIPING_ENABLED)) { this.ensureVelocityTracker(); mVelocityTracker.addMovement(event); switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mVelocityTracker.computeCurrentVelocity(UiConfig.VELOCITY_UNITS); final float xVelocity = mVelocityTracker.getXVelocity(); if (Math.abs(xVelocity) > mPageFlingSwipingSensitivity) { super.onTouchEvent(event); this.handleFling(xVelocity); return true; } } } return super.onTouchEvent(event); }
From source file:com.android.dialer.widget.OverlappingPaneLayout.java
@Override public boolean onTouchEvent(MotionEvent ev) { if (!mCanSlide) { return super.onTouchEvent(ev); }/*from w w w .ja va 2s .co m*/ mDragHelper.processTouchEvent(ev); final int action = ev.getAction(); boolean wantTouchEvents = true; switch (action & MotionEventCompat.ACTION_MASK) { case MotionEvent.ACTION_DOWN: { final float x = ev.getX(); final float y = ev.getY(); mInitialMotionX = x; mInitialMotionY = y; break; } } return wantTouchEvents; }
From source file:android.car.ui.provider.CarDrawerLayout.java
@Override public boolean dispatchGenericMotionEvent(MotionEvent ev) { final View drawerView = findDrawerView(); if (drawerView != null && ev.getAction() == MotionEvent.ACTION_SCROLL && mDrawerControllerListener != null && mDrawerControllerListener.onScroll()) { return true; }/*from w ww . j a va 2 s .c o m*/ return super.dispatchGenericMotionEvent(ev); }
From source file:com.base.view.slidemenu.SlideMenu.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { final float x = ev.getX(); final float y = ev.getY(); final int currentState = mCurrentState; if (STATE_DRAG == currentState || STATE_SCROLL == currentState) { return true; }/*from w w w . ja va 2 s .c o m*/ switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: mPressedX = mLastMotionX = x; mPressedY = y; mIsTapInContent = isTapInContent(x, y); mIsTapInEdgeSlide = isTapInEdgeSlide(x, y); return isOpen() && mIsTapInContent; case MotionEvent.ACTION_MOVE: float dx = x - mPressedX; float dy = y - mPressedY; if (mIsEdgeSlideEnable && !mIsTapInEdgeSlide && mCurrentState == STATE_CLOSE) { return false; } // Detect the vertical scroll if (Math.abs(dy) >= mTouchSlop && mIsTapInContent && canScrollVertically(this, (int) dy, (int) x, (int) y)) { // if the child can response the vertical scroll, we will not to // steal the MotionEvent any more requestDisallowInterceptTouchEvent(true); return false; } if (Math.abs(dx) >= mTouchSlop && mIsTapInContent) { if (!canScrollHorizontally(this, (int) dx, (int) x, (int) y)) { setCurrentState(STATE_DRAG); return true; } } } return false; }