List of usage examples for android.view MotionEvent toString
@Override
public String toString()
From source file:com.google.android.gms.location.sample.locationupdates.MainActivity.java
@Override public void onLongPress(MotionEvent event) { stopUpdatesButtonHandler(mStopUpdatesButton); Toast.makeText(MainActivity.this, "Lets Stop/Pause the application !!", Toast.LENGTH_SHORT).show(); Log.d(DEBUG_TAG, "onLongPress: " + event.toString()); }
From source file:com.google.android.gms.location.sample.locationupdates.MainActivity.java
@Override public boolean onDoubleTapEvent(MotionEvent event) { startUpdatesButtonHandler(mStartUpdatesButton); Toast.makeText(MainActivity.this, "Lets Start the application !!", Toast.LENGTH_SHORT).show(); Log.d(DEBUG_TAG, "onDoubleTapEvent: " + event.toString()); return true;/*from ww w . java2s. com*/ }
From source file:org.openhab.habdroid.ui.OpenHABWidgetListActivity.java
@Override public boolean dispatchTouchEvent(MotionEvent event) { Log.d(TAG, event.toString()); Log.d(TAG, String.format("event action = %d", event.getAction())); return super.dispatchTouchEvent(event); }
From source file:com.amazon.appstream.fireclient.FireClientActivity.java
/** * A "generic motion event" includes joystick and mouse motion * when the mouse button isn't down. In our simple sample, we're * not handling the joystick, but this is where any such code * would live./* ww w . j a v a 2 s . co m*/ * * This will only ever be called in HONEYCOMB_MR1 (12) or later, so I'm marking the * function using \@TargetApi to allow it to call the super. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @Override public boolean dispatchGenericMotionEvent(MotionEvent event) { if (event.getSource() == InputDevice.SOURCE_MOUSE) { event.getPointerCoords(0, mCoordHolder); switch (event.getAction()) { case MotionEvent.ACTION_HOVER_MOVE: AppStreamInterface.mouseEvent((int) mCoordHolder.x, (int) mCoordHolder.y, 0); break; default: return super.dispatchGenericMotionEvent(event); } return true; } else if (event.getSource() == InputDevice.SOURCE_JOYSTICK) { Log.v(TAG, "Joystick event:" + event.toString()); if (!mInitializedJoystick) { mInitializedJoystick = true; InputDevice joystick = InputDevice.getDevice(event.getDeviceId()); InputDevice.MotionRange lThumbX = joystick.getMotionRange(MotionEvent.AXIS_X, InputDevice.SOURCE_JOYSTICK); InputDevice.MotionRange lThumbY = joystick.getMotionRange(MotionEvent.AXIS_Y, InputDevice.SOURCE_JOYSTICK); InputDevice.MotionRange rThumbX = joystick.getMotionRange(MotionEvent.AXIS_Z); InputDevice.MotionRange rThumbY = joystick.getMotionRange(MotionEvent.AXIS_RZ); InputDevice.MotionRange rTrigger = joystick.getMotionRange(MotionEvent.AXIS_GAS); if (rTrigger == null) { rTrigger = joystick.getMotionRange(MotionEvent.AXIS_RTRIGGER); mRTrigger = MotionEvent.AXIS_RTRIGGER; } InputDevice.MotionRange lTrigger = joystick.getMotionRange(MotionEvent.AXIS_BRAKE); if (lTrigger == null) { lTrigger = joystick.getMotionRange(MotionEvent.AXIS_LTRIGGER); mLTrigger = MotionEvent.AXIS_LTRIGGER; } List<InputDevice.MotionRange> ranges = joystick.getMotionRanges(); InputDevice.MotionRange dPad = null; String name = joystick.getName(); /* The Amazon Fire Game Controller follows the NVidia standard of sending AXIS_HAT_X/AXIS_HAT_Y results when the user hits the D-Pad. Only if we return false from dispatchGenericMotionEvent() will it then send DPAD keycodes. But the most popular Android joystick on the market at this time, the Nyko Playpad Pro, returns AXIS_HAT_X/AXIS_HAT_Y results when the left analog stick hits its extremes, meaning that the analog stick will generate DPAD keys if we return false. The Nyko generates DPAD keys directly for the DPAD controller. So we have two incompatible standards fighting with each other. Probably the safest thing to do would be to ask the user to press on their DPAD and see what messages we get, but that is beyond the scope of this example code. */ if (name.equals("Amazon Fire Game Controler")) { for (int i = 0; i < ranges.size(); ++i) { InputDevice.MotionRange range = ranges.get(i); int axis = range.getAxis(); if (axis == MotionEvent.AXIS_HAT_X || axis == MotionEvent.AXIS_HAT_Y) { dPad = ranges.get(i); break; } } } JoystickHelper.joystickDeadZones(lTrigger, rTrigger, lThumbX, lThumbY, rThumbX, rThumbY, dPad); } float lThumbX = event.getAxisValue(MotionEvent.AXIS_X); float lThumbY = -event.getAxisValue(MotionEvent.AXIS_Y); float rThumbX = event.getAxisValue(MotionEvent.AXIS_Z); float rThumbY = -event.getAxisValue(MotionEvent.AXIS_RZ); float lTrigger = event.getAxisValue(mLTrigger); float rTrigger = event.getAxisValue(mRTrigger); float hatX = event.getAxisValue(MotionEvent.AXIS_HAT_X); float hatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y); JoystickHelper.setJoystickState(lTrigger, rTrigger, lThumbX, lThumbY, rThumbX, rThumbY, hatX, hatY); return true; } return super.dispatchGenericMotionEvent(event); }
From source file:eu.powet.groundcopter.views.BaseGroundCopterUI.java
public void init_callbacks() { final GestureDetectorCompat mGestureDetector2 = new GestureDetectorCompat(ctx, new GestureDetector.OnGestureListener() { @Override// w ww .ja v a2 s . com public boolean onSingleTapUp(MotionEvent e) { // TODO Auto-generated method stub return false; } @Override public void onShowPress(MotionEvent e) { // TODO Auto-generated method stub } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { // TODO Auto-generated method stub return false; } @Override public void onLongPress(final MotionEvent e) { ctx.runOnUiThread(new Runnable() { @Override public void run() { System.out.println(e.toString()); GeoPoint m = (GeoPoint) mapView.getProjection().fromPixels(e.getX(), e.getY()); GeoPointMission wp = new GeoPointMission(m, 0); kController.handleMessage(Request.ADD_WAYPOINT, wp); Vibrator v = (Vibrator) ctx.getSystemService(Context.VIBRATOR_SERVICE); // Vibrate for 500 milliseconds v.vibrate(100); } }); } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { // TODO Auto-generated method stub return false; } @Override public boolean onDown(MotionEvent e) { // TODO Auto-generated method stub return false; } }); mapView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent e) { return mGestureDetector2.onTouchEvent(e); } }); bt_read_mission.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { kController.handleMessage(Request.CLEAR_UI_WAYPOINTS); kController.handleMessage(Request.READ_WAYPOINTS); } }); bt_write_mission.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { kController.handleMessage(Request.WRITE_WAYPOINTS); } }); bt_clean_mission.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { kController.handleMessage(Request.DELETE_WAYPOINTS); } }); bt_record.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (b_copter_record) { b_copter_record = false; kController.handleMessage(Request.DISABLE_LOG); bt_record.setText("Start Record"); } else { b_copter_record = true; kController.handleMessage(Request.ENABLE_LOG); bt_record.setText("Stop Record"); } } }); bt_set_home_location.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { /*MAV_CMD_DO_SET_HOME Changes the home location either to the current location or a specified location. Mission Param #1 Use current (1=use current location, 0=use specified location) Mission Param #2 Empty Mission Param #3 Empty Mission Param #4 Empty Mission Param #5 Latitude Mission Param #6 Longitude Mission Param #7 Altitude double lat = 48.727209; double lon = -2.00267; int alt = 15; GeoPointMission here = new GeoPointMission(new GeoPoint(lat, lon,alt)); MavlinkHelper.flyhere(mavlink, here); */ } }); bt_goto_home_location.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: kController.handleMessage(Request.RETURN_TO_LAUNCH); break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage("Are you sure to go to home?").setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); } }); bt_request_stream.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (b_request_stream) { kController.handleMessage(Request.START_STREAM); b_request_stream = false; bt_request_stream.setText(txt_stream_stop); } else { b_request_stream = true; kController.handleMessage(Request.STOP_STREAM); bt_request_stream.setText(txt_stream_start); } } }); bt_display_hud.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (b_display_hud) { kController.handleMessage(Request.ENABLE_HUD); b_display_hud = false; } else { b_display_hud = true; kController.handleMessage(Request.DISABLE_HUD); } } }); bt_connect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { bt_connect.setEnabled(false); bt_deconnect.setEnabled(true); baudrate_57600.setEnabled(false); baudrate_115200.setEnabled(false); kController.handleMessage(Request.CONNECT); } }); bt_deconnect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { bt_connect.setEnabled(true); bt_deconnect.setEnabled(false); baudrate_57600.setEnabled(true); baudrate_115200.setEnabled(true); kController.handleMessage(Request.STOP_STREAM); kController.handleMessage(Request.DISABLE_BUTTONS); kController.handleMessage(Request.DISCONNECT); } }); bt_pilot.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (pilot_auto == false) { kController.handleMessage(Request.PILOT_AUTO); pilot_auto = true; bt_pilot.setText(txt_manuel); } else { kController.handleMessage(Request.PILOT_MANUEL); pilot_auto = false; bt_pilot.setText(txt_auto); } /* DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which){ case DialogInterface.BUTTON_POSITIVE: break; case DialogInterface.BUTTON_NEGATIVE: //No button clicked break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage("Confirmez vous le changement de mode ?").setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); */ } }); bt_exit.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { kController.handleMessage(Request.DISCONNECT); kController.handleMessage(Request.EXIT); } }); baudrate_115200.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { baudrate_57600.setChecked(false); baudrate_115200.setChecked(true); kController.handleMessage(Request.CHANGE_BAUDRATE, FTDriver.BAUD115200); } }); baudrate_57600.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { baudrate_115200.setChecked(false); baudrate_57600.setChecked(true); kController.handleMessage(Request.CHANGE_BAUDRATE, FTDriver.BAUD57600); } }); bt_arm_disarm.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { /* * In a MAVLINK_MSG_ID_COMMAND_LONG A MAV_CMD of type MAV_CMD_COMPONENT_ARM_DISARM with component id MAV_COMP_ID_SYSTEM_CONTROL = 250, uses param index 1 to specify an arm/disarm motors event: 1 to arm, 0 to disarm //MAVLINK_MSG_ID_COMMAND_LONG*/ DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: if (!b_copter_is_armed) { kController.handleMessage(Request.SET_ARMED); } else { kController.handleMessage(Request.SET_DISARMED); } break; case DialogInterface.BUTTON_NEGATIVE: //No button clicked break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setMessage("Are you sure to ARM/DISARM ?").setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); } }); bt_follow_me.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!b_copter_is_followingme) { AlertDialog.Builder alert = new AlertDialog.Builder(ctx); alert.setTitle("Follow Me "); alert.setMessage("Set Altitude"); final EditText input_altitude = new EditText(ctx); input_altitude.setText("10"); alert.setView(input_altitude); alert.setPositiveButton("ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { try { int altitude = Integer.parseInt(input_altitude.getText().toString()); kController.handleMessage(Request.DELETE_WAYPOINTS); kController.handleMessage(Request.SET_FOLLOWME_ALTITUDE, altitude); kController.handleMessage(Request.START_FOLLOWME); bt_follow_me.setText(txt_followme_stop); b_copter_is_followingme = true; } catch (Exception e) { kController.handleMessage(Request.TOAST_MSG, "Error ", e.getMessage()); } } }); alert.setNegativeButton("cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); alert.show(); } else { kController.handleMessage(Request.STOP_FOLLOWME); bt_follow_me.setText(txt_followme_start); b_copter_is_followingme = false; } } }); }
From source file:com.lb.launcher.Workspace.java
/** * Called directly from a CellLayout (not by the framework), after we've been added as a * listener via setOnInterceptTouchEventListener(). This allows us to tell the CellLayout * that it should intercept touch events, which is not something that is normally supported. *//*w ww. j av a2 s . c o m*/ @Override public boolean onTouch(View v, MotionEvent event) { Log.v(getClass().toString() + "::onTouch:", event.toString()); // added by H.Yasui 2016/11/ return (workspaceInModalState() || !isFinishedSwitchingState()) || (!workspaceInModalState() && indexOfChild(v) != mCurrentPage); }