use of android.view.GestureDetector in project android-vision by googlesamples.
the class BarcodeCaptureActivity method onCreate.
/**
* Initializes the UI and creates the detector pipeline.
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.barcode_capture);
mPreview = (CameraSourcePreview) findViewById(R.id.preview);
mGraphicOverlay = (GraphicOverlay<BarcodeGraphic>) findViewById(R.id.graphicOverlay);
// read parameters from the intent used to launch the activity.
boolean autoFocus = getIntent().getBooleanExtra(AutoFocus, false);
boolean useFlash = getIntent().getBooleanExtra(UseFlash, false);
// Check for the camera permission before accessing the camera. If the
// permission is not granted yet, request permission.
int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
if (rc == PackageManager.PERMISSION_GRANTED) {
createCameraSource(autoFocus, useFlash);
} else {
requestCameraPermission();
}
gestureDetector = new GestureDetector(this, new CaptureGestureListener());
scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener());
Snackbar.make(mGraphicOverlay, "Tap to capture. Pinch/Stretch to zoom", Snackbar.LENGTH_LONG).show();
}
use of android.view.GestureDetector in project jmonkeyengine by jMonkeyEngine.
the class AndroidInputHandler method addListeners.
protected void addListeners(GLSurfaceView view) {
view.setOnTouchListener(this);
view.setOnKeyListener(this);
AndroidGestureProcessor gestureHandler = new AndroidGestureProcessor(touchInput);
touchInput.setGestureDetector(new GestureDetector(view.getContext(), gestureHandler));
touchInput.setScaleDetector(new ScaleGestureDetector(view.getContext(), gestureHandler));
}
use of android.view.GestureDetector in project Android-Terminal-Emulator by jackpal.
the class EmulatorView method attachSession.
/**
* Attach a {@link TermSession} to this view.
*
* @param session The {@link TermSession} this view will be displaying.
*/
public void attachSession(TermSession session) {
mTextRenderer = null;
mForegroundPaint = new Paint();
mBackgroundPaint = new Paint();
mTopRow = 0;
mLeftColumn = 0;
mGestureDetector = new GestureDetector(this);
// mGestureDetector.setIsLongpressEnabled(false);
setVerticalScrollBarEnabled(true);
setFocusable(true);
setFocusableInTouchMode(true);
mTermSession = session;
mKeyListener = new TermKeyListener(session);
session.setKeyListener(mKeyListener);
// Do init now if it was deferred until a TermSession was attached
if (mDeferInit) {
mDeferInit = false;
mKnownSize = true;
initialize();
}
}
use of android.view.GestureDetector in project AndroidPicker by gzu-liyujiang.
the class HorizontalListView method initView.
private synchronized void initView() {
mLeftViewIndex = -1;
mRightViewIndex = 0;
mDisplayOffset = 0;
mCurrentX = 0;
mNextX = 0;
mMaxX = Integer.MAX_VALUE;
mScroller = new Scroller(getContext());
mGesture = new GestureDetector(getContext(), mOnGesture);
}
use of android.view.GestureDetector in project Android-Developers-Samples by johnjohndoe.
the class BasicGestureDetectFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
View gestureView = getActivity().findViewById(R.id.sample_output);
gestureView.setClickable(true);
gestureView.setFocusable(true);
// BEGIN_INCLUDE(init_detector)
// First create the GestureListener that will include all our callbacks.
// Then create the GestureDetector, which takes that listener as an argument.
GestureDetector.SimpleOnGestureListener gestureListener = new GestureListener();
final GestureDetector gd = new GestureDetector(getActivity(), gestureListener);
/* For the view where gestures will occur, create an onTouchListener that sends
* all motion events to the gesture detector. When the gesture detector
* actually detects an event, it will use the callbacks you created in the
* SimpleOnGestureListener to alert your application.
*/
gestureView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
gd.onTouchEvent(motionEvent);
return false;
}
});
// END_INCLUDE(init_detector)
}
Aggregations