Search in sources :

Example 66 with GestureDetector

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();
}
Also used : GestureDetector(android.view.GestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector) SuppressLint(android.annotation.SuppressLint)

Example 67 with GestureDetector

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));
}
Also used : GestureDetector(android.view.GestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector)

Example 68 with GestureDetector

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();
    }
}
Also used : GestureDetector(android.view.GestureDetector) Paint(android.graphics.Paint)

Example 69 with GestureDetector

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);
}
Also used : GestureDetector(android.view.GestureDetector) Scroller(android.widget.Scroller)

Example 70 with GestureDetector

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)
}
Also used : GestureDetector(android.view.GestureDetector) View(android.view.View) MotionEvent(android.view.MotionEvent)

Aggregations

GestureDetector (android.view.GestureDetector)132 MotionEvent (android.view.MotionEvent)45 ScaleGestureDetector (android.view.ScaleGestureDetector)23 Paint (android.graphics.Paint)22 View (android.view.View)22 Scroller (android.widget.Scroller)13 WindowManager (android.view.WindowManager)11 Handler (android.os.Handler)9 TextView (android.widget.TextView)9 SimpleOnGestureListener (android.view.GestureDetector.SimpleOnGestureListener)8 LayoutInflater (android.view.LayoutInflater)8 TypedArray (android.content.res.TypedArray)7 ImageView (android.widget.ImageView)7 ViewConfiguration (android.view.ViewConfiguration)6 OverScroller (android.widget.OverScroller)6 Matrix (android.graphics.Matrix)5 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)5 FlingAnimationUtils (com.android.systemui.statusbar.FlingAnimationUtils)5 SuppressLint (android.annotation.SuppressLint)4 Resources (android.content.res.Resources)4