Search in sources :

Example 76 with GestureDetector

use of android.view.GestureDetector in project muzei by romannurik.

the class FullScreenActivity method onCreate.

public void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    setContentView(R.layout.full_screen_activity);
    FirebaseAnalytics.getInstance(this).setUserProperty("device_type", BuildConfig.DEVICE_TYPE);
    mPanView = (PanView) findViewById(R.id.pan_view);
    getLoaderManager().initLoader(0, null, this);
    mScrimView = findViewById(R.id.scrim);
    mLoadingIndicatorView = findViewById(R.id.loading_indicator);
    mHandler.postDelayed(mShowLoadingIndicatorRunnable, 500);
    mMetadataContainerView = findViewById(R.id.metadata_container);
    mTitleView = (TextView) findViewById(R.id.title);
    mBylineView = (TextView) findViewById(R.id.byline);
    Typeface tf = TypefaceUtil.getAndCache(this, "Alegreya-BlackItalic.ttf");
    mTitleView = (TextView) findViewById(R.id.title);
    mTitleView.setTypeface(tf);
    tf = TypefaceUtil.getAndCache(this, "Alegreya-Italic.ttf");
    mBylineView = (TextView) findViewById(R.id.byline);
    mBylineView.setTypeface(tf);
    mDismissOverlay = (DismissOverlayView) findViewById(R.id.dismiss_overlay);
    // Only show the dismiss overlay on Wear 1.0 devices
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
        mDismissOverlay.setIntroText(R.string.dismiss_overlay_intro);
        mDismissOverlay.showIntroIfNecessary();
    }
    mDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (mDismissOverlay.getVisibility() == View.VISIBLE) {
                return false;
            }
            if (mMetadataVisible) {
                setMetadataVisible(false);
            } else {
                setMetadataVisible(true);
            }
            return true;
        }

        @Override
        public void onLongPress(MotionEvent ev) {
            if (mDismissOverlay.getVisibility() == View.VISIBLE) {
                return;
            }
            // Only show the dismiss overlay on Wear 1.0 devices
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
                mDismissOverlay.show();
            }
        }
    });
}
Also used : Typeface(android.graphics.Typeface) GestureDetector(android.view.GestureDetector) MotionEvent(android.view.MotionEvent)

Example 77 with GestureDetector

use of android.view.GestureDetector in project FoldableLayout by alexvasilkov.

the class FoldableListLayout method init.

private void init(Context context) {
    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {

        @Override
        public boolean onDown(MotionEvent event) {
            return FoldableListLayout.this.onDown();
        }

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distX, float distY) {
            return FoldableListLayout.this.onScroll(e1, e2);
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velX, float velY) {
            return FoldableListLayout.this.onFling(velY);
        }
    });
    gestureDetector.setIsLongpressEnabled(false);
    animator = ObjectAnimator.ofFloat(this, "foldRotation", 0f);
    minDistanceBeforeScroll = ViewConfiguration.get(context).getScaledTouchSlop();
    flingAnimation = new FlingAnimation();
    foldShading = new SimpleFoldShading();
    setChildrenDrawingOrderEnabled(true);
}
Also used : SimpleOnGestureListener(android.view.GestureDetector.SimpleOnGestureListener) SimpleFoldShading(com.alexvasilkov.foldablelayout.shading.SimpleFoldShading) GestureDetector(android.view.GestureDetector) MotionEvent(android.view.MotionEvent)

Example 78 with GestureDetector

use of android.view.GestureDetector in project platform_frameworks_base by android.

the class Gallery method onAttachedToWindow.

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    if (mGestureDetector == null) {
        mGestureDetector = new GestureDetector(getContext(), this);
        mGestureDetector.setIsLongpressEnabled(true);
    }
}
Also used : GestureDetector(android.view.GestureDetector)

Example 79 with GestureDetector

use of android.view.GestureDetector in project CircularReveal by ozodrukh.

the class RadialTransformationActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample_2);
    ButterKnife.bind(this);
    Picasso.with(this).load("http://camp-campbell.com/wp-content/uploads/2014/09/847187872-san-francisco.jpg").resizeDimen(R.dimen.radial_card_width, R.dimen.radial_card_height).centerCrop().into(sanFranciscoView);
    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

        @Override
        public void onPrepared(MediaPlayer mp) {
            mp.setLooping(true);
        }
    });
    videoView.setVideoURI(Uri.parse(VIDEO_URL));
    videoView.start();
    final GestureDetector detector = new GestureDetector(this, tapDetector);
    for (int i = 0; i < stack.getChildCount(); i++) {
        View view = stack.getChildAt(i);
        view.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return detector.onTouchEvent(event);
            }
        });
    }
    final ViewRevealManager revealManager = new ViewRevealManager();
    final SpringViewAnimatorManager springManager = new SpringViewAnimatorManager();
    springManager.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY);
    springManager.setStiffness(SpringForce.STIFFNESS_LOW);
    stack.setViewRevealManager(revealManager);
    settingsView.addSwitch("Enable Spring", false, new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            stack.setViewRevealManager(isChecked ? springManager : revealManager);
        }
    });
    settingsView.setAnimatorManager(springManager);
    final BottomSheetBehavior behavior = BottomSheetBehavior.from(settingsView);
    behavior.setPeekHeight(getResources().getDimensionPixelSize(R.dimen.bottom_peek_height));
    behavior.setSkipCollapsed(false);
    behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
Also used : GestureDetector(android.view.GestureDetector) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) VideoView(android.widget.VideoView) Point(android.graphics.Point) MotionEvent(android.view.MotionEvent) BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) ViewRevealManager(io.codetail.animation.ViewRevealManager) SpringViewAnimatorManager(io.codetail.animation.SpringViewAnimatorManager) CompoundButton(android.widget.CompoundButton) MediaPlayer(android.media.MediaPlayer)

Example 80 with GestureDetector

use of android.view.GestureDetector in project android-common by Trinea.

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)

Aggregations

GestureDetector (android.view.GestureDetector)133 MotionEvent (android.view.MotionEvent)46 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