當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleOnGestureListener類代碼示例

本文整理匯總了Java中android.view.GestureDetector.SimpleOnGestureListener的典型用法代碼示例。如果您正苦於以下問題:Java SimpleOnGestureListener類的具體用法?Java SimpleOnGestureListener怎麽用?Java SimpleOnGestureListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SimpleOnGestureListener類屬於android.view.GestureDetector包,在下文中一共展示了SimpleOnGestureListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ClipZoomImageView

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
public ClipZoomImageView(Context context, AttributeSet attrs) {
	super(context, attrs);

	setScaleType(ScaleType.MATRIX);
	mGestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
		@Override
		public boolean onDoubleTap(MotionEvent e) {
			if (isAutoScale == true)
				return true;

			float x = e.getX();
			float y = e.getY();
			if (getScale() < SCALE_MID) {
				ClipZoomImageView.this.postDelayed(new AutoScaleRunnable(SCALE_MID, x, y), 16);
				isAutoScale = true;
			} else {
				ClipZoomImageView.this.postDelayed(new AutoScaleRunnable(initScale, x, y), 16);
				isAutoScale = true;
			}

			return true;
		}
	});
	mScaleGestureDetector = new ScaleGestureDetector(context, this);
	this.setOnTouchListener(this);
}
 
開發者ID:lingganhezi,項目名稱:dedecmsapp,代碼行數:27,代碼來源:ClipZoomImageView.java

示例2: ZoomImageView

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
public ZoomImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    setScaleType(ScaleType.MATRIX);
    mGestureDetector = new GestureDetector(context,
            new SimpleOnGestureListener() {
                @Override
                public boolean onDoubleTap(MotionEvent e) {
                    if (isAutoScale)
                        return true;
                    float x = e.getX();
                    float y = e.getY();
                    if (getScale() < SCALE_MID) {
                        postDelayed(new ScaleRunnable(SCALE_MID, x, y), 16);
                        isAutoScale = true;
                    } else {
                        postDelayed(new ScaleRunnable(mScale, x, y), 16);
                        isAutoScale = true;
                    }
                    return true;
                }
            });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    this.setOnTouchListener(this);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:25,代碼來源:ZoomImageView.java

示例3: init

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
public void init() {
	mGestureListener = new SimpleOnGestureListener() {
		@Override
		public boolean onDown(MotionEvent e) {
			isFling = false;
			return true;
		}

		@Override
		public boolean onFling(MotionEvent e1, MotionEvent e2,
							   float velocityX, float velocityY) {

			if (velocityX > mViewConfiguration.getScaledMinimumFlingVelocity() || velocityY > mViewConfiguration.getScaledMinimumFlingVelocity())
				isFling = true;
			return isFling;
		}
	};
	mGestureDetector = new GestureDetectorCompat(getContext(),
			mGestureListener);

	mCloseScroller = ScrollerCompat.create(getContext());
	mOpenScroller = ScrollerCompat.create(getContext());
}
 
開發者ID:PhongHuynh93,項目名稱:SwipeMenuRecyclerView-master,代碼行數:24,代碼來源:SwipeMenuLayout.java

示例4: WheelScroller

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
/**
 * Constructor
 * @param context the current context
 * @param listener the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            // Do scrolling in onTouchEvent() since onScroll() are not call immediately
            //  when user touch and move the spinnerwheel
            return true;
        }

        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            lastScrollPosition = 0;
            scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
            setNextMessage(MESSAGE_SCROLL);
            return true;
        }

        // public boolean onDown(MotionEvent motionEvent);

    });
    gestureDetector.setIsLongpressEnabled(false);
    
    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
 
開發者ID:vondear,項目名稱:RxTools,代碼行數:31,代碼來源:WheelScroller.java

示例5: ZoomImageView

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
public ZoomImageView(Context context, AttributeSet attrs) {
	super(context, attrs);
	setScaleType(ScaleType.MATRIX);//用矩陣來繪製
	mGestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
		@Override
		public boolean onDoubleTap(MotionEvent e) {//雙擊時
			if (isAutoScale == true) return true;
			float x = e.getX();
			float y = e.getY();
			Log.i(TAG, "雙擊onDoubleTap," + "縮放比例:" + getScale() + " , " + initScale);
			if (getScale() < SCALE_MID) postDelayed(new AutoScaleRunnable(SCALE_MID, x, y), 10);
			else if (getScale() >= SCALE_MID && getScale() < SCALE_MAX) postDelayed(new AutoScaleRunnable(SCALE_MAX, x, y), 10);
			else postDelayed(new AutoScaleRunnable(initScale, x, y), 10);

			isAutoScale = true;

			return true;
		}
	});
	mScaleGestureDetector = new ScaleGestureDetector(context, this);
	this.setOnTouchListener(this);
}
 
開發者ID:baiqiantao,項目名稱:GestureDetectorTest,代碼行數:23,代碼來源:ZoomImageView.java

示例6: ClipRectZoomImageView

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
public ClipRectZoomImageView(Context context, AttributeSet attrs) {
	super(context, attrs);

	setScaleType(ScaleType.MATRIX);
	mGestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
		@Override
		public boolean onDoubleTap(MotionEvent e) {
			if (isAutoScale == true)
				return true;

			float x = e.getX();
			float y = e.getY();
			if (getScale() < SCALE_MID) {
				ClipRectZoomImageView.this.postDelayed(new AutoScaleRunnable(SCALE_MID, x, y), 16);
				isAutoScale = true;
			} else {
				ClipRectZoomImageView.this.postDelayed(new AutoScaleRunnable(initScale, x, y), 16);
				isAutoScale = true;
			}

			return true;
		}
	});
	mScaleGestureDetector = new ScaleGestureDetector(context, this);
	this.setOnTouchListener(this);
}
 
開發者ID:lingganhezi,項目名稱:dedecmsapp,代碼行數:27,代碼來源:ClipRectZoomImageView.java

示例7: onDoubleTap

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
/**
 * Register listener on double-tap gesture for view
 *
 * @param view
 * @param listener
 * @return view
 */
public static View onDoubleTap(final View view,
    final OnDoubleTapListener listener) {
  final GestureDetector detector = new GestureDetector(view.getContext(),
      new SimpleOnGestureListener());
  detector.setOnDoubleTapListener(listener);
  view.setOnTouchListener(new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
      return detector.onTouchEvent(event);
    }
  });

  return view;
}
 
開發者ID:markzhai,項目名稱:GitHubExplorer,代碼行數:23,代碼來源:Gestures.java

示例8: DragLayout

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
public DragLayout(Context context, AttributeSet attrs, int defStyleAttr) {
                super(context, attrs, defStyleAttr);
                mGestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
                        @Override
                        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
//                                如果水平方向的偏移量大於豎直方向的偏移量,就消化該事件,
                                return Math.abs(distanceX) > Math.abs(distanceY) || super.onScroll(e1, e2, distanceX, distanceY);

                        }
                });
//                永遠要記得,該工具實現的拖拉是基於控件位置的改變來實現的
                mViewDragHelper = ViewDragHelper.create(this, new DragViewCallBack());
        }
 
開發者ID:HelloChenJinJun,項目名稱:TestChat,代碼行數:14,代碼來源:DragLayout.java

示例9: ZoomImageView

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
public ZoomImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
        super.setScaleType(ScaleType.MATRIX);
        mGestureDetector = new GestureDetector(context,
                new SimpleOnGestureListener() {
                        @Override
                        public boolean onDoubleTap(MotionEvent e) {
                                if (isAutoScale)
                                        return true;

                                float x = e.getX();
                                float y = e.getY();
                                Log.e("DoubleTap", getScale() + " , " + initScale);
                                if (getScale() < SCALE_MID) {
                                        ZoomImageView.this.postDelayed(
                                                new AutoScaleRunnable(SCALE_MID, x, y), 16);
                                        isAutoScale = true;
                                } else if (getScale() >= SCALE_MID
                                        && getScale() < SCALE_MAX) {
                                        ZoomImageView.this.postDelayed(
                                                new AutoScaleRunnable(SCALE_MAX, x, y), 16);
                                        isAutoScale = true;
                                } else {
                                        ZoomImageView.this.postDelayed(
                                                new AutoScaleRunnable(initScale, x, y), 16);
                                        isAutoScale = true;
                                }

                                return true;
                        }
                });
        mScaleGestureDetector = new ScaleGestureDetector(context, this);
        this.setOnTouchListener(this);
}
 
開發者ID:HelloChenJinJun,項目名稱:TestChat,代碼行數:35,代碼來源:ZoomImageView.java

示例10: ClipZoomImageView

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
public ClipZoomImageView(Context context, AttributeSet attrs) {
    super(context, attrs);

    setScaleType(ScaleType.MATRIX);
    mGestureDetector = new GestureDetector(context,
            new SimpleOnGestureListener() {
                @Override
                public boolean onDoubleTap(MotionEvent e) {
                    if (isAutoScale == true)
                        return true;

                    float x = e.getX();
                    float y = e.getY();
                    if (getScale() < SCALE_MID) {
                        ClipZoomImageView.this.postDelayed(
                                new AutoScaleRunnable(SCALE_MID, x, y), 16);
                        isAutoScale = true;
                    } else {
                        ClipZoomImageView.this.postDelayed(
                                new AutoScaleRunnable(initScale, x, y), 16);
                        isAutoScale = true;
                    }

                    return true;
                }
            });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    setOnTouchListener(this);
}
 
開發者ID:jacklongway,項目名稱:LiteSDK,代碼行數:30,代碼來源:ClipZoomImageView.java

示例11: WheelScroller

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
/**
 * Constructor
 * 
 * @param context
 *            the current context
 * @param listener
 *            the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
	gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
		public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
			// Do scrolling in onTouchEvent() since onScroll() are not call
			// immediately
			// when user touch and move the spinnerwheel
			return true;
		}

		public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
			lastScrollPosition = 0;
			scrollerFling(lastScrollPosition, (int) velocityX, (int) velocityY);
			setNextMessage(MESSAGE_SCROLL);
			return true;
		}

		// public boolean onDown(MotionEvent motionEvent);

	});
	gestureDetector.setIsLongpressEnabled(false);

	scroller = new Scroller(context);

	this.listener = listener;
	this.context = context;
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:35,代碼來源:WheelScroller.java

示例12: startDelayConfirmation

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
public void startDelayConfirmation(long delay, DelayedConfirmationListener listener) {
    stopDelayConfirmation();

    setProgressMode(CircularProgressDrawable.MODE_DETERMINATE);
    setProgressPercent(0);
    setShowProgress(true);

    setClickable(true);

    mDelayedConfirmationListener = listener;
    mDelayedConfirmationAnimator = ValueAnimator.ofFloat(0, 1).setDuration(delay);
    mDelayedConfirmationAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float progress = (float) animation.getAnimatedValue();
            if (getProgressDrawable() != null) {
                getProgressDrawable().setProgress(progress);
            } else {
                stopDelayConfirmation();
            }
            if (progress >= 1) {
                finishDelayConfirmation(false);
            }
        }
    });
    mDelayedConfirmationAnimator.start();

    if (mGestureDetector == null) {
        mGestureDetector = new GestureDetector(getContext(), new SimpleOnGestureListener() {
            @Override
            public boolean onSingleTapConfirmed(MotionEvent e) {
                finishDelayConfirmation(true);
                return super.onSingleTapConfirmed(e);
            }
        });
    }
}
 
開發者ID:mobvoi,項目名稱:ticdesign,代碼行數:38,代碼來源:FloatingActionButton.java

示例13: SwipableOverlayView

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
/**
 * Creates a SwipableOverlayView.
 * @param context Context for acquiring resources.
 * @param attrs Attributes from the XML layout inflation.
 */
public SwipableOverlayView(Context context, AttributeSet attrs) {
    super(context, attrs);
    SimpleOnGestureListener gestureListener = createGestureListener();
    mGestureDetector = new GestureDetector(context, gestureListener);
    mGestureStateListener = createGestureStateListener();
    mGestureState = GESTURE_NONE;
    mLayoutChangeListener = createLayoutChangeListener();
    mAnimatorListenerAdapter = createAnimatorListenerAdapter();
    mInterpolator = new DecelerateInterpolator(1.0f);
    mTabObserver = createTabObserver();

    // We make this view 'draw' to provide a placeholder for its animations.
    setWillNotDraw(false);
}
 
開發者ID:Smalinuxer,項目名稱:Vafrinn,代碼行數:20,代碼來源:SwipableOverlayView.java

示例14: RecyclerItemClickListener

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
public RecyclerItemClickListener(Context context, OnItemClickListener onItemClickListener) {
	listener = onItemClickListener;

	gestureDetector = new GestureDetector(context, new SimpleOnGestureListener() {
		@Override
		public boolean onSingleTapUp(MotionEvent e) {
			return true;
		}
	});
}
 
開發者ID:punchup,項目名稱:Superuser-UI,代碼行數:11,代碼來源:RecyclerItemClickListener.java

示例15: ZoomCropImageView

import android.view.GestureDetector.SimpleOnGestureListener; //導入依賴的package包/類
@SuppressLint("ClickableViewAccessibility")
public ZoomCropImageView(Context context, AttributeSet attrs, int defStyle) {
	super(context, attrs, defStyle);
	setScaleType(ScaleType.MATRIX);
	mGestureDetector = new GestureDetector(context,
			new SimpleOnGestureListener() {
				@Override
				public boolean onDoubleTap(MotionEvent e) {
					if (isAutoScale == true)
						return true;

					float x = e.getX();
					float y = e.getY();
					if (getScale() < initScale) {
						ZoomCropImageView.this.postDelayed(
								new AutoScaleRunnable(mScaleMax, x, y), 16);
						isAutoScale = true;
					} else {
						ZoomCropImageView.this.postDelayed(
								new AutoScaleRunnable(mScaleMin, x, y), 16);
						isAutoScale = true;
					}

					return true;
				}
			});
	mScaleGestureDetector = new ScaleGestureDetector(context, this);
	this.setOnTouchListener(this);
}
 
開發者ID:CrazyOrr,項目名稱:ZoomCropImage,代碼行數:30,代碼來源:ZoomCropImageView.java


注:本文中的android.view.GestureDetector.SimpleOnGestureListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。