@Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { if (recyclerView == null) { this.recyclerView = rv; this.baseQuickAdapter = (BaseQuickAdapter) recyclerView.getAdapter(); mGestureDetector = new GestureDetectorCompat(recyclerView.getContext(), new ItemTouchHelperGestureListener(recyclerView)); } if (!mGestureDetector.onTouchEvent(e) && e.getActionMasked() == MotionEvent.ACTION_UP && mIsShowPress) { if (mPressedView!=null){ mPressedView.setPressed(false); mPressedView = null; } mIsShowPress = false; mIsPrepressed = false; } return false; }
public DragLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.app, 0, 0); bottomDragVisibleHeight = (int) a.getDimension(R.styleable.app_bottomDragVisibleHeight, 0); bototmExtraIndicatorHeight = (int) a.getDimension(R.styleable.app_bototmExtraIndicatorHeight, 0); a.recycle(); mDragHelper = ViewDragHelper .create(this, 10f, new DragHelperCallback()); mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_TOP); moveDetector = new GestureDetectorCompat(context, new MoveDetector()); moveDetector.setIsLongpressEnabled(false); // 不处理长按事件 // 滑动的距离阈值由系统提供 ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); }
public Attacher(DraweeView<GenericDraweeHierarchy> draweeView) { mDraweeView = new WeakReference<>(draweeView); draweeView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER); draweeView.setOnTouchListener(this); mScaleDragDetector = new ScaleDragDetector(draweeView.getContext(), this); mGestureDetector = new GestureDetectorCompat(draweeView.getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public void onLongPress(MotionEvent e) { super.onLongPress(e); if (null != mLongClickListener) { mLongClickListener.onLongClick(getDraweeView()); } } }); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); }
private void init(Context context, AttributeSet attrs) { //获取相关属性设置 TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlideLayout); mAlphaColor = ta.getColor(R.styleable.SlideLayout_sl_anim_alpha_color, DEF_ANIM_ALPHA_COLOR); mEdgeEnable = ta.getBoolean(R.styleable.SlideLayout_sl_edge_enable, DEF_EDGE_ENABLE); mMainAlphaEnable = ta.getBoolean(R.styleable.SlideLayout_sl_main_alpha_enable, DEF_MAIN_ALPHA_ENABLE); ta.recycle(); //初始化ViewDragHelper相关 mCallback = new DragCallback(); mDragHelper = ViewDragHelper.create(this, DEF_SENSITIVITY, mCallback); if (mEdgeEnable) { //设置边缘滑动检测 mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT); //设置最小滑动速度 mDragHelper.setMinVelocity(DEF_SENSITIVITY * DEF_MIN_FLING_VELOCITY); } //初始化屏幕触控处理相关 mGestureListener = new GestureListener(); mGestureDetector = new GestureDetectorCompat(context, mGestureListener); //设置初始状态为关闭 mStatus = Status.CLOSED; }
/** * Constructor with arguments. It receives a * Context used to get the resources. * * @param context - the context used to get the resources. * @param attrs - attribute set with custom styles. */ public CalendarView(Context context, AttributeSet attrs) { super(context, attrs); mContext = context; //Initialize the gesture listener needed.. mGestureDetector = new GestureDetectorCompat(context, new CalendarGestureDetector()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CUPCAKE) { if (isInEditMode()) { return; } } getAttributes(attrs); init(); }
public DraggableSquareView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mDragHelper = ViewDragHelper .create(this, 10f, new DragHelperCallback()); moveDetector = new GestureDetectorCompat(context, new MoveDetector()); moveDetector.setIsLongpressEnabled(false); // 不能处理长按事件,否则违背最初设计的初衷 spaceInterval = (int) getResources().getDimension(R.dimen.drag_square_interval); // 小方块之间的间隔 // 滑动的距离阈值由系统提供 ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); anchorHandler = new Handler() { @Override public void handleMessage(Message msg) { if (draggingView != null) { // 开始移动重心的动画 draggingView.startAnchorAnimation(); } } }; }
public Window(Context context) { super(context); this.setFocusable(true); this.setFocusableInTouchMode(true); //used for checking the total size needed for all the bubble to be reachable but not being able to go for miles //without any stops totalscreensize.put("up",0); totalscreensize.put("down",0); totalscreensize.put("right",0); totalscreensize.put("left",0); currentmessage=""; mDetector=new GestureDetectorCompat(getContext(),this); WindowManager wm =(WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display dis = wm.getDefaultDisplay(); Point pt = new Point(); dis.getSize(pt); Center = new Point(pt.x/centerX,pt.y/centerY); }
/** * Constructs a new PendingDrag that, if accepted by the DragHandler, begins with the * {@code actionDown} event. * * @param controller The activity's {@link BlocklyController}. * @param touchedView The initial touched {@link BlockView} of the drag. * @param actionDown The first {@link MotionEvent#ACTION_DOWN} event. */ PendingDrag(@NonNull BlocklyController controller, @NonNull BlockView touchedView, @NonNull MotionEvent actionDown) { if (actionDown.getAction() != MotionEvent.ACTION_DOWN) { throw new IllegalArgumentException(); } mController = controller; mHelper = controller.getWorkspaceHelper(); mLatestEventTime = actionDown.getEventTime(); mTouchedView = touchedView; mPointerId = actionDown.getPointerId(actionDown.getActionIndex()); int pointerIdx = actionDown.findPointerIndex(mPointerId); mTouchDownBlockX = (int) actionDown.getX(pointerIdx); mTouchDownBlockY = (int) actionDown.getY(pointerIdx); touchedView.getTouchLocationOnScreen(actionDown, mTouchDownScreen); mHelper.screenToWorkspaceCoordinates(mTouchDownScreen, mTouchDownWorkspace); mGestureDetector = new GestureDetectorCompat(mController.getContext(), new GestureListener()); mGestureDetector.onTouchEvent(actionDown); }
private void prepare(AttributeSet attrs) { setFocusable(true); setDescendantFocusability(FOCUS_AFTER_DESCENDANTS); setWillNotDraw(false); mScroller = new Scroller(getContext()); mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleListener); mGestureDetector = new GestureDetectorCompat(getContext(), mGestureListener); if (attrs != null) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CustomViewExtension, 0, 0); autoScrollMargins = a.getDimensionPixelSize(R.styleable.CustomViewExtension_autoScrollMargins, 0); a.recycle(); } mEdgeGlowLeft = new EdgeEffectCompat(getContext()); mEdgeGlowTop = new EdgeEffectCompat(getContext()); mEdgeGlowRight = new EdgeEffectCompat(getContext()); mEdgeGlowBottom = new EdgeEffectCompat(getContext()); setWillNotDraw(false); }
public CropView(Context context, AttributeSet attrs) { super(context, attrs); mDetectorCompat = new GestureDetectorCompat(getContext(), new GestureListener()); mScaleDetector = new ScaleGestureDetector(getContext(), new ScaleGestureListener()); mBitmapOptions = new BitmapFactory.Options(); mPaint = new Paint(Paint.FILTER_BITMAP_FLAG); mRectPaint = new Paint(); mRectPaint.setStyle(Paint.Style.STROKE); mRectPaint.setStrokeWidth(1f); mBorderPaint = new Paint(); mBorderPaint.setColor(Color.BLACK); mCanvasDrawRect = new Rect(); mImageDrawRect = new Rect(); mCacheRect = new Rect(); mOutputRect = new Rect(); mSmallImage = false; mImageOK = false; mLabelCollection = new LabelCollection(); }
private void init(Context context) { this.context = context; paint = new Paint(); paint.setAntiAlias(true); loadDataThread.start(); gestureDetectorCompat = new GestureDetectorCompat(context,new GestureDetector.SimpleOnGestureListener(){ @Override public boolean onDown(MotionEvent e) { handlerTouch(e.getX(),e.getY()); return true; } }); minWidth = context.getResources().getDimensionPixelOffset(R.dimen.min_width); minHeight = context.getResources().getDimensionPixelOffset(R.dimen.min_height); }
@Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { if (!shouldDetectGesture()) { return false; // 拦截手势检测 } // 手势检测 if (recyclerView == null) { this.recyclerView = rv; this.baseAdapter = (T) recyclerView.getAdapter(); mGestureDetector = new GestureDetectorCompat(recyclerView.getContext(), new ItemTouchHelperGestureListener(recyclerView)); } if (!mGestureDetector.onTouchEvent(e) && e.getActionMasked() == MotionEvent.ACTION_UP && mIsShowPress) { if (mPressedView != null) { BaseViewHolder vh = (BaseViewHolder) recyclerView.getChildViewHolder(mPressedView); if (vh == null || vh.getItemViewType() != IRecyclerView.LOADING_VIEW || vh.getItemViewType() != FETCHING_VIEW) { mPressedView.setPressed(false); } mPressedView = null; } mIsShowPress = false; mIsPrepressed = false; } return false; }
/** * 双击 */ public static void onDoubleTap(@NonNull View targetView, @NonNull final OnDoubleTapListener onDoubleTapListener) { final GestureDetectorCompat gestureDetectorCompat = new GestureDetectorCompat(targetView.getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onDoubleTap(MotionEvent e) { onDoubleTapListener.onDoubleTap(); return super.onDoubleTap(e); } }); targetView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { gestureDetectorCompat.onTouchEvent(event); return false; } }); }
private void initLayout() { mOverScroller = new OverScroller(getContext()); mGestureDetectorCompat = new GestureDetectorCompat(getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, final float velocityY) { if (Math.abs(velocityX) > Math.abs(velocityY)) { return false; } if (isFloat() /*&& velocityY < 0*/) { return false; } fling(velocityY); return true; } }); }
public TagViewGroup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); Resources.Theme theme = context.getTheme(); TypedArray array = theme.obtainStyledAttributes(attrs, R.styleable.TagViewGroup, defStyleAttr, 0); mRadius = array.getDimensionPixelSize(R.styleable.TagViewGroup_radius, DipConvertUtils.dip2px(context, DEFAULT_RADIUS)); mInnerRadius = array.getDimensionPixelSize(R.styleable.TagViewGroup_inner_radius, DipConvertUtils.dip2px(context, DEFAULT_INNER_RADIUS)); mTDistance = array.getDimensionPixelSize(R.styleable.TagViewGroup_tilt_distance, DipConvertUtils.dip2px(context, DEFAULT_TILT_DISTANCE)); mVDistance = array.getDimensionPixelSize(R.styleable.TagViewGroup_v_distance, DipConvertUtils.dip2px(context, DEFAULT_V_DISTANCE)); mLinesWidth = array.getDimensionPixelSize(R.styleable.TagViewGroup_line_width, DipConvertUtils.dip2px(context, DEFAULT_LINES_WIDTH)); mRippleMaxRadius = array.getDimensionPixelSize(R.styleable.TagViewGroup_ripple_maxRadius, DipConvertUtils.dip2px(context, DEFAULT_RIPPLE_MAX_RADIUS)); mRippleAlpha = array.getInteger(R.styleable.TagViewGroup_ripple_alpha, DEFULT_RIPPLE_ALPHA); mRippleMinRadius = mInnerRadius + (mRadius - mInnerRadius) / 2; array.recycle(); mPaint = new Paint(); mPath = new Path(); mDstPath = new Path(); mPathMeasure = new PathMeasure(); mPaint.setAntiAlias(true); mGestureDetector = new GestureDetectorCompat(context, new TagOnGestureListener()); mChildUsed = new int[4]; mCenterRect = new RectF(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; mGestureDetector = new GestureDetectorCompat(getActivity(), new GestureListener()); if ( mLandscape ) { mainActivity.mViewPagerListeners.add(this); } if ( savedInstanceState != null ) { long date = savedInstanceState.getLong(SAVE_DATE, -1); if ( date > 0 ) mCalendar.setTimeInMillis(date); } }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_data_list, container, false); if (view instanceof RecyclerView) { Context context = view.getContext(); recyclerView = (RecyclerView) view; recyclerView.setLayoutManager(new LinearLayoutManager(context)); recyclerView.addOnItemTouchListener(this); adapter = new DataRecyclerViewAdapter(taskArrayList, DataListFragment.this); recyclerView.setAdapter(adapter); gestureDetector = new GestureDetectorCompat(getActivity(), new RecyclerViewDemoOnGestureListener()); } return view; }
private void setCustomScrolling() { mGestureDetector = new GestureDetectorCompat(getContext(), new MyGestureDetector()); setOnTouchListener((v, event) -> { //If the user swipes if (mGestureDetector.onTouchEvent(event)) { return true; } else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { int featureHeight = v.getMeasuredHeight(); mActiveFeature = ((getScrollY() + (featureHeight / 2)) / featureHeight); int scrollTo = mActiveFeature * featureHeight; smoothScrollTo(0, scrollTo); return true; } else { return false; } }); }
/** * 初始化参数 */ private void initParams() { mDetector = new GestureDetectorCompat(this, new SimpleGestureAction()); mStateBarH = AndroidUtils.getStatusBarHeight(this); mHeadH = (int) getResources().getDimension(R.dimen.game_detail_head_height); mBarH = (int) getResources().getDimension(R.dimen.tool_bar_height); mScreenH = AndroidUtils.getScreenParams(this)[1]; mNBarH = AndroidUtils.getNavigationBarHeight(this); mTopL = -mHeadH + mBarH; mCenterL = DensityUtils.dp2px(150); mBottomL = mScreenH - mStateBarH - mNBarH - mHeadH + mBarH; mRootView = findViewById(android.R.id.content); //处理4.4之后状态栏 if (AndroidVersionUtil.hasKitKat()) { mTemp.setVisibility(View.VISIBLE); mToolBar.setTranslationY(mStateBarH); mTemp.getLayoutParams().height = mStateBarH; } else { mTemp.setVisibility(View.GONE); } }
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()); }
private void init(Context context, AttributeSet attrs) { if (attrs != null && context != null) { TypedArray a = context.getTheme().obtainStyledAttributes( attrs, R.styleable.SwipeRevealLayout, 0, 0 ); mDragEdge = a.getInteger(R.styleable.SwipeRevealLayout_dragEdge, DRAG_EDGE_LEFT); mMinFlingVelocity = a.getInteger(R.styleable.SwipeRevealLayout_flingVelocity, DEFAULT_MIN_FLING_VELOCITY); mMode = a.getInteger(R.styleable.SwipeRevealLayout_mode, MODE_NORMAL); mMinDistRequestDisallowParent = a.getDimensionPixelSize( R.styleable.SwipeRevealLayout_minDistRequestDisallowParent, dpToPx(DEFAULT_MIN_DIST_REQUEST_DISALLOW_PARENT) ); } mDragHelper = ViewDragHelper.create(this, 1.0f, mDragHelperCallback); mDragHelper.setEdgeTrackingEnabled(ViewDragHelper.EDGE_ALL); mGestureDetector = new GestureDetectorCompat(context, mGestureListener); }
private void init(@NonNull Context context) { // I fucking love Android setWillNotDraw(false); selectedLayerPaint = new Paint(); selectedLayerPaint.setAlpha((int) (255 * Constants.SELECTED_LAYER_ALPHA)); selectedLayerPaint.setAntiAlias(true); // init listeners this.scaleGestureDetector = new ScaleGestureDetector(context, new ScaleListener()); this.rotateGestureDetector = new RotateGestureDetector(context, new RotateListener()); this.moveGestureDetector = new MoveGestureDetector(context, new MoveListener()); this.gestureDetectorCompat = new GestureDetectorCompat(context, new TapsListener()); setOnTouchListener(onTouchListener); updateUI(); }
public CropView(Context context, AttributeSet attrs) { super(context, attrs); mDetectorCompat = new GestureDetectorCompat(getContext(), new GestureListener()); mScaleDetector = new ScaleGestureDetector(getContext(), new ScaleGestureListener()); mBitmapOptions = new BitmapFactory.Options(); mPaint = new Paint(Paint.FILTER_BITMAP_FLAG); mRectPaint = new Paint(); mRectPaint.setStyle(Paint.Style.STROKE); mBorderPaint = new Paint(); mBorderPaint.setColor(Color.BLACK); mCanvasDrawRect = new Rect(); mImageDrawRect = new Rect(); mCacheRect = new Rect(); mSmallImage = false; mImageOK = false; mLabelHandler = new LabelHandler(); }
public void processRawEvent(GestureDetectorCompat mDetector, MotionEvent e) { // record the touches setTouches(e); if (edgesTouched == 0 && e.getAction() == MotionEvent.ACTION_DOWN) { edgesTouched = getEdgesTouched((int) e.getX(), (int) e.getY()); if (edgesTouched != 0) { log.debug("Edges Touched: {}", edgesTouched); } } mDetector.onTouchEvent(e); if (touchFocusEnabled) { if (e.getAction() == MotionEvent.ACTION_MOVE) { if (logTouch) log.debug("onMouseMove: {},{}", X(e), Y(e)); client.getCurrentConnection().postMouseEvent(new MouseEvent(this, MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, X(e), Y(e), 0, 0, 0)); } } if (edgesTouched != 0 && (e.getAction() == MotionEvent.ACTION_UP || e.getAction() == MotionEvent.ACTION_POINTER_UP)) { log.debug("Clearing Touched Edges"); edgesTouched = 0; } }
private void initTracker() { if (!Utils.hasExternalStoragePermission(this)) { ActivityCompat.requestPermissions( this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE }, Constants.REQUEST_CODE_PERMISSION_EXTERNAL_STORAGE); } // TODO(youngseokyoon): consolidate the Tracker into UserActionLogger mLogger = UserActionLogger.getInstance(this); mGestureListener = new GestureListener(this); mGestureDetector = new GestureDetectorCompat(this, mGestureListener); mGestureDetector.setOnDoubleTapListener(mGestureListener); }
public DragPaneLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mDensity = context.getResources().getDisplayMetrics().density; mViewDragCallback = new ViewDragCallback(); mDragHelper = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mViewDragCallback); mDragHelper.setMinVelocity(MIN_FLING_VELOCITY * mDensity); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO); // So that we can catch the back button ? setFocusableInTouchMode(true); setClickable(true); ViewGroupCompat.setMotionEventSplittingEnabled(this, false); mGestureDetector = new GestureDetectorCompat(context, mGestureListener); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recharge); detector = new GestureDetectorCompat(this, new GestureListener()); ButterKnife.bind(this); setupToolbar(); Bundle extras = getIntent().getExtras(); if (extras != null) { @PlanConstants.Type int type = extras.getInt(TYPE_BUNDLE_KEY); presenter = new RechargePresenterImpl(this, type, getRechargeTitle(type)); presenter.createRecharge(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // set gesture detector mDetector = new GestureDetectorCompat(this, new MyGestureListener()); mRubberIndicator = (RubberIndicator) findViewById(R.id.rubber); mTextView = (TextView) findViewById(R.id.focus_position); // check to see if savedInstanceState is null if (savedInstanceState != null) { mRubberIndicator.setCount(savedInstanceState.getInt(KEY_INDICATOR_ITEM_NUM), savedInstanceState.getInt(KEY_INDICATOR_POSITION)); } else { mRubberIndicator.setCount(indicatorItemNum, 2); } //mRubberIndicator.setCount(5, 2); mRubberIndicator.setOnMoveListener(this); updateFocusPosition(); }
@Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { if (!shouldDetectGesture()) { return false; // 拦截手势检测 } // 手势检测 if (recyclerView == null) { this.recyclerView = rv; this.baseAdapter = (T) recyclerView.getAdapter(); mGestureDetector = new GestureDetectorCompat(recyclerView.getContext(), new ItemTouchHelperGestureListener(recyclerView)); } if (!mGestureDetector.onTouchEvent(e) && e.getActionMasked() == MotionEvent.ACTION_UP && mIsShowPress) { if (mPressedView != null) { BaseViewHolder vh = (BaseViewHolder) recyclerView.getChildViewHolder(mPressedView); if (vh == null || vh.getItemViewType() != IRecyclerView.LOADING_VIEW || vh.getItemViewType() != IRecyclerView.FETCHING_VIEW) { mPressedView.setPressed(false); } mPressedView = null; } mIsShowPress = false; mIsPrepressed = false; } return false; }
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mGestureDetector = new GestureDetectorCompat(getContext(), new GestureListener()); TypedArray attr = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, 0); if (attr != null) { try { mColor = attr.getInt(R.styleable.FloatingActionButton_fabColor, COLOR_ACCENT); switch (mColor) { case COLOR_BLACK: mColorNormal = Color.BLACK; break; case COLOR_WHITE: mColorNormal = Color.WHITE; break; case COLOR_ACCENT: default: mColorNormal = ThemeUtils.getColorAccent(getContext()); } mColorPressed = ThemeUtils.getColorControlNormal(getContext()); } finally { attr.recycle(); } } init(); }
private void init(Context context, AttributeSet attrs ) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SyncedListLayout); try{ mLeftListId = a.getResourceId(R.styleable.SyncedListLayout_left_id, 0); mRightListId = a.getResourceId(R.styleable.SyncedListLayout_right_id, 0); mLeftScrollFactor = a.getFloat(R.styleable.SyncedListLayout_left_scroll_factor, 1f); mRightScrollFactor = a.getFloat(R.styleable.SyncedListLayout_right_scroll_factor, 1f); }finally { a.recycle(); } WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); DisplayMetrics metric = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(metric); mAnimationVelocity = (int)(DEFAULT_VELOCITY * metric.density); gestureDetector = new GestureDetectorCompat(context, gestureListener); mScroller = new Scroller(context); mAnimationRunnable = new AnimationRunnable(context); mFlingRunnable = new FlingRunnable(); }
public PagerOnTouchListener(Activity activity) { PagerOnTouchListener touchListener = this; ViewConfiguration viewConfiguration = ViewConfiguration.get(activity); int minSwipeDistance = viewConfiguration.getScaledPagingTouchSlop(); int velocity = viewConfiguration.getScaledMinimumFlingVelocity(); gdt = new GestureDetectorCompat(activity, new PagerOnGestureListener(minSwipeDistance, velocity) { @Override public void onSwipeLeft() { touchListener.onSwipeLeft(); } @Override public void onSwipeRight() { touchListener.onSwipeRight(); } }); }