Search in sources :

Example 81 with GestureDetector

use of android.view.GestureDetector in project material by rey5137.

the class BottomSheetDialog method init.

private void init(Context context, int style) {
    mContainer = new ContainerFrameLayout(context);
    cancelable(true);
    canceledOnTouchOutside(true);
    onCreate();
    applyStyle(style);
    mMinFlingVelocity = ViewConfiguration.get(context).getScaledMinimumFlingVelocity() * 2;
    mGestureDetector = new GestureDetector(context, new GestureDetector.OnGestureListener() {

        @Override
        public boolean onDown(MotionEvent e) {
            return false;
        }

        @Override
        public void onShowPress(MotionEvent e) {
        }

        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            return false;
        }

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            return false;
        }

        @Override
        public void onLongPress(MotionEvent e) {
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            if (velocityY > mMinFlingVelocity) {
                dismiss();
                return true;
            }
            return false;
        }
    });
    super.setContentView(mContainer);
}
Also used : GestureDetector(android.view.GestureDetector) MotionEvent(android.view.MotionEvent)

Example 82 with GestureDetector

use of android.view.GestureDetector in project weiciyuan by qii.

the class SwipeFrameLayout method init.

private void init() {
    scroller = new OverScroller(getContext(), new DecelerateInterpolator());
    setBackground(ThemeUtility.getDrawable(android.R.attr.windowBackground));
    this.activity = (Activity) getContext();
    this.topView = ((View) (activity.findViewById(android.R.id.content).getParent()));
    this.max_motion_event_down_x_position = Utility.dip2px(25);
    this.gestureDetector = new GestureDetector(getContext(), new SwipeRightToCloseOnGestureListener());
    this.setId(R.id.swipe_framelayout);
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) GestureDetector(android.view.GestureDetector) View(android.view.View) OverScroller(android.widget.OverScroller)

Example 83 with GestureDetector

use of android.view.GestureDetector in project Float-Bar by tianzhijiexian.

the class FloatService method createFloatView.

////////////////////////////////////////////////////////////////////////////
private void createFloatView() {
    wmParams = Util.getParams(wmParams);
    // 悬浮窗默认显示以左上角为起始坐标
    wmParams.gravity = Gravity.RIGHT | Gravity.TOP;
    if (!prefs.isRightMode()) {
        wmParams.gravity = Gravity.LEFT | Gravity.TOP;
    }
    // 以屏幕右上角为原点,设置x、y初始值,确定显示窗口的起始位置
    wmParams.x = 0;
    wmParams.y = 0;
    mWindowManager = (WindowManager) service.getSystemService(Context.WINDOW_SERVICE);
    LayoutInflater inflater = LayoutInflater.from(service);
    // 获取浮动窗口视图所在布局
    mFloatLayout = (LinearLayout) inflater.inflate(R.layout.floating, null);
    // 添加悬浮窗的视图
    mWindowManager.addView(mFloatLayout, wmParams);
    /**
		 * 设置悬浮窗的点击、滑动事件
		 */
    sampleFloat = (ImageButton) mFloatLayout.findViewById(R.id.float_button_id);
    sampleFloat.getBackground().setAlpha(150);
    sampleFloat.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            prefs.doTouch(service);
        }
    });
    /**
		 * 设置有无反馈
		 */
    MyOnGestureListener listener = new MyOnGestureListener();
    @SuppressWarnings("deprecation") final GestureDetector mGestureDetector = new GestureDetector(listener);
    sampleFloat.setOnTouchListener(new MyOnTouchListener(mGestureDetector));
}
Also used : LayoutInflater(android.view.LayoutInflater) OnClickListener(android.view.View.OnClickListener) GestureDetector(android.view.GestureDetector) View(android.view.View)

Example 84 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)

Example 85 with GestureDetector

use of android.view.GestureDetector in project DropListView by ufo22940268.

the class DropView method init.

private void init(AttributeSet attrs, int defStyle) {
    mColor = getResources().getColor(R.color.drop_view_color);
    mGestureDetector = new GestureDetector(getContext(), mGestureListener);
    mMaxRadius1 = dpToPx(25);
    mRadius1 = mMaxRadius1;
    mMinRadius1 = mRadius1 * MIN_RADIUS1_FACTOR;
    mRadius2 = mRadius1;
    mMinRadius2 = (float) (mRadius2 * MIN_RADIUS2_FACTOR);
    mTopPadding = dpToPx(15);
    mPullThreshold = dpToPx(100);
    mBzrOffset = dpToPx(10);
    mLoadingView = new ProgressBar(getContext());
    mLoadingView.setIndeterminate(true);
    int size = mRadius1 * 2 + dpToPx(5);
    LayoutParams params = new LayoutParams(size, size);
    params.topMargin = mTopPadding - dpToPx(5);
    params.gravity = Gravity.CENTER_HORIZONTAL;
    mLoadingView.setLayoutParams(params);
    mIconBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_refresh_white_48dp);
    /**
         * Adjust loading view position to fit drop view.
         */
    mLoadingView.setPadding(0, 0, dpToPx(15), 0);
    addView(mLoadingView);
    enableLoading(false);
}
Also used : GestureDetector(android.view.GestureDetector) ProgressBar(android.widget.ProgressBar) Point(android.graphics.Point) Paint(android.graphics.Paint)

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