List of usage examples for android.view MotionEvent ACTION_UP
int ACTION_UP
To view the source code for android.view MotionEvent ACTION_UP.
Click Source Link
From source file:com.spoiledmilk.ibikecph.map.MapActivity.java
protected boolean onImgSwiperTouch(View view, MotionEvent event) { if (leftContainer.getVisibility() != View.VISIBLE) { leftContainer.setVisibility(View.VISIBLE); }//w w w. j a va2s . co m if (mapDisabledView.getVisibility() != View.VISIBLE) { mapDisabledView.setVisibility(View.VISIBLE); } switch (event.getAction()) { case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: view.setPressed(false); if (moveCount <= 3) translate(slidden ? -maxSlide : maxSlide, true); else translate(0, true); break; case MotionEvent.ACTION_DOWN: moveCount = 0; view.setPressed(true); touchX = event.getX(); break; case MotionEvent.ACTION_MOVE: if (moveCount++ < 3) break; newTouchX = event.getX(); delta = newTouchX - touchX; translate(delta, false); touchX = newTouchX; break; } if (slidden && mapDisabledView.getVisibility() != View.GONE) { mapDisabledView.setVisibility(View.GONE); } return true; }
From source file:com.cubic9.android.droidglove.Main.java
@Override public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mYPointWhenDown = event.getY();/*w w w. j av a2 s . co m*/ break; case MotionEvent.ACTION_MOVE: mYDiff = event.getY() - mYPointWhenDown; if (mYDiff < 0) { mYDiff = 0; mYPointWhenDown = event.getY(); } else if (mYDiff > 100) { mYDiff = 100; mYPointWhenDown = event.getY() - 100; } break; case MotionEvent.ACTION_UP: mYDiff = 0; break; default: break; } return true; }
From source file:com.test.hwautotest.emmagee.service.EmmageeService.java
/** * create a floating window to show real-time data. *///from w w w . j a v a 2 s . c om private void createFloatingWindow() { SharedPreferences shared = getSharedPreferences("float_flag", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = shared.edit(); editor.putInt("float", 1); editor.commit(); windowManager = (WindowManager) getApplicationContext().getSystemService("window"); wmParams = ((MyApplication) getApplication()).getMywmParams(); wmParams.type = 2002; wmParams.flags |= 8; wmParams.gravity = Gravity.LEFT | Gravity.TOP; wmParams.x = 0; wmParams.y = 0; wmParams.width = WindowManager.LayoutParams.WRAP_CONTENT; wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT; wmParams.format = 1; windowManager.addView(viFloatingWindow, wmParams); viFloatingWindow.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { x = event.getRawX(); y = event.getRawY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: // state = MotionEvent.ACTION_DOWN; startX = x; startY = y; mTouchStartX = event.getX(); mTouchStartY = event.getY(); Log.d("startP", "startX" + mTouchStartX + "====startY" + mTouchStartY); break; case MotionEvent.ACTION_MOVE: // state = MotionEvent.ACTION_MOVE; updateViewPosition(); break; case MotionEvent.ACTION_UP: // state = MotionEvent.ACTION_UP; updateViewPosition(); // showImg();//? mTouchStartX = mTouchStartY = 0; break; } return true; } }); // btnWifi.setOnClickListener(new OnClickListener() { // @Override // public void onClick(View v) { // try { // btnWifi = (Button) viFloatingWindow.findViewById(R.id.wifi); // String buttonText = (String) btnWifi.getText(); // String wifiText = getResources().getString( // R.string.openwifi); // if (buttonText.equals(wifiText)) { // wifiManager.setWifiEnabled(true); // btnWifi.setText(R.string.closewifi); // } else { // wifiManager.setWifiEnabled(false); // btnWifi.setText(R.string.openwifi); // } // } catch (Exception e) { // Toast.makeText(viFloatingWindow.getContext(), "?wifi", // Toast.LENGTH_LONG).show(); // Log.e(LOG_TAG, e.toString()); // } // } // }); //? imgClose.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub showMemi(); } }); }
From source file:com.android.andryyu.lifehelper.widget.RippleView.java
@Override public boolean onTouchEvent(MotionEvent event) { if (gestureDetector.onTouchEvent(event)) { animateRipple(event);//w w w .ja v a 2s .com sendClickEvent(false); rippleStatus = RIPPLE_SINGLE; } if (rippleStatus == RIPPLE_LONG_PRESS) { if (event.getAction() == MotionEvent.ACTION_UP) { rippleStatus = RIPPLE_ACTION_UP; } else if (Math.abs(event.getX() - lastLongPressX) >= touchSlop || Math.abs(event.getY() - lastLongPressY) >= touchSlop) { rippleStatus = RIPPLE_ACTION_MOVE; } } return super.onTouchEvent(event); }
From source file:com.scigames.slidegame.Registration1UserNameActivity.java
@Override public boolean dispatchTouchEvent(MotionEvent event) { View v = getCurrentFocus();//from w ww . j a v a 2 s .c om boolean ret = super.dispatchTouchEvent(event); if (v instanceof EditText) { View w = getCurrentFocus(); int scrcoords[] = new int[2]; w.getLocationOnScreen(scrcoords); float x = event.getRawX() + w.getLeft() - scrcoords[0]; float y = event.getRawY() + w.getTop() - scrcoords[1]; Log.d("Activity", "Touch event " + event.getRawX() + "," + event.getRawY() + " " + x + "," + y + " rect " + w.getLeft() + "," + w.getTop() + "," + w.getRight() + "," + w.getBottom() + " coords " + scrcoords[0] + "," + scrcoords[1]); if (event.getAction() == MotionEvent.ACTION_UP && (x < w.getLeft() || x >= w.getRight() || y < w.getTop() || y > w.getBottom())) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0); } } return ret; }
From source file:com.nextgis.maplibui.util.ControlHelper.java
public static void setClearAction(final EditText target) { target.setOnTouchListener(new View.OnTouchListener() { final int RIGHT = 2; @Override//from www.ja v a 2s. com public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { int leftEdgeOfRightDrawable = view.getRight() - target.getCompoundDrawables()[RIGHT].getBounds().width(); // when EditBox has padding, adjust leftEdge like // leftEdgeOfRightDrawable -= getResources().getDimension(R.dimen.edittext_padding_left_right); if (event.getRawX() >= leftEdgeOfRightDrawable) { // clicked on clear icon target.setText(""); target.clearFocus(); return false; } } return false; } }); }
From source file:cn.njmeter.njmeter.widget.spinner.NiceSpinner.java
@Override public boolean onTouchEvent(MotionEvent event) { if (isEnabled() && event.getAction() == MotionEvent.ACTION_UP) { if (!popupWindow.isShowing()) { showDropDown();/*w w w . j ava 2s . com*/ } else { dismissDropDown(); } } return super.onTouchEvent(event); }
From source file:agricultural.nxt.agriculturalsupervision.Activity.company.CompanyActivity.java
@Override public void onTouch(MotionEvent motionEvent) { int action = motionEvent.getAction(); switch (action) { case MotionEvent.ACTION_UP: sl.requestDisallowInterceptTouchEvent(false); break;/*from w ww. j av a2s. c om*/ case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_MOVE: sl.requestDisallowInterceptTouchEvent(true); break; } }
From source file:com.example.appf.CS3570.java
@Override public boolean onTouchEvent(MotionEvent e) { // MotionEvent reports input details from the touch screen // and other input controls. In this case, you are only // interested in events where the touch position changed. float x = e.getX(); float y = e.getY(); switch (e.getAction()) { case MotionEvent.ACTION_DOWN: if (mother.out != null) { mother.out.println("{\"type\": \"DOWN\", \"x\": " + x + ", \"y\": " + y + "}\0"); }/*from w w w . ja v a 2 s.c om*/ break; case MotionEvent.ACTION_UP: if (mother.out != null) { mother.out.println("{\"type\": \"UP\", \"x\": " + x + ", \"y\": " + y + "}\0"); } break; case MotionEvent.ACTION_MOVE: float dx = x - mPreviousX; float dy = y - mPreviousY; // reverse direction of rotation above the mid-line if (y > getHeight() / 2) { dx = dx * -1; } // reverse direction of rotation to left of the mid-line if (x < getWidth() / 2) { dy = dy * -1; } //mRenderer.mAngle += (dx + dy) * TOUCH_SCALE_FACTOR; // = 180.0f / 320 //mRenderer.mTetra.rotate(dx, 0, 1, 0); //mRenderer.mTetra.rotate(dy, 1, 0, 0); //mRenderer.mCamera.rotateY((double)(dx * TOUCH_SCALE_FACTOR)); //mRenderer.mCamera.rotateX((double)(dy * TOUCH_SCALE_FACTOR)); if (mother.out != null) { Log.e("eee", "{\"type\": \"MOVE\", \"x\": " + x + ", \"y\": " + y + "}"); mother.out.println("{\"type\": \"MOVE\", \"x\": " + x + ", \"y\": " + y + "}\0"); } requestRender(); } mPreviousX = x; mPreviousY = y; return true; }
From source file:com.cssweb.android.view.FTrendView.java
/** * true?,false??/*from w ww.j av a 2 s .c om*/ */ public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: touchesBegan(event); break; case MotionEvent.ACTION_MOVE: touchesMoved(event); break; case MotionEvent.ACTION_UP: touchesEnded(event); break; case MotionEvent.ACTION_CANCEL: break; } return true; }