1
0

Basic handling of gestures

This commit is contained in:
dump_stack() 2020-02-23 15:57:13 +00:00
parent 5dd5152503
commit b1e9f0dc54

View File

@ -3,9 +3,13 @@ package io.dumpstack.minimap;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
public class MainActivity extends AppCompatActivity {
public class MainActivity extends AppCompatActivity implements GestureDetector.OnGestureListener {
GestureDetector gestureDetector;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -18,5 +22,45 @@ public class MainActivity extends AppCompatActivity {
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
this.gestureDetector = new GestureDetector(this, this);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (gestureDetector.onTouchEvent(ev)) {
return true;
}
return super.dispatchTouchEvent(ev);
}
@Override
public boolean onDown(MotionEvent e) {
return false;
}
@Override
public void onShowPress(MotionEvent e) {
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return false;
}
@Override
public void onLongPress(MotionEvent e) {
// TODO Use swipe down to close the application
finish();
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
return false;
}
}