Created
November 21, 2020 21:01
-
-
Save matthewmorrone/cfaf715e292b272d55cf7f132c616a28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private int longClickDuration = 3000; | |
private boolean isLongPress = false; | |
numEquipeCheat.setOnTouchListener(new View.OnTouchListener() { | |
@Override | |
public boolean onTouch(View v, MotionEvent event) { | |
if (event.getAction() == MotionEvent.ACTION_DOWN) { | |
isLongPress = true; | |
Handler handler = new Handler(); | |
handler.postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
if (isLongPress) { | |
Vibrator vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); | |
vibrator.vibrate(100); | |
// set your code here | |
// Don't forgot to add <uses-permission android:name="android.permission.VIBRATE" /> to vibrate. | |
} | |
} | |
}, longClickDuration); | |
} | |
else if (event.getAction() == MotionEvent.ACTION_UP) { | |
isLongPress = false; | |
} | |
return true; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment