List of usage examples for android.view MotionEvent ACTION_DOWN
int ACTION_DOWN
To view the source code for android.view MotionEvent ACTION_DOWN.
Click Source Link
From source file:com.ritesh.sevilla.EditDeliverAddressPhoneFields.VerifyPhoneFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.activity_edit_delivery_address, container, false); ButterKnife.bind(this, rootView); Appconstant.sh = getActivity().getSharedPreferences(Appconstant.MyPREFERENCES, Context.MODE_PRIVATE); User_ID = Appconstant.sh.getString("id", null); Log.e("User_ID from SharedPref :", "" + User_ID); /*textDotLoaderCountry = (DotLoader) rootView.findViewById(R.id.text_dot_loader_country); for (int i = 1; i < 4; i++) {/*from www. j a va 2 s.co m*/ textDotLoaderCountry.postDelayed(new DotIncrementRunnable(3 + i, textDotLoaderCountry), i * 3000); } textDotLoaderState = (DotLoader) rootView.findViewById(R.id.text_dot_loader_state); for (int i = 1; i < 4; i++) { textDotLoaderState.postDelayed(new DotIncrementRunnable(3 + i, textDotLoaderState), i * 3000); } textDotLoaderCity = (DotLoader) rootView.findViewById(R.id.text_dot_loader_city); for (int i = 1; i < 4; i++) { textDotLoaderCity.postDelayed(new DotIncrementRunnable(3 + i, textDotLoaderCity), i * 3000); }*/ if (Utils.isConnected(getActivity())) { UserGetAddressJsontask task = new UserGetAddressJsontask(); task.execute(); } else { SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP).margin(15, 15) .backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please Your Internet Connectivity..!!")); } CPB_address_progressbar_circular = (CircularProgressBar) rootView .findViewById(R.id.cpb_address_progressbar_circular); // signupProgress.setVisibility(View.GONE); ((CircularProgressDrawable) CPB_address_progressbar_circular.getIndeterminateDrawable()).start(); updateValues(); /*%%%%%%%%%%%%%% Spinner Country (Start) %%%%%%%%%%%%%%*/ /*spinner click method and not clicked method for country (Start)*/ SP_user_country.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() { @Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) { SP_user_country.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); /*Toast.makeText(getActivity(), "Position :" + " " + position + " Clicked " + "" + item, Toast.LENGTH_SHORT).show();*/ Log.e("Country Detail :", "Position :" + "" + position + "\t" + "ID :" + "" + id + "\t" + "Name :" + "" + item); /*android.support.design.widget.Snackbar.make(view, "Clicked " + item, android.support.design.widget.Snackbar.LENGTH_SHORT).show();*/ Get_user_country_SelectedValue = item; Str_get_user_country = item; Str_set_user_country = Str_get_user_country; long pos = id; int posi = position; Log.e("pos :", "" + pos); Log.e("posi ID:", "" + posi); GetSet_user_country_ID = String.valueOf(posi); Log.e("GetSet_user_country_ID :", "" + GetSet_user_country_ID); Log.e("Str_get_user_country :", "" + Str_get_user_country); Log.e("Str_set_user_country :", "" + Str_set_user_country); Log.e("Get_user_country_SelectedValue :", "" + Get_user_country_SelectedValue); if (Utils.isConnected(getActivity())) { UserStateListJsontask task = new UserStateListJsontask(); task.execute(); } else { SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please Your Internet Connectivity..!!")); } } }); SP_user_country.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() { @Override public void onNothingSelected(MaterialSpinner spinner) { /*Toast.makeText(getActivity(), "Please select Country First..!!", Toast.LENGTH_SHORT).show();*/ android.support.design.widget.Snackbar.make(spinner, "Please select Country First..!!", android.support.design.widget.Snackbar.LENGTH_SHORT).show(); } }); /*%%%%%%%%%%%%%% Spinner Country (End) %%%%%%%%%%%%%%*/ /*%%%%%%%%%%%%%% Spinner State (Start) %%%%%%%%%%%%%%*/ SP_user_state.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() { @Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) { SP_user_state.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); /*Toast.makeText(getActivity(), "Position :" + " " + position + " Clicked " + "" + item, Toast.LENGTH_SHORT).show();*/ Log.e("State Detail :", "Position :" + "" + position + "\t" + "ID :" + "" + id + "\t" + "Name :" + "" + item); /*android.support.design.widget.Snackbar.make(view, "Clicked " + item, android.support.design.widget.Snackbar.LENGTH_SHORT).show();*/ Get_user_state_SelectedValue = item; Str_get_user_state = item; Str_set_user_state = Str_get_user_state; long pos = id; int posi = position; Log.e("pos :", "" + pos); Log.e("posi ID:", "" + posi); GetSet_user_state_ID = String.valueOf(posi); Log.e("GetSet_user_state_ID :", "" + GetSet_user_state_ID); Log.e("Str_get_user_state :", "" + Str_get_user_state); Log.e("Str_set_user_state :", "" + Str_set_user_state); if (Utils.isConnected(getActivity())) { UserCityListJsontask task = new UserCityListJsontask(); task.execute(); } else { SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please Your Internet Connectivity..!!")); } } }); SP_user_state.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() { @Override public void onNothingSelected(MaterialSpinner spinner) { /*Toast.makeText(getActivity(), "Please select Country First..!!", Toast.LENGTH_SHORT).show();*/ android.support.design.widget.Snackbar.make(spinner, "Please select State First..!!", android.support.design.widget.Snackbar.LENGTH_SHORT).show(); } }); /*%%%%%%%%%%%%%% Spinner State (End) %%%%%%%%%%%%%%*/ /*%%%%%%%%%%%%%% Spinner City (Start) %%%%%%%%%%%%%%*/ SP_user_city.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() { @Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) { SP_user_city.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); /*Toast.makeText(getActivity(), "Position :" + " " + position + " Clicked " + "" + item, Toast.LENGTH_SHORT).show();*/ Log.e("City Detail :", "Position :" + "" + position + "\t" + "ID :" + "" + id + "\t" + "Name :" + "" + item); /*android.support.design.widget.Snackbar.make(view, "Clicked " + item, android.support.design.widget.Snackbar.LENGTH_SHORT).show();*/ Get_user_city_SelectedValue = item; Str_get_user_city = item; Str_set_user_city = Str_get_user_city; Log.e("Get_user_city_SelectedValue :", "" + Get_user_city_SelectedValue); Log.e("Str_get_user_city :", "" + Str_get_user_city); Log.e("Str_set_user_city :", "" + Str_set_user_city); } }); SP_user_city.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() { @Override public void onNothingSelected(MaterialSpinner spinner) { /*Toast.makeText(getActivity(), "Please select Country First..!!", Toast.LENGTH_SHORT).show();*/ android.support.design.widget.Snackbar.make(spinner, "Please select City First..!!", android.support.design.widget.Snackbar.LENGTH_SHORT).show(); } }); /*%%%%%%%%%%%%%% Spinner City (End) %%%%%%%%%%%%%%*/ CV_et_address_continue_payment.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { Str_set_user_f_name = ET_address_user_first_name.getText().toString().trim(); Str_set_user_l_name = ET_address_user_last_name.getText().toString().trim(); Str_set_user_street_address = ET_address_user_address.getText().toString().trim(); Str_set_user_phone = ET_address_phone.getText().toString().trim(); Str_set_user_phone_replace = Str_set_user_phone.replace(" ", ""); Str_set_user_zip_code = ET_address_user_zip_code.getText().toString().trim(); Log.e("Address Data :", "\n" + "Str_set_user_f_name :" + "" + Str_set_user_f_name + "\n" + "Str_set_user_l_name :" + "" + Str_set_user_l_name + "\n" + "Str_set_user_street_address :" + "" + Str_set_user_street_address + "\n" + "Str_set_user_phone :" + "" + Str_set_user_phone + "\n" + "Str_set_user_phone_replace :" + "" + Str_set_user_phone_replace + "\n" + "Str_set_user_zip_code :" + "" + Str_set_user_zip_code + "\n" + "Str_set_user_country :" + "" + Str_set_user_country + "\n" + "Str_set_user_state :" + "" + Str_set_user_state + "\n" + "Str_set_user_city :" + "" + Str_set_user_city + "\n"); if (event.getAction() == MotionEvent.ACTION_DOWN) { Log.e("Action ", "Down"); CV_et_address_continue_payment_click.setVisibility(View.VISIBLE); CV_et_address_continue_payment.setVisibility(View.GONE); v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // Toast.makeText(getApplicationContext(), "Add to cart Clicked", Toast.LENGTH_SHORT).show(); return true; } if (event.getAction() == MotionEvent.ACTION_MOVE) { Log.e("Action ", "Move"); CV_et_address_continue_payment_click.setVisibility(View.VISIBLE); CV_et_address_continue_payment.setVisibility(View.GONE); return true; } if (event.getAction() == MotionEvent.ACTION_UP) { Log.e("Action ", "Up"); CV_et_address_continue_payment_click.setVisibility(View.GONE); CV_et_address_continue_payment.setVisibility(View.VISIBLE); /*Intent MyCartPage = new Intent(GetDeliveryAddress.this, MyCartActivity.class); startActivity(MyCartPage);*/ if (Str_set_user_f_name.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(ET_address_user_first_name); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please enter your First Name")); } else if (Str_set_user_l_name.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(ET_address_user_last_name); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please enter your Last Name")); } else if (Str_set_user_street_address.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(ET_address_user_address); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please enter your Street Address")); } else if (Str_set_user_phone_replace.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(ET_address_phone); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please enter your Phone Number")); } else if (Str_set_user_country.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(SP_user_country); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please select your Country")); } else if (Str_set_user_state.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(SP_user_state); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please select your State")); } else if (Str_set_user_city.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ***************/ YoYo.with(Techniques.Tada).duration(700).playOn(SP_user_city); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please select your City")); } else if (Str_set_user_zip_code.isEmpty()) { ISerror = true; v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); // v.playSoundEffect(SoundEffectConstants.CLICK); /**************** Start Animation ************** **/ YoYo.with(Techniques.Tada).duration(700).playOn(ET_address_user_zip_code); /**************** End Animation ****************/ /*Toast.makeText(getApplicationContext(), "Please enter your Email Id", Toast.LENGTH_SHORT).show();*/ SnackbarManager.show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please enter your area code")); } else if (!ISerror) { // v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); /*Toast.makeText(getApplicationContext(), "Good", Toast.LENGTH_SHORT).show();*/ if (Utils.isConnected(getActivity())) { UserUpdateAddressJsontask task = new UserUpdateAddressJsontask(); task.execute(); } else { SnackbarManager .show(Snackbar.with(getActivity()).position(Snackbar.SnackbarPosition.TOP) .margin(15, 15).backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Please Your Internet Connectivity..!!")); } /* SnackbarManager.show( Snackbar.with(getActivity()) .position(Snackbar.SnackbarPosition.TOP) .margin(15, 15) .backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Good All Value Correct"));*/ // v.playSoundEffect(android.view.SoundEffectConstants.CLICK); } /*SnackbarManager.show( Snackbar.with(getActivity()) .position(Snackbar.SnackbarPosition.TOP) .margin(15, 15) .backgroundDrawable(R.drawable.snackbar_custom_layout) .text("Confirm Clicked")); */ return true; } return false; } }); initUI(rootView); return rootView; }
From source file:android.support.design.widget.FloatingActionButton.java
@Override public boolean onTouchEvent(MotionEvent ev) { switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: // Skipping the gesture if it doesn't start in in the FAB 'content' area if (getContentRect(mTouchArea) && !mTouchArea.contains((int) ev.getX(), (int) ev.getY())) { return false; }//from w w w .j ava 2 s .c om break; } return super.onTouchEvent(ev); }
From source file:activitydialogtest.pczhu.com.everytest.refresh2.SwipeListView.java
/** * @see ListView#onInterceptTouchEvent(MotionEvent) *//*from ww w.j a v a2 s .c om*/ @Override public boolean onInterceptTouchEvent(MotionEvent ev) { int action = MotionEventCompat.getActionMasked(ev); final float x = ev.getX(); final float y = ev.getY(); if (isEnabled() && touchListener.isSwipeEnabled()) { if (touchState == TOUCH_STATE_SCROLLING_X) { return touchListener.onTouch(this, ev); } switch (action) { case MotionEvent.ACTION_MOVE: checkInMoving(x, y); return touchState == TOUCH_STATE_SCROLLING_Y; case MotionEvent.ACTION_DOWN: touchListener.onTouch(this, ev); touchState = TOUCH_STATE_REST; lastMotionX = x; lastMotionY = y; return false; case MotionEvent.ACTION_CANCEL: touchState = TOUCH_STATE_REST; break; case MotionEvent.ACTION_UP: touchListener.onTouch(this, ev); return touchState == TOUCH_STATE_SCROLLING_Y; default: break; } } return super.onInterceptTouchEvent(ev); }
From source file:com.orbar.pxdemo.ImageView.FivePXImageFragment.java
private void setupMap(String latitude, String longitude, String imageName, String imageDescription) { map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); // get references to transparent image and ScrollView final ScrollView mainScrollView = (ScrollView) rootView.findViewById(R.id.image_details_scrollView); ImageView transparentImageView = (ImageView) rootView.findViewById(R.id.transparent_image); // allows scrolling on the map independently of the scrollView transparentImageView.setOnTouchListener(new View.OnTouchListener() { @Override/*from w ww . j a v a 2 s . com*/ public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: // Disallow ScrollView to intercept touch events. mainScrollView.requestDisallowInterceptTouchEvent(true); // Disable touch on transparent view return false; case MotionEvent.ACTION_UP: // Allow ScrollView to intercept touch events. mainScrollView.requestDisallowInterceptTouchEvent(false); return true; case MotionEvent.ACTION_MOVE: mainScrollView.requestDisallowInterceptTouchEvent(true); return false; default: return true; } } }); LatLng imageLocation = new LatLng(Double.valueOf(latitude), Double.valueOf(longitude)); LatLng mapCenter = new LatLng(Double.valueOf(latitude) - 1, Double.valueOf(longitude)); map.addMarker(new MarkerOptions().position(imageLocation).snippet(imageDescription).title(imageName)); // Move the camera instantly to position with a zoom of 6. map.moveCamera(CameraUpdateFactory.newLatLngZoom(mapCenter, 6)); }
From source file:SwipeListView.java
/** * @see android.widget.ListView#onInterceptTouchEvent(android.view.MotionEvent) *//*from ww w .j a v a 2 s . com*/ @Override public boolean onInterceptTouchEvent(MotionEvent ev) { int action = MotionEventCompat.getActionMasked(ev); final float x = ev.getX(); final float y = ev.getY(); if (isEnabled() && touchListener.isSwipeEnabled()) { if (touchState == TOUCH_STATE_SCROLLING_X) { return touchListener.onTouch(this, ev); } switch (action) { case MotionEvent.ACTION_MOVE: checkInMoving(x, y); return touchState == TOUCH_STATE_SCROLLING_Y; case MotionEvent.ACTION_DOWN: super.onInterceptTouchEvent(ev); touchListener.onTouch(this, ev); touchState = TOUCH_STATE_REST; lastMotionX = x; lastMotionY = y; return false; case MotionEvent.ACTION_CANCEL: touchState = TOUCH_STATE_REST; break; case MotionEvent.ACTION_UP: touchListener.onTouch(this, ev); return touchState == TOUCH_STATE_SCROLLING_Y; default: break; } } return super.onInterceptTouchEvent(ev); }
From source file:chenyoufu.hciprojectes10.MyGLSurfaceView.java
@Override public boolean onTouchEvent(MotionEvent event) { int action = MotionEventCompat.getActionMasked(event); int index = MotionEventCompat.getActionIndex(event); if (event.getPointerCount() > 1) { if (action == MotionEvent.ACTION_POINTER_UP && event.getPointerCount() == 2) { xOri = MotionEventCompat.getX(event, 1 - index); yOri = MotionEventCompat.getY(event, 1 - index); }/*from w w w.ja v a 2 s . c o m*/ mScaleDetector.onTouchEvent(event); } else { switch (action) { case MotionEvent.ACTION_DOWN: xOri = MotionEventCompat.getX(event, index); yOri = MotionEventCompat.getY(event, index); break; case MotionEvent.ACTION_MOVE: float xNow = MotionEventCompat.getX(event, index); float yNow = MotionEventCompat.getY(event, index); float[] xMove = Global.fArrayMul(Global.getCamCrossProductNV(), (xOri - xNow) / Global.moveFactor); Global.cameraEye = Global.fArrayAdd(Global.cameraEye, xMove); Global.cameraCentre = Global.fArrayAdd(Global.cameraCentre, xMove); float[] yMove = Global.fArrayMul(Global.cameraUp, (yNow - yOri) / Global.moveFactor); Global.cameraEye = Global.fArrayAdd(Global.cameraEye, yMove); Global.cameraCentre = Global.fArrayAdd(Global.cameraCentre, yMove); xOri = xNow; yOri = yNow; break; default: break; } } requestRender(); return true; }
From source file:com.app.afteryou.ui.staggered.StaggeredGridView.java
@Override public boolean onTouchEvent(MotionEvent ev) { if (!isEnabled()) { // A disabled view that is clickable still consumes the touch // events, it just doesn't respond to them. return isClickable() || isLongClickable(); }//w w w . j a v a2 s . c o m mVelocityTracker.addMovement(ev); final int action = ev.getAction() & MotionEventCompat.ACTION_MASK; int motionPosition = pointToPosition((int) ev.getX(), (int) ev.getY()); switch (action) { case MotionEvent.ACTION_DOWN: mVelocityTracker.clear(); mScroller.abortAnimation(); mLastTouchY = ev.getY(); mLastTouchX = ev.getX(); motionPosition = pointToPosition((int) mLastTouchX, (int) mLastTouchY); mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mTouchRemainderY = 0; if (mTouchMode != TOUCH_MODE_FLINGING && !mDataChanged && motionPosition >= 0 && getAdapter().isEnabled(motionPosition)) { mTouchMode = TOUCH_MODE_DOWN; mBeginClick = true; if (mPendingCheckForTap == null) { mPendingCheckForTap = new CheckForTap(); } postDelayed(mPendingCheckForTap, ViewConfiguration.getTapTimeout()); } mMotionPosition = motionPosition; invalidate(); break; case MotionEvent.ACTION_MOVE: { final int index = MotionEventCompat.findPointerIndex(ev, mActivePointerId); if (index < 0) { Log.e(TAG, "onInterceptTouchEvent could not find pointer with id " + mActivePointerId + " - did StaggeredGridView receive an inconsistent " + "event stream?"); return false; } final float y = MotionEventCompat.getY(ev, index); final float dy = y - mLastTouchY + mTouchRemainderY; final int deltaY = (int) dy; mTouchRemainderY = dy - deltaY; if (Math.abs(dy) > mTouchSlop) { setTouchMode(TOUCH_MODE_DRAGGING); } if (mTouchMode == TOUCH_MODE_DRAGGING) { mLastTouchY = y; if (!trackMotionScroll(deltaY, true)) { // Break fling velocity if we impacted an edge. mVelocityTracker.clear(); } } updateSelectorState(); } break; case MotionEvent.ACTION_CANCEL: updateSelectorState(); setPressed(false); View motionView = this.getChildAt(mMotionPosition - mFirstPosition); if (motionView != null) { motionView.setPressed(false); } final Handler handler = getHandler(); if (handler != null) { handler.removeCallbacks(mPendingCheckForLongPress); } if (mTopEdge != null) { mTopEdge.onRelease(); mBottomEdge.onRelease(); } setTouchMode(TOUCH_MODE_IDLE); break; case MotionEvent.ACTION_UP: { mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); final float velocity = VelocityTrackerCompat.getYVelocity(mVelocityTracker, mActivePointerId); final int prevTouchMode = mTouchMode; if (Math.abs(velocity) > mFlingVelocity) { // TODO setTouchMode(TOUCH_MODE_FLINGING); mScroller.fling(0, 0, 0, (int) velocity, 0, 0, Integer.MIN_VALUE, Integer.MAX_VALUE); mLastTouchY = 0; ViewCompat.postInvalidateOnAnimation(this); } else { setTouchMode(TOUCH_MODE_IDLE); } if (!mDataChanged && mAdapter.isEnabled(motionPosition)) { // TODO : handle mTouchMode = TOUCH_MODE_TAP; } else { mTouchMode = TOUCH_MODE_REST; } switch (prevTouchMode) { case TOUCH_MODE_DOWN: case TOUCH_MODE_TAP: case TOUCH_MODE_DONE_WAITING: final View child = getChildAt(motionPosition - mFirstPosition); final float x = ev.getX(); final boolean inList = x > getPaddingLeft() && x < getWidth() - getPaddingRight(); if (child != null && !child.hasFocusable() && inList) { if (mTouchMode != TOUCH_MODE_DOWN) { child.setPressed(false); } if (mPerformClick == null) { invalidate(); mPerformClick = new PerformClick(); } final PerformClick performClick = mPerformClick; performClick.mClickMotionPosition = motionPosition; performClick.rememberWindowAttachCount(); if (mTouchMode == TOUCH_MODE_DOWN || mTouchMode == TOUCH_MODE_TAP) { final Handler handlerTouch = getHandler(); if (handlerTouch != null) { handlerTouch.removeCallbacks(mTouchMode == TOUCH_MODE_DOWN ? mPendingCheckForTap : mPendingCheckForLongPress); } if (!mDataChanged && mAdapter.isEnabled(motionPosition)) { mTouchMode = TOUCH_MODE_TAP; layoutChildren(mDataChanged); child.setPressed(true); positionSelector(mMotionPosition, child); setPressed(true); if (mSelector != null) { Drawable d = mSelector.getCurrent(); if (d != null && d instanceof TransitionDrawable) { ((TransitionDrawable) d).resetTransition(); } } if (mTouchModeReset != null) { removeCallbacks(mTouchModeReset); } mTouchModeReset = new Runnable() { @Override public void run() { mTouchMode = TOUCH_MODE_REST; child.setPressed(false); setPressed(false); if (!mDataChanged) { performClick.run(); } } }; postDelayed(mTouchModeReset, ViewConfiguration.getPressedStateDuration()); } else { mTouchMode = TOUCH_MODE_REST; } return true; } else if (!mDataChanged && mAdapter.isEnabled(motionPosition)) { performClick.run(); } } mTouchMode = TOUCH_MODE_REST; } mBeginClick = false; updateSelectorState(); } break; } return true; }
From source file:com.achep.acdisplay.ui.fragments.AcDisplayFragment.java
@Override public void onPressedView(MotionEvent event, int activePointerId, View view) { mTouchHandler.removeCallbacksAndMessages(null); mPressedIconView = view;//from w w w .j a v a 2 s . co m if (view == null) { return; } final Widget widget = findWidgetByIcon(view); if (isCurrentWidget(widget)) { // We need to reset this, cause current widget may be // pinned. mHandler.removeMessages(MSG_SHOW_HOME_WIDGET); return; } else if (widget == null && mSelectedWidget.isHomeWidget()) { return; } int action = event.getActionMasked(); int delay = action != MotionEvent.ACTION_DOWN ? mConfigWidgetSelectDelay : 0; mTouchHandler.postDelayed(new Runnable() { @Override public void run() { if (widget == null) { showHomeWidget(); } else { showWidget(widget); } } }, delay); }
From source file:android.support.design.widget.CoordinatorLayout.java
private boolean performIntercept(MotionEvent ev, final int type) { boolean intercepted = false; boolean newBlock = false; MotionEvent cancelEvent = null;//ww w .j a v a 2 s . co m final int action = MotionEventCompat.getActionMasked(ev); final List<View> topmostChildList = mTempList1; getTopSortedChildren(topmostChildList); // Let topmost child views inspect first final int childCount = topmostChildList.size(); for (int i = 0; i < childCount; i++) { final View child = topmostChildList.get(i); final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final Behavior b = lp.getBehavior(); if ((intercepted || newBlock) && action != MotionEvent.ACTION_DOWN) { // Cancel all behaviors beneath the one that intercepted. // If the event is "down" then we don't have anything to cancel yet. if (b != null) { if (cancelEvent == null) { final long now = SystemClock.uptimeMillis(); cancelEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0); } switch (type) { case TYPE_ON_INTERCEPT: b.onInterceptTouchEvent(this, child, cancelEvent); break; case TYPE_ON_TOUCH: b.onTouchEvent(this, child, cancelEvent); break; } } continue; } if (!intercepted && b != null) { switch (type) { case TYPE_ON_INTERCEPT: intercepted = b.onInterceptTouchEvent(this, child, ev); break; case TYPE_ON_TOUCH: intercepted = b.onTouchEvent(this, child, ev); break; } if (intercepted) { mBehaviorTouchView = child; } } // Don't keep going if we're not allowing interaction below this. // Setting newBlock will make sure we cancel the rest of the behaviors. final boolean wasBlocking = lp.didBlockInteraction(); final boolean isBlocking = lp.isBlockingInteractionBelow(this, child); newBlock = isBlocking && !wasBlocking; if (isBlocking && !newBlock) { // Stop here since we don't have anything more to cancel - we already did // when the behavior first started blocking things below this point. break; } } topmostChildList.clear(); return intercepted; }
From source file:com.owncloud.android.authentication.AuthenticatorActivity.java
/** * {@inheritDoc}//from w w w .jav a 2 s . co m * * IMPORTANT ENTRY POINT 1: activity is shown to the user */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.account_setup); mAuthMessage = (TextView) findViewById(R.id.auth_message); mHostUrlInput = (EditText) findViewById(R.id.hostUrlInput); mHostUrlInput.setText(getString(R.string.server_url)); // valid although // R.string.server_url // is an empty // string mUsernameInput = (EditText) findViewById(R.id.account_username); mPasswordInput = (EditText) findViewById(R.id.account_password); mPasswordInput2 = (EditText) findViewById(R.id.account_password2); mOAuthAuthEndpointText = (TextView) findViewById(R.id.oAuthEntryPoint_1); mOAuthTokenEndpointText = (TextView) findViewById(R.id.oAuthEntryPoint_2); mOAuth2Check = (CheckBox) findViewById(R.id.oauth_onOff_check); mOkButton = findViewById(R.id.buttonOK); mAuthStatusLayout = (TextView) findViewById(R.id.auth_status_text); // / set Host Url Input Enabled mHostUrlInputEnabled = getResources().getBoolean(R.bool.show_server_url_input); locationSpinner = (Spinner) findViewById(R.id.spinner1); // / complete label for 'register account' button Button b = (Button) findViewById(R.id.account_register); if (b != null) { b.setText(String.format(getString(R.string.auth_register), getString(R.string.app_name))); } // / initialization mAccountMgr = AccountManager.get(this); mNewCapturedUriFromOAuth2Redirection = null; mAction = getIntent().getByteExtra(EXTRA_ACTION, ACTION_CREATE); mAccount = null; mHostBaseUrl = ""; location = " ";//locationSpinner.getSelectedItem(); locationSpinner.setOnItemSelectedListener(this); boolean refreshButtonEnabled = false; // URL input configuration applied if (!mHostUrlInputEnabled) { findViewById(R.id.hostUrlFrame).setVisibility(View.GONE); mRefreshButton = findViewById(R.id.centeredRefreshButton); } else { mRefreshButton = findViewById(R.id.embeddedRefreshButton); } if (savedInstanceState == null) { mResumed = false; // / connection state and info mAuthMessageVisibility = View.GONE; mServerStatusText = mServerStatusIcon = 0; mServerIsValid = false; mServerIsChecked = false; mIsSslConn = false; mAuthStatusText = mAuthStatusIcon = 0; // / retrieve extras from intent mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT); if (mAccount != null) { String ocVersion = mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION); Log.d("!!!!!!!!!!!!!!!!!!!!!!!!! ", mAccount.name); if (ocVersion != null) { mDiscoveredVersion = new OwnCloudVersion(ocVersion); } mHostBaseUrl = normalizeUrl( mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL)); mHostUrlInput.setText(mHostBaseUrl); String userName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@')); Log.d("!!!!!!!!!!!!!!!!!!!!!!!!!4234 ", userName); mUsernameInput.setText(userName); } initAuthorizationMethod(); // checks intent and setup.xml to // determine mCurrentAuthorizationMethod mJustCreated = true; if (mAction == ACTION_UPDATE_TOKEN || !mHostUrlInputEnabled) { checkOcServer(); } } else { mResumed = true; // / connection state and info mAuthMessageVisibility = savedInstanceState.getInt(KEY_AUTH_MESSAGE_VISIBILITY); mAuthMessageText = savedInstanceState.getString(KEY_AUTH_MESSAGE_TEXT); mServerIsValid = savedInstanceState.getBoolean(KEY_SERVER_VALID); mServerIsChecked = savedInstanceState.getBoolean(KEY_SERVER_CHECKED); mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT); mServerStatusIcon = savedInstanceState.getInt(KEY_SERVER_STATUS_ICON); mIsSslConn = savedInstanceState.getBoolean(KEY_IS_SSL_CONN); mAuthStatusText = savedInstanceState.getInt(KEY_AUTH_STATUS_TEXT); mAuthStatusIcon = savedInstanceState.getInt(KEY_AUTH_STATUS_ICON); if (savedInstanceState.getBoolean(KEY_PASSWORD_VISIBLE, false)) { showPassword(); } // / server data String ocVersion = savedInstanceState.getString(KEY_OC_VERSION); if (ocVersion != null) { mDiscoveredVersion = new OwnCloudVersion(ocVersion); } mHostBaseUrl = savedInstanceState.getString(KEY_HOST_URL_TEXT); // account data, if updating mAccount = savedInstanceState.getParcelable(KEY_ACCOUNT); // Log.d("////////////////// ",mAccount.name); mAuthTokenType = savedInstanceState.getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE); if (mAuthTokenType == null) { mAuthTokenType = AccountAuthenticator.AUTH_TOKEN_TYPE_PASSWORD; } // check if server check was interrupted by a configuration change if (savedInstanceState.getBoolean(KEY_SERVER_CHECK_IN_PROGRESS, false)) { checkOcServer(); } // refresh button enabled refreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED); } if (mAuthMessageVisibility == View.VISIBLE) { showAuthMessage(mAuthMessageText); } else { hideAuthMessage(); } adaptViewAccordingToAuthenticationMethod(); showServerStatus(); showAuthStatus(); if (mAction == ACTION_UPDATE_TOKEN) { // / lock things that should not change mHostUrlInput.setEnabled(false); mHostUrlInput.setFocusable(false); mUsernameInput.setEnabled(false); mUsernameInput.setFocusable(false); mOAuth2Check.setVisibility(View.GONE); } // if (mServerIsChecked && !mServerIsValid && mRefreshButtonEnabled) // showRefreshButton(); if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton(); mOkButton.setEnabled(mServerIsValid); // state not automatically // recovered in configuration // changes if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType) || !AUTH_OPTIONAL.equals(getString(R.string.auth_method_oauth2))) { mOAuth2Check.setVisibility(View.GONE); } mPasswordInput.setText(""); // clean password to avoid social hacking // (disadvantage: password in removed if the // device is turned aside) // / bind view elements to listeners and other friends mHostUrlInput.setOnFocusChangeListener(this); mHostUrlInput.setImeOptions(EditorInfo.IME_ACTION_NEXT); mHostUrlInput.setOnEditorActionListener(this); mHostUrlInput.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (!mHostBaseUrl.equals(normalizeUrl(mHostUrlInput.getText().toString()))) { mOkButton.setEnabled(false); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!mResumed) { mAuthStatusIcon = 0; mAuthStatusText = 0; showAuthStatus(); } mResumed = false; } }); mPasswordInput.setOnFocusChangeListener(this); mPasswordInput.setImeOptions(EditorInfo.IME_ACTION_DONE); mPasswordInput.setOnEditorActionListener(this); mPasswordInput.setOnTouchListener(new RightDrawableOnTouchListener() { @Override public boolean onDrawableTouch(final MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { AuthenticatorActivity.this.onViewPasswordClick(); } return true; } }); findViewById(R.id.scroll).setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType) && mHostUrlInput.hasFocus()) { checkOcServer(); } } return false; } }); }