1
0
Fork 0
mirror of https://github.com/vanitasvitae/Spherical synced 2024-12-22 02:48:00 +01:00

Add tap gesture listener and toggle input mode on tap

This commit is contained in:
vanitasvitae 2017-09-14 02:23:37 +02:00
parent a8b4e0ecb2
commit 64ed8b3d61
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -6,6 +6,9 @@ import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;
import java.io.FileNotFoundException;
@ -37,6 +40,22 @@ public class MainActivity extends AppCompatActivity {
renderer = new Renderer(surfaceView);
setContentView(surfaceView);
// Detect gestures like single taps.
final GestureDetector mGesDetect = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapConfirmed(MotionEvent event) {
SphereSurfaceView.USE_TOUCH = !SphereSurfaceView.USE_TOUCH;
return true;
}
});
surfaceView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return mGesDetect.onTouchEvent(event);
}
});
Intent intent = getIntent();
switch (intent.getAction()) {
//Image was sent into the app
@ -142,4 +161,5 @@ public class MainActivity extends AppCompatActivity {
private void displayFlatImage(InputStream inputStream) {
Log.d(TAG, "Display Flat Image!");
}
}