use of android.view.GestureDetector in project frostwire by frostwire.
the class TouchImageView method sharedConstructing.
private void sharedConstructing(Context context) {
super.setClickable(true);
this.context = context;
mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
mGestureDetector = new GestureDetector(context, new GestureListener());
matrix = new Matrix();
prevMatrix = new Matrix();
m = new float[9];
normalizedScale = 1;
if (mScaleType == null) {
mScaleType = ScaleType.FIT_CENTER;
}
minScale = 1;
maxScale = 3;
superMinScale = SUPER_MIN_MULTIPLIER * minScale;
superMaxScale = SUPER_MAX_MULTIPLIER * maxScale;
setImageMatrix(matrix);
setScaleType(ScaleType.MATRIX);
setState(State.NONE);
onDrawReady = false;
super.setOnTouchListener(new PrivateOnTouchListener());
}
use of android.view.GestureDetector in project apps-android-wikipedia by wikimedia.
the class ZoomableDraweeView method init.
private void init() {
mZoomableController = createZoomableController();
mZoomableController.setListener(mZoomableListener);
mTapGestureDetector = new GestureDetector(getContext(), mTapListenerWrapper);
}
use of android.view.GestureDetector in project yoo_home_Android by culturer.
the class SkyWheel method init.
private void init() {
mDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDown(MotionEvent e) {
if (mAnimator != null && mAnimator.isRunning()) {
mAnimator.cancel();
}
return false;
}
/**
* 手指点击一次的时候调用一次
* @param e
* @return
*/
@Override
public boolean onSingleTapUp(MotionEvent e) {
// 点击时,判断当前点是否被某个子控件包含,如果包含直接调用子控件的点击事件即可
int index = getClickPosition(e);
if (index > -1) {
// 强制让当前的控件的点击事件执行
getChildAt(index).performClick();
}
return false;
}
/**
* @param e1 按下事件 action—_down
* @param e2 move事件,最近一次的action_move
* @param distanceX = 上一次move事件的x值 - 当前move事件的x值
* @param distanceY = 上一次move事件的y值 - 当前move事件的y值
* @return
*/
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
// 计算出手指滑动过程中的角度变化夹角
// 计算出起始点的角度
double startDegree = getDegree(e2.getX() + distanceX, e2.getY() + distanceX);
// 计算出结束点的角度
double endDegree = getDegree(e2.getX(), e2.getY());
// 计算出夹角
double diff = endDegree - startDegree;
setDegree(diffDegree + diff);
return false;
}
/**
* @param e1 手指按下的事件
* @param e2 手指移动的事件
* @param velocityX 手指离开屏幕时,在x轴的速率(像素/s)
* @param velocityY 手指离开屏幕时,在y轴的速率(像素/s)
* @return
*/
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
// 计算当前点的角度
double startDegree = getDegree(e2.getX(), e2.getY());
// 计算1ms后的角度
double endDegreeAfter1ms = getDegree(e2.getX() + velocityX / 1000, e2.getY() + velocityY / 1000);
// 计算出1ms的角速度
double velocityAfter1ms = endDegreeAfter1ms - startDegree;
// 计算出1s的角速度
double velocityAfter1s = velocityAfter1ms * 1000;
// 通过角速度设置,要移动到的角度
startFlingAnimation(velocityAfter1s);
return false;
}
});
}
use of android.view.GestureDetector in project android_frameworks_base by crdroidandroid.
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;
}
});
}
use of android.view.GestureDetector in project android_frameworks_base by crdroidandroid.
the class SystemGesturesPointerEventListener method systemReady.
public void systemReady() {
Handler h = new Handler(Looper.myLooper());
mGestureDetector = new GestureDetector(mContext, new FlingGestureDetector(), h);
mOverscroller = new OverScroller(mContext);
}
Aggregations