List of usage examples for android.view MotionEvent getAction
public final int getAction()
From source file:br.com.cybereagle.androidwidgets.view.PagerContainer.java
@Override public boolean onTouchEvent(MotionEvent ev) { //We capture any touches not already handled by the ViewPager // to implement scrolling from a touch outside the pager bounds. switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: initialTouch.x = (int) ev.getX(); initialTouch.y = (int) ev.getY(); default:// w w w. j av a2s .co m ev.offsetLocation(center.x - initialTouch.x, center.y - initialTouch.y); break; } return pager.dispatchTouchEvent(ev); }
From source file:com.project.merauke.CustomItemizedOverlay.java
@Override public boolean onTouchEvent(MotionEvent event, MapView map) { if (event.getAction() == MotionEvent.ACTION_MOVE) { isMove = true;//from w ww. j a v a 2 s .c o m } if ((event.getAction() == MotionEvent.ACTION_UP) && isMove) { Log.d("ACTION", "UP after MOVE"); // Toast.makeText(c, "geser-geser detected", Toast.LENGTH_SHORT).show(); Projection projection = maps.getProjection(); GeoPoint geoPointMin = (GeoPoint) projection.fromPixels(0, 0); GeoPoint geoPointMax = (GeoPoint) projection.fromPixels(maps.getWidth(), maps.getHeight()); minLat = geoPointMin.getLatitudeE6() / 1E6; minLng = geoPointMin.getLongitudeE6() / 1E6; // Log.d("drikvy-min", minLat+"---"+minLng);// 2-3 maxLat = geoPointMax.getLatitudeE6() / 1E6; maxLng = geoPointMax.getLongitudeE6() / 1E6; // Log.d("drikvy-max", maxLat+"---"+maxLng);// 1-4 new FetchDataTask() { protected void onPreExecute() { whellProgress.show(); } protected void onPostExecute(ArrayList<CustomOverlayItem> result) { if (result != null) { storeAll(result); whellProgress.dismiss(); maps.invalidate(); } } }.execute(); isMove = false; } return false; }
From source file:ca.uqac.florentinth.speakerauthentication.MainActivity.java
private void initGUI() { view = findViewById(R.id.main_layout); usernameInput = (EditText) findViewById(R.id.username_input); passwordInput = (EditText) findViewById(R.id.password_input); visibiltyImage = (ImageView) findViewById(R.id.visibility); loginBtn = (Button) findViewById(R.id.btn_login); newAccountBtn = (Button) findViewById(R.id.btn_new_account); visibiltyImage.setOnTouchListener(new View.OnTouchListener() { @Override/*w w w.jav a 2s. 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; } }); loginBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { checkExternalStoragePermissions(); } }); newAccountBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getApplicationContext(), CreateActivity.class)); } }); }
From source file:com.android.deskclock.VerticalViewPager.java
@Override public boolean onTouchEvent(MotionEvent ev) { try {//from w w w . ja v a 2 s. c om initializeParent(); final float x = ev.getX(); final float y = ev.getY(); switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: { mLastMotionX = x; mLastMotionY = y; if (!mParentViewPager.onTouchEvent(ev)) return false; return verticalDrag(ev); } case MotionEvent.ACTION_MOVE: { final float xDiff = Math.abs(x - mLastMotionX); final float yDiff = Math.abs(y - mLastMotionY); if (!mHorizontalDrag && !mVerticalDrag) { if (xDiff > mTouchSlop && xDiff > yDiff) { // Swiping left and right mHorizontalDrag = true; } else if (yDiff > mTouchSlop && yDiff > xDiff) { //Swiping up and down mVerticalDrag = true; } } if (mHorizontalDrag) { return mParentViewPager.onTouchEvent(ev); } else if (mVerticalDrag) { return verticalDrag(ev); } } case MotionEvent.ACTION_UP: { if (mHorizontalDrag) { mHorizontalDrag = false; return mParentViewPager.onTouchEvent(ev); } if (mVerticalDrag) { mVerticalDrag = false; return verticalDrag(ev); } } } // Set both flags to false in case user lifted finger in the parent view pager mHorizontalDrag = false; mVerticalDrag = false; } catch (Exception e) { // The mParentViewPager shouldn't be null, but just in case. If this happens, // app should not crash, instead just ignore the user swipe input // TODO: handle the exception gracefully } return false; }
From source file:com.android.hareime.accessibility.AccessibleKeyboardViewProxy.java
/** * Simulates a transition between two {@link Key}s by sending a HOVER_EXIT * on the previous key, a HOVER_ENTER on the current key, and a HOVER_MOVE * on the current key./*from w w w . jav a 2s.c o m*/ * * @param currentKey The currently hovered key. * @param previousKey The previously hovered key. * @param event The event that triggered the transition. * @return {@code true} if the event was handled. */ private boolean onTransitionKey(Key currentKey, Key previousKey, MotionEvent event) { final int savedAction = event.getAction(); event.setAction(MotionEvent.ACTION_HOVER_EXIT); onHoverKey(previousKey, event); event.setAction(MotionEvent.ACTION_HOVER_ENTER); onHoverKey(currentKey, event); event.setAction(MotionEvent.ACTION_HOVER_MOVE); final boolean handled = onHoverKey(currentKey, event); event.setAction(savedAction); return handled; }
From source file:com.funzio.pure2D.demo.particles.NovaActivity.java
@Override public boolean onTouch(final View v, final MotionEvent event) { final int action = event.getAction() & MotionEvent.ACTION_MASK; // null check if (mNovaFactory == null) { return false; }//from w ww . j av a2s. c o m if (action == MotionEvent.ACTION_DOWN) { mStage.queueEvent(new Runnable() { @Override public void run() { final int pointerCount = event.getPointerCount(); for (int i = 0; i < pointerCount; i++) { // for demo, limit the number of emitters if (mScene.getNumGrandChildren() < mNovaFactory.getPoolSize()) { addObject(event.getX(i), mDisplaySize.y - event.getY(i)); } } } }); } return true; }
From source file:com.android_mobile.core.ui.comp.banner.LoopViewPager.java
/** * ??/*from w w w .jav a 2 s.c om*/ */ @Override public boolean dispatchTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { // if (getAdapter().getCount() > 0 && autoable) { startImageTimerTask(); } } else if (event.getAction() == MotionEvent.ACTION_DOWN) { // ? stopImageTimerTask(); } return super.dispatchTouchEvent(event); }
From source file:br.com.bioscada.apps.biotracks.fragments.StatsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); handler = new Handler(); Spinner activityTypeIcon = (Spinner) getView().findViewById(R.id.stats_activity_type_icon); activityTypeIcon.setAdapter(TrackIconUtils.getIconSpinnerAdapter(getActivity(), "")); activityTypeIcon.setOnTouchListener(new View.OnTouchListener() { @Override// w w w . j a v a 2 s .co m public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { ((TrackDetailActivity) getActivity()).chooseActivityType(category); } return true; } }); activityTypeIcon.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) { ((TrackDetailActivity) getActivity()).chooseActivityType(category); } return true; } }); }
From source file:com.baidu.android.voicedemo.ActivityTouch.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sdk2_api);/*from w w w . j a va 2 s . c o m*/ txtResult = (TextView) findViewById(R.id.txtResult); txtLog = (TextView) findViewById(R.id.txtLog); btn = (Button) findViewById(R.id.btn); setting = (Button) findViewById(R.id.setting); setting.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent("com.baidu.speech.asr.demo.setting"); startActivity(intent); } }); speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this, new ComponentName(this, VoiceRecognitionService.class)); speechRecognizer.setRecognitionListener(this); speechTips = View.inflate(this, R.layout.bd_asr_popup_speech, null); speechWave = speechTips.findViewById(R.id.wave); speechTips.setVisibility(View.GONE); addContentView(speechTips, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); btn.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: speechTips.setVisibility(View.VISIBLE); speechRecognizer.cancel(); Intent intent = new Intent(); bindParams(intent); intent.putExtra("vad", "touch"); txtResult.setText(""); txtLog.setText(""); speechRecognizer.startListening(intent); return true; case MotionEvent.ACTION_UP: speechRecognizer.stopListening(); speechTips.setVisibility(View.GONE); break; } return false; } }); }
From source file:com.suan.weclient.fragment.mass.VoiceFragment.java
private void initWidgets() { recordLayout = (RelativeLayout) view.findViewById(R.id.voice_record_start); recordLayout.setOnTouchListener(new View.OnTouchListener() { @Override/*from w ww.j ava 2 s .c o m*/ public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: recordLayout.setSelected(true); if (!isRecord) { startRecord(); } break; case MotionEvent.ACTION_MOVE: recordLayout.setSelected(true); if (!isRecord) { startRecord(); } break; default: recordLayout.setSelected(false); if (isRecord) { stopRecord(); } break; } return true; } }); }