Search in sources :

Example 96 with GestureDetector

use of android.view.GestureDetector in project Timber by naman14.

the class SlideTrackSwitcher method attach.

public void attach(@NonNull View v) {
    mView = v;
    mDetector = new GestureDetector(v.getContext(), new SwipeListener());
    v.setOnTouchListener(this);
}
Also used : GestureDetector(android.view.GestureDetector)

Example 97 with GestureDetector

use of android.view.GestureDetector in project ImageViewZoom by sephiroth74.

the class ImageViewTouch method init.

@Override
protected void init(Context context, AttributeSet attrs, int defStyle) {
    super.init(context, attrs, defStyle);
    mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
    mGestureListener = getGestureListener();
    mScaleListener = getScaleListener();
    mScaleDetector = new ScaleGestureDetector(getContext(), mScaleListener);
    mGestureDetector = new GestureDetector(getContext(), mGestureListener, null, true);
    mDoubleTapDirection = 1;
    setQuickScaleEnabled(false);
}
Also used : GestureDetector(android.view.GestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector) ScaleGestureDetector(android.view.ScaleGestureDetector)

Example 98 with GestureDetector

use of android.view.GestureDetector in project MaterialLibrary by DeveloperPaul123.

the class MaterialFloatingActionButtonMenu method init.

/**
     * Initialize the view and fields.
     * @param context the context of this view.
     * @param attrs the attribute set of this view.
     */
private void init(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialFloatingActionButtonMenu);
    circleColor = a.getColor(R.styleable.MaterialFloatingActionButtonMenu_mat_fab_menu_color, getColor(android.R.color.holo_blue_dark));
    mShowAllChildren = a.getBoolean(R.styleable.MaterialFloatingActionButtonMenu_mat_fab_menu_showChildrenAlways, false);
    circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    buttonColor = getColor(android.R.color.holo_blue_dark);
    circlePaint.setStyle(Paint.Style.FILL);
    circlePaint.setColor(circleColor);
    menuRadius = 1f;
    circleShowAnimator = ObjectAnimator.ofFloat(this, "menuRadius", maxRadius);
    circleCloseAnimator = ObjectAnimator.ofFloat(this, "menuRadius", 1.0f);
    degreeOffsetAnimator = ObjectAnimator.ofFloat(this, "degreeOffset", 0.0f);
    OvershootInterpolator interpolator = new OvershootInterpolator();
    mExpandAnimation = new AnimatorSet().setDuration(150);
    mExpandAnimation.setInterpolator(interpolator);
    mExpandAnimation.addListener(expandMenuListener);
    mCollapseAnimation = new AnimatorSet().setDuration(100);
    mCollapseAnimation.addListener(collapseMenuListener);
    showButtonsSet = new AnimatorSet().setDuration(100);
    showButtonsSet.setInterpolator(interpolator);
    showButtonsSet.addListener(showButtonsListener);
    hideButtonsSet = new AnimatorSet().setDuration(50);
    hideButtonsSet.addListener(hideButtonsListener);
    setWillNotDraw(false);
    setClickable(false);
    setLongClickable(false);
    createAddButton(context);
    interceptDownEvents[0] = 0.0f;
    interceptDownEvents[1] = 0.0f;
    lastEventPoints[0] = 0.0f;
    lastEventPoints[1] = 0.0f;
    ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mSlop = configuration.getScaledTouchSlop();
    minFlingVel = configuration.getScaledMinimumFlingVelocity();
    maxFlingVel = configuration.getScaledMaximumFlingVelocity();
    startAngle = 225f;
    collapseOnChildClick = true;
    expands = new ArrayList<>();
    collapses = new ArrayList<>();
    DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
    windowWidth = metrics.widthPixels;
    windowHeight = metrics.heightPixels;
    gestureDetector = new GestureDetector(getContext(), new GestureListener());
    mScroller = new Scroller(context, new AccelerateDecelerateInterpolator(), true);
}
Also used : ViewConfiguration(android.view.ViewConfiguration) OvershootInterpolator(android.view.animation.OvershootInterpolator) TypedArray(android.content.res.TypedArray) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) AnimatorSet(android.animation.AnimatorSet) GestureDetector(android.view.GestureDetector) Paint(android.graphics.Paint) Scroller(android.widget.Scroller) DisplayMetrics(android.util.DisplayMetrics)

Example 99 with GestureDetector

use of android.view.GestureDetector in project enroscar by stanfy.

the class LoadableImageSwitcher method init.

private void init(final Context context) {
    super.setFactory(this);
    gestureDetector = new GestureDetector(context, this);
    gestureDetector.setIsLongpressEnabled(true);
}
Also used : GestureDetector(android.view.GestureDetector)

Example 100 with GestureDetector

use of android.view.GestureDetector in project Shuttle by timusus.

the class ArtworkFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_artwork, container, false);
    GestureDetector gestureDetector = new GestureDetector(this.getActivity(), new GestureListener(this));
    imageView = (ImageView) rootView.findViewById(R.id.image);
    imageView.setOnTouchListener((view, motionEvent) -> gestureDetector.onTouchEvent(motionEvent));
    updateArtwork();
    return rootView;
}
Also used : GestureDetector(android.view.GestureDetector) ImageView(android.widget.ImageView) View(android.view.View)

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