List of usage examples for android.support.v4.view GestureDetectorCompat GestureDetectorCompat
public GestureDetectorCompat(Context context, OnGestureListener onGestureListener)
From source file:com.eje_c.android.view.CompositeGestureDetector.java
public CompositeGestureDetector(Context context, OnCompositeGestureListener listener) { this.listener = listener; gestureDetector = new GestureDetectorCompat(context, listener); scaleGestureDetector = new ScaleGestureDetector(context, listener); rotateGestureDetector = new RotateGestureDetector(context, listener); }
From source file:com.baoyz.dribble.widget.SuperRecyclerView.java
public SuperRecyclerView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); super.setOnScrollListener(new OnScrollListener() { @Override// w w w. j a v a2 s. c o m public void onScrollStateChanged(RecyclerView recyclerView, int newState) { if (newState == RecyclerView.SCROLL_STATE_IDLE) { LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager(); if (layoutManager.findLastVisibleItemPosition() == (layoutManager.getItemCount() - 1)) { setLoadMore(true); } } if (mScrollListener != null) mScrollListener.onScrollStateChanged(recyclerView, newState); } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); if (mScrollListener != null) mScrollListener.onScrolled(recyclerView, dx, dy); } }); ViewConfiguration viewConfiguration = ViewConfiguration.get(context); mTouchDistance = viewConfiguration.getScaledOverflingDistance(); mFlingVelocity = viewConfiguration.getScaledMinimumFlingVelocity(); mGesutureDetector = new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (mOnQuickScrollListener != null && Math.abs(velocityY) > mFlingVelocity) { if (velocityY > 0) mOnQuickScrollListener.onQuickDown(); else mOnQuickScrollListener.onQuickUp(); } return super.onFling(e1, e2, velocityX, velocityY); } }); }
From source file:fr.magistry.taigime.CandidateView.java
/** * Construct a CandidateView for showing suggested words for completion. * @param context/*from ww w. j a va 2 s . co m*/ */ public CandidateView(Context context) { super(context); mSelectionHighlight = context.getResources().getDrawable(android.R.drawable.list_selector_background); mSelectionHighlight.setState(new int[] { android.R.attr.state_enabled, android.R.attr.state_focused, android.R.attr.state_window_focused, android.R.attr.state_pressed }); Resources r = context.getResources(); setBackgroundColor(r.getColor(R.color.candidate_background)); mColorNormal = r.getColor(R.color.candidate_normal); mColorRecommended = r.getColor(R.color.candidate_recommended); mColorOther = r.getColor(R.color.candidate_other); mVerticalPadding = r.getDimensionPixelSize(R.dimen.candidate_vertical_padding); mPaint = new Paint(); mPaint.setColor(mColorNormal); mPaint.setAntiAlias(true); mPaint.setTextSize(r.getDimensionPixelSize(R.dimen.candidate_font_height)); mPaint.setStrokeWidth(0); mPaintTRS = new Paint(); mPaintTRS.set(mPaint); mPaintTRS.setTextSize(r.getDimensionPixelSize(R.dimen.candidate_font_trs_height)); mPaintBPM = new Paint(); mPaintBPM.set(mPaintTRS); mGestureDetector = new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { mScrolled = true; int sx = getScrollX(); sx += distanceX; if (sx < 0) { sx = 0; } if (sx + getWidth() > mTotalWidth) { sx -= distanceX; } mTargetScrollX = sx; scrollTo(sx, getScrollY()); invalidate(); return true; } }); setHorizontalFadingEdgeEnabled(true); setWillNotDraw(false); setHorizontalScrollBarEnabled(false); setVerticalScrollBarEnabled(false); updateConfig(context); }
From source file:com.tmall.wireless.tangram.ext.SwipeItemTouchListener.java
public SwipeItemTouchListener(Context context, GroupBasicAdapter groupBasicAdapter, RecyclerView recyclerView) { this.mGroupBasicAdapter = groupBasicAdapter; this.recyclerView = recyclerView; this.recyclerView.addOnScrollListener(scrollListener); this.layoutManager = (VirtualLayoutManager) recyclerView.getLayoutManager(); mSwipeGestureDector = new GestureDetectorCompat(context, new SwipeGestureListener()); mChildList = new ArrayList<>(); }
From source file:com.github.shareme.gwsmaterialuikit.library.ccv.CompactCalendarView.java
public CompactCalendarView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); compactCalendarController = new CompactCalendarController(new Paint(), new OverScroller(getContext()), new Rect(), attrs, getContext(), Color.argb(255, 233, 84, 81), Color.argb(255, 64, 64, 64), Color.argb(255, 219, 219, 219), VelocityTracker.obtain()); gestureDetector = new GestureDetectorCompat(getContext(), gestureListener); animationHandler = new AnimationHandler(compactCalendarController, this); }
From source file:om.sstvencoder.CropView.java
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;//from w ww . ja va 2 s . co m mImageOK = false; mLabelHandler = new LabelHandler(); }
From source file:com.wenhui.syncedListView.lib.SyncedListLayout.java
private void init(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SyncedListLayout); try {//from ww w . j a va 2s .c o m 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(); }
From source file:com.cryart.sabbathschool.view.SSReadingView.java
public SSReadingView(final Context context) { super(context); if (!isInEditMode()) { gestureDetector = new GestureDetectorCompat(context, new SSReadingView.GestureListener()); ssReadViewBridge = new SSReadViewBridge(context); this.setWebViewClient(new SSWebViewClient()); this.getSettings().setJavaScriptEnabled(true); this.addJavascriptInterface(ssReadViewBridge, bridgeName); }/* ww w . java2 s. com*/ }
From source file:com.example.spencerdepas.translationapp.activities.DMVStudyActivity.java
public void setUpGestures() { Log.d(TAG, "setUpGestures :"); GestureListener mGestureListener = new GestureListener(); mGestureListener.delegate = DMVStudyActivity.this; gDetect = new GestureDetectorCompat(this, mGestureListener); }
From source file:org.gearvrf.viewmanager.controls.util.VRSamplesTouchPadGesturesDetector.java
public VRSamplesTouchPadGesturesDetector(Context context, OnTouchPadGestureListener listener) { this.mDetector = new GestureDetectorCompat(context, this); this.mDetector.setIsLongpressEnabled(false); this.mDetector.setOnDoubleTapListener(this); this.gestureListener = listener; //Test// www . j a v a2 s.c o m sharedPref = context.getSharedPreferences("VR", Context.MODE_PRIVATE); editor = sharedPref.edit(); // showLogsAtPref(); }