Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cd620dd2d | ||
|
|
1e8bd05b28 | ||
|
|
95dea5b89b |
No files matched your search
+6
-1
@@ -17,7 +17,7 @@ public class LeftClickGesture extends ValidatorGesture {
|
||||
private boolean mMouseActivated;
|
||||
|
||||
public LeftClickGesture(Handler handler) {
|
||||
super(handler, LauncherPreferences.PREF_LONGPRESS_TRIGGER);
|
||||
super(handler);
|
||||
}
|
||||
|
||||
public final void inputEvent() {
|
||||
@@ -27,6 +27,11 @@ public class LeftClickGesture extends ValidatorGesture {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getGestureDelay() {
|
||||
return LauncherPreferences.PREF_LONGPRESS_TRIGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkAndTrigger() {
|
||||
boolean fingerStill = LeftClickGesture.isFingerStill(mGestureStartX, mGestureStartY, mGestureEndX, mGestureEndY, FINGER_STILL_THRESHOLD);
|
||||
|
||||
+7
-2
@@ -6,12 +6,12 @@ import net.kdt.pojavlaunch.LwjglGlfwKeycode;
|
||||
|
||||
import org.lwjgl.glfw.CallbackBridge;
|
||||
|
||||
public class RightClickGesture extends ValidatorGesture{
|
||||
public class RightClickGesture extends ValidatorGesture {
|
||||
private boolean mGestureEnabled = true;
|
||||
private boolean mGestureValid = true;
|
||||
private float mGestureStartX, mGestureStartY, mGestureEndX, mGestureEndY;
|
||||
public RightClickGesture(Handler mHandler) {
|
||||
super(mHandler, 150);
|
||||
super(mHandler);
|
||||
}
|
||||
|
||||
public final void inputEvent() {
|
||||
@@ -29,6 +29,11 @@ public class RightClickGesture extends ValidatorGesture{
|
||||
mGestureEndY += deltaY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getGestureDelay() {
|
||||
return 150;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkAndTrigger() {
|
||||
// If the validate() method was called, it means that the user held on for too long. The cancellation should be ignored.
|
||||
|
||||
+9
-6
@@ -9,16 +9,13 @@ import android.os.Handler;
|
||||
public abstract class ValidatorGesture implements Runnable{
|
||||
private final Handler mHandler;
|
||||
private boolean mGestureActive;
|
||||
private final int mRequiredDuration;
|
||||
|
||||
/**
|
||||
* @param mHandler the Handler that will be used for calling back the checkAndTrigger() method.
|
||||
* This Handler should run on the same thread as the callee of submit()/cancel()
|
||||
* @param mRequiredDuration the duration after which the class will call checkAndTrigger().
|
||||
*/
|
||||
public ValidatorGesture(Handler mHandler, int mRequiredDuration) {
|
||||
public ValidatorGesture(Handler mHandler) {
|
||||
this.mHandler = mHandler;
|
||||
this.mRequiredDuration = mRequiredDuration;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,7 +25,7 @@ public abstract class ValidatorGesture implements Runnable{
|
||||
*/
|
||||
public final boolean submit() {
|
||||
if(mGestureActive) return false;
|
||||
mHandler.postDelayed(this, mRequiredDuration);
|
||||
mHandler.postDelayed(this, getGestureDelay());
|
||||
mGestureActive = true;
|
||||
return true;
|
||||
}
|
||||
@@ -55,7 +52,13 @@ public abstract class ValidatorGesture implements Runnable{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called after mRequiredDuration milliseconds, if the gesture was not cancelled.
|
||||
* This method will be called during gesture submission to determine the gesture check duration.
|
||||
* @return the required gesture check duration in milliseconds
|
||||
*/
|
||||
protected abstract int getGestureDelay();
|
||||
|
||||
/**
|
||||
* This method will be called after getGestureDelay() milliseconds, if the gesture was not cancelled.
|
||||
* @return false if you want to mark this gesture as "inactive"
|
||||
* true otherwise
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user