Search in sources :

Example 31 with GestureDetector

use of android.view.GestureDetector in project android_frameworks_base by DirtyUnicorns.

the class DividerView method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mHandle = (DividerHandleView) findViewById(R.id.docked_divider_handle);
    mBackground = findViewById(R.id.docked_divider_background);
    mMinimizedShadow = (MinimizedDockShadow) findViewById(R.id.minimized_dock_shadow);
    mHandle.setOnTouchListener(this);
    mDividerWindowWidth = getResources().getDimensionPixelSize(com.android.internal.R.dimen.docked_stack_divider_thickness);
    mDividerInsets = getResources().getDimensionPixelSize(com.android.internal.R.dimen.docked_stack_divider_insets);
    mDividerSize = mDividerWindowWidth - 2 * mDividerInsets;
    mTouchElevation = getResources().getDimensionPixelSize(R.dimen.docked_stack_divider_lift_elevation);
    mLongPressEntraceAnimDuration = getResources().getInteger(R.integer.long_press_dock_anim_duration);
    mGrowRecents = getResources().getBoolean(R.bool.recents_grow_in_multiwindow);
    mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop();
    mFlingAnimationUtils = new FlingAnimationUtils(getContext(), 0.3f);
    updateDisplayInfo();
    boolean landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    mHandle.setPointerIcon(PointerIcon.getSystemIcon(getContext(), landscape ? TYPE_HORIZONTAL_DOUBLE_ARROW : TYPE_VERTICAL_DOUBLE_ARROW));
    getViewTreeObserver().addOnComputeInternalInsetsListener(this);
    mHandle.setAccessibilityDelegate(mHandleDelegate);
    mGestureDetector = new GestureDetector(mContext, new SimpleOnGestureListener() {

        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            if (SWAPPING_ENABLED) {
                updateDockSide();
                SystemServicesProxy ssp = Recents.getSystemServices();
                if (mDockSide != WindowManager.DOCKED_INVALID && !ssp.isRecentsActivityVisible()) {
                    mWindowManagerProxy.swapTasks();
                    return true;
                }
            }
            return false;
        }
    });
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) FlingAnimationUtils(com.android.systemui.statusbar.FlingAnimationUtils) SimpleOnGestureListener(android.view.GestureDetector.SimpleOnGestureListener) GestureDetector(android.view.GestureDetector) MotionEvent(android.view.MotionEvent)

Example 32 with GestureDetector

use of android.view.GestureDetector in project instructure-android by instructure.

the class BaseLoginLandingPageActivity method setupGesture.

private void setupGesture() {
    mGesture = new GestureDetector(getApplicationContext(), new GestureDetector.SimpleOnGestureListener() {

        public boolean onDown(MotionEvent event) {
            return true;
        }
    });
    findViewById(R.id.rootView).setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return mGesture.onTouchEvent(event);
        }
    });
}
Also used : GestureDetector(android.view.GestureDetector) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) MotionEvent(android.view.MotionEvent)

Example 33 with GestureDetector

use of android.view.GestureDetector in project instructure-android by instructure.

the class URLSignIn method onCreate.

// /////////////////////////////////////////////////////////////////////////
// LifeCycle
// /////////////////////////////////////////////////////////////////////////
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getRootLayout());
    mTopDivider = findViewById(R.id.topDivider);
    listView = (ListView) findViewById(R.id.listview);
    mConnect = (ImageView) findViewById(R.id.connect);
    mRightHelpIcon = findViewById(R.id.help_button);
    mCanvasLogo = findViewById(R.id.canvas_logo);
    SoftKeyboardUtil.observeSoftKeyBoard(this, this);
    // Log to GA.
    trackAppFlow(URLSignIn.this);
    setupUrlEnter();
    // Handle Intent. This will set the URLEnter if it was passed in. So it has to be AFTER it's initialized and set.
    handleIntent();
    // Handle the Crouton if it exists.
    if (messageToUser != null && messageToUser.length() > 1) {
        displayMessage(messageToUser, MESSAGE_TYPE_WARNING);
    }
    if (mConnect != null) {
        mConnect.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                connectToURL();
            }
        });
    }
    if (getErrorDelegate() != null) {
        // Set Retrofit Error Handling Delegate
        APIHelpers.setDefaultErrorDelegateClass(URLSignIn.this, getErrorDelegate().getClass().getName());
    }
    // Start crashlytics
    startCrashlytics();
    // Set our user agent for CanvasKit.
    APIHelpers.setUserAgent(URLSignIn.this, CanvasAPI.getCandroidUserAgent(getUserAgent(), URLSignIn.this));
    // Start helpShift
    startHelpShift();
    // Delete old externally cached files
    deleteCachedFiles();
    // Help Layout
    findViewById(R.id.help_button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showHelpShiftSupport();
        }
    });
    // Set up gesture
    gesture = new GestureDetector(getApplicationContext(), new GestureDetector.SimpleOnGestureListener() {

        public boolean onDown(MotionEvent event) {
            return true;
        }
    });
    // Handle canvas_login stuff.
    findViewById(R.id.rootView).setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return gesture.onTouchEvent(event);
        }
    });
    setupCallbacks();
    // See if the user is already signed in.
    checkSignedIn(true);
    beginAdapterSetupProcess();
    handleNightlyBuilds();
}
Also used : GestureDetector(android.view.GestureDetector) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AutoCompleteTextView(android.widget.AutoCompleteTextView) MotionEvent(android.view.MotionEvent)

Example 34 with GestureDetector

use of android.view.GestureDetector in project RxTools by vondear.

the class RxScaleImageView method setGestureDetector.

private void setGestureDetector(final Context context) {
    this.detector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            if (panEnabled && readySent && vTranslate != null && e1 != null && e2 != null && (Math.abs(e1.getX() - e2.getX()) > 50 || Math.abs(e1.getY() - e2.getY()) > 50) && (Math.abs(velocityX) > 500 || Math.abs(velocityY) > 500) && !isZooming) {
                PointF vTranslateEnd = new PointF(vTranslate.x + (velocityX * 0.25f), vTranslate.y + (velocityY * 0.25f));
                float sCenterXEnd = ((getWidth() / 2) - vTranslateEnd.x) / scale;
                float sCenterYEnd = ((getHeight() / 2) - vTranslateEnd.y) / scale;
                new AnimationBuilder(new PointF(sCenterXEnd, sCenterYEnd)).withEasing(EASE_OUT_QUAD).withPanLimited(false).withOrigin(ORIGIN_FLING).start();
                return true;
            }
            return super.onFling(e1, e2, velocityX, velocityY);
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            performClick();
            return true;
        }

        @Override
        public boolean onDoubleTap(MotionEvent e) {
            if (zoomEnabled && readySent && vTranslate != null) {
                // Hacky solution for #15 - after a double tap the GestureDetector gets in a state
                // where the next fling is ignored, so here we replace it with a new one.
                setGestureDetector(context);
                if (quickScaleEnabled) {
                    // Store quick scale params. This will become either a double tap zoom or a
                    // quick scale depending on whether the user swipes.
                    vCenterStart = new PointF(e.getX(), e.getY());
                    vTranslateStart = new PointF(vTranslate.x, vTranslate.y);
                    scaleStart = scale;
                    isQuickScaling = true;
                    isZooming = true;
                    quickScaleLastDistance = -1F;
                    quickScaleSCenter = viewToSourceCoord(vCenterStart);
                    quickScaleVStart = new PointF(e.getX(), e.getY());
                    quickScaleVLastPoint = new PointF(quickScaleSCenter.x, quickScaleSCenter.y);
                    quickScaleMoved = false;
                    // We need to get events in onTouchEvent after this.
                    return false;
                } else {
                    // Start double tap zoom animation.
                    doubleTapZoom(viewToSourceCoord(new PointF(e.getX(), e.getY())), new PointF(e.getX(), e.getY()));
                    return true;
                }
            }
            return super.onDoubleTapEvent(e);
        }
    });
}
Also used : PointF(android.graphics.PointF) GestureDetector(android.view.GestureDetector) MotionEvent(android.view.MotionEvent)

Example 35 with GestureDetector

use of android.view.GestureDetector in project CustomViews by AndroidStudy233.

the class PhotoView method init.

private void init() {
    super.setScaleType(ScaleType.MATRIX);
    if (mScaleType == null)
        mScaleType = ScaleType.CENTER_INSIDE;
    mRotateDetector = new RotateGestureDetector(mRotateListener);
    mDetector = new GestureDetector(getContext(), mGestureListener);
    mScaleDetector = new ScaleGestureDetector(getContext(), mScaleListener);
    float density = getResources().getDisplayMetrics().density;
    MAX_OVER_SCROLL = (int) (density * 30);
    MAX_FLING_OVER_SCROLL = (int) (density * 30);
    MAX_OVER_RESISTANCE = (int) (density * 140);
    mMinRotate = MIN_ROTATE;
    mAnimaDuring = ANIMA_DURING;
    mMaxScale = MAX_SCALE;
}
Also used : GestureDetector(android.view.GestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector)

Aggregations

GestureDetector (android.view.GestureDetector)220 MotionEvent (android.view.MotionEvent)90 View (android.view.View)53 ScaleGestureDetector (android.view.ScaleGestureDetector)42 Paint (android.graphics.Paint)30 TextView (android.widget.TextView)29 Handler (android.os.Handler)20 ImageView (android.widget.ImageView)20 Matrix (android.graphics.Matrix)18 SuppressLint (android.annotation.SuppressLint)17 Scroller (android.widget.Scroller)16 WindowManager (android.view.WindowManager)15 TypedArray (android.content.res.TypedArray)12 SimpleOnGestureListener (android.view.GestureDetector.SimpleOnGestureListener)11 ViewGroup (android.view.ViewGroup)10 AdapterView (android.widget.AdapterView)10 Intent (android.content.Intent)9 SharedPreferences (android.content.SharedPreferences)9 PointF (android.graphics.PointF)9 OverScroller (android.widget.OverScroller)9