Java Code Examples for android.support.v4.widget.ScrollerCompat#create()

The following examples show how to use android.support.v4.widget.ScrollerCompat#create() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewDragHelper.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Apps should use ViewDragHelper.create() to get a new instance. This will
 * allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context   Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
Example 2
Source File: ViewDragHelper.java    From SimpleNews with Apache License 2.0 6 votes vote down vote up
/**
 * Apps should use ViewDragHelper.create() to get a new instance. This will
 * allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context   Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
Example 3
Source File: ViewDragHelper.java    From CoreModule with Apache License 2.0 6 votes vote down vote up
/**
 * Apps should use ViewDragHelper.create() to get a new instance. This will
 * allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context   Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
Example 4
Source File: ViewDragHelper.java    From Tweetin with Apache License 2.0 6 votes vote down vote up
/**
 * Apps should use ViewDragHelper.create() to get a new instance.
 * This will allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
Example 5
Source File: HeaderBehavior.java    From ticdesign with Apache License 2.0 6 votes vote down vote up
final boolean fling(CoordinatorLayout coordinatorLayout, V layout, int minOffset,
        int maxOffset, float velocityY) {
    if (mFlingRunnable != null) {
        layout.removeCallbacks(mFlingRunnable);
        mFlingRunnable = null;
    }

    if (mScroller == null) {
        mScroller = ScrollerCompat.create(layout.getContext());
    }

    mScroller.fling(
            0, getTopAndBottomOffset(), // curr
            0, Math.round(velocityY), // velocity.
            0, 0, // x
            minOffset, maxOffset); // y

    if (mScroller.computeScrollOffset()) {
        mFlingRunnable = new FlingRunnable(coordinatorLayout, layout);
        ViewCompat.postOnAnimation(layout, mFlingRunnable);
        return true;
    }
    return false;
}
 
Example 6
Source File: ViewDragHelper.java    From WayHoo with Apache License 2.0 6 votes vote down vote up
/**
 * Apps should use ViewDragHelper.create() to get a new instance. This will
 * allow VDH to use internal compatibility implementations for different
 * platform versions.
 * 
 * @param context
 *            Context to initialize config-dependent params from
 * @param forParent
 *            Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
	if (forParent == null) {
		throw new IllegalArgumentException("Parent view may not be null");
	}
	if (cb == null) {
		throw new IllegalArgumentException("Callback may not be null");
	}

	mParentView = forParent;
	mCallback = cb;

	final ViewConfiguration vc = ViewConfiguration.get(context);
	final float density = context.getResources().getDisplayMetrics().density;
	mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

	mTouchSlop = vc.getScaledTouchSlop();
	mMaxVelocity = vc.getScaledMaximumFlingVelocity();
	mMinVelocity = vc.getScaledMinimumFlingVelocity();
	mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
Example 7
Source File: ViewDragHelper.java    From Cashew with Apache License 2.0 6 votes vote down vote up
/**
 * Apps should use ViewDragHelper.create() to get a new instance. This will
 * allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context   Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
Example 8
Source File: DidiViewDragHelper.java    From DidiLayout with Apache License 2.0 6 votes vote down vote up
/**
 * Apps should use DidiViewDragHelper.create() to get a new instance.
 * This will allow VDH to use internal compatibility implementations for different
 * platform versions.
 * If the interpolator is null, the default interpolator will be used.
 *
 * @param context      Context to initialize config-dependent params from
 * @param forParent    Parent view to monitor
 * @param interpolator interpolator for scroller
 */
private DidiViewDragHelper(Context context, ViewGroup forParent, Interpolator interpolator, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, interpolator != null ? interpolator : sInterpolator);
}
 
Example 9
Source File: ViewDragHelper.java    From Dragger with Apache License 2.0 6 votes vote down vote up
/**
 * Apps should use ViewDragHelper.create() to get a new instance.
 * This will allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
  if (forParent == null) {
    throw new IllegalArgumentException("Parent view may not be null");
  }
  if (cb == null) {
    throw new IllegalArgumentException("Callback may not be null");
  }

  mParentView = forParent;
  mCallback = cb;

  final ViewConfiguration vc = ViewConfiguration.get(context);
  final float density = context.getResources().getDisplayMetrics().density;
  mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

  mTouchSlop = vc.getScaledTouchSlop();
  mMaxVelocity = vc.getScaledMaximumFlingVelocity();
  mMinVelocity = vc.getScaledMinimumFlingVelocity();
  mScroller = ScrollerCompat.create(context, INTERPOLATOR);
}
 
Example 10
Source File: ViewDragHelper.java    From mobile-manager-tool with MIT License 6 votes vote down vote up
/**
 * Apps should use ViewDragHelper.create() to get a new instance.
 * This will allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
Example 11
Source File: ViewDragHelper.java    From Nimingban with Apache License 2.0 6 votes vote down vote up
/**
 * Apps should use ViewDragHelper.create() to get a new instance.
 * This will allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
Example 12
Source File: ViewDragHelper.java    From ting with Apache License 2.0 6 votes vote down vote up
/**
 * Apps should use ViewDragHelper.create() to get a new instance.
 * This will allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
Example 13
Source File: ViewDragHelper.java    From zhangshangwuda with Apache License 2.0 6 votes vote down vote up
/**
 * Apps should use ViewDragHelper.create() to get a new instance. This will
 * allow VDH to use internal compatibility implementations for different
 * platform versions.
 * 
 * @param context
 *            Context to initialize config-dependent params from
 * @param forParent
 *            Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
	if (forParent == null) {
		throw new IllegalArgumentException("Parent view may not be null");
	}
	if (cb == null) {
		throw new IllegalArgumentException("Callback may not be null");
	}

	mParentView = forParent;
	mCallback = cb;

	final ViewConfiguration vc = ViewConfiguration.get(context);
	final float density = context.getResources().getDisplayMetrics().density;
	mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

	mTouchSlop = vc.getScaledTouchSlop();
	mMaxVelocity = vc.getScaledMaximumFlingVelocity();
	mMinVelocity = vc.getScaledMinimumFlingVelocity();
	mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
Example 14
Source File: ViewDragHelper.java    From TLint with Apache License 2.0 6 votes vote down vote up
/**
 * Apps should use ViewDragHelper.create() to get a new instance. This will
 * allow VDH to use internal compatibility implementations for different
 * platform versions.
 *
 * @param context   Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
Example 15
Source File: ViewDragHelper.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * Apps should use ViewDragHelper.create() to get a new instance. This will
 * allow VDH to use internal compatibility implementations for different
 * platform versions.
 * 
 * @param context Context to initialize config-dependent params from
 * @param forParent Parent view to monitor
 */
private ViewDragHelper(Context context, ViewGroup forParent, Callback cb) {
    if (forParent == null) {
        throw new IllegalArgumentException("Parent view may not be null");
    }
    if (cb == null) {
        throw new IllegalArgumentException("Callback may not be null");
    }

    mParentView = forParent;
    mCallback = cb;

    final ViewConfiguration vc = ViewConfiguration.get(context);
    final float density = context.getResources().getDisplayMetrics().density;
    mEdgeSize = (int) (EDGE_SIZE * density + 0.5f);

    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mScroller = ScrollerCompat.create(context, sInterpolator);
}
 
Example 16
Source File: NestedWebView.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
private void initScrollView() {
    mScroller = ScrollerCompat.create(getContext(), null);
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}
 
Example 17
Source File: InsertAbleGridView.java    From ClassifyView with Apache License 2.0 5 votes vote down vote up
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.InsertAbleGridView, defStyleAttr, R.style.InsertAbleGridViewDefaultStyle);
    mRowCount = a.getInt(R.styleable.InsertAbleGridView_RowCount, 2);
    mColumnCount = a.getInt(R.styleable.InsertAbleGridView_ColumnCount, 2);
    mRowGap = a.getDimensionPixelSize(R.styleable.InsertAbleGridView_RowGap, 10);
    mColumnGap = a.getDimensionPixelSize(R.styleable.InsertAbleGridView_ColumnGap, 10);
    mOutLinePadding = a.getDimensionPixelSize(R.styleable.InsertAbleGridView_OutlinePadding, 10);
    mInnerPadding = a.getDimensionPixelOffset(R.styleable.InsertAbleGridView_InnerPadding, 10);
    mBagDrawable = new BagDrawable(mOutLinePadding);
    mBagDrawable.setOutlineStyle(a.getColor(R.styleable.InsertAbleGridView_OutlineColor, 0), a.getDimensionPixelSize(R.styleable.InsertAbleGridView_OutlineWidth, 3));
    setBackgroundDrawable(mBagDrawable);
    a.recycle();
    mScroller = ScrollerCompat.create(context);
}
 
Example 18
Source File: PieChartTouchHandler.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
public PieChartTouchHandler(Context context, PieChartView chart) {
    super(context, chart);
    pieChart = (PieChartView) chart;
    scroller = ScrollerCompat.create(context);
    gestureDetector = new GestureDetector(context, new ChartGestureListener());
    scaleGestureDetector = new ScaleGestureDetector(context, new ChartScaleGestureListener());
    isZoomEnabled = false;// Zoom is not supported by PieChart.
}
 
Example 19
Source File: SwipeMenuLayout.java    From MapForTour with MIT License 4 votes vote down vote up
private void init() {
	setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT,
			LayoutParams.WRAP_CONTENT));
	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) {
			// TODO
			if (Math.abs(e1.getX() - e2.getX()) > MIN_FLING
					&& velocityX < MAX_VELOCITYX) {
				isFling = true;
			}
			// Log.i("byz", MAX_VELOCITYX + ", velocityX = " + velocityX);
			return super.onFling(e1, e2, velocityX, velocityY);
		}
	};
	mGestureDetector = new GestureDetectorCompat(getContext(),
			mGestureListener);

	// mScroller = ScrollerCompat.create(getContext(), new
	// BounceInterpolator());
	if (mCloseInterpolator != null) {
		mCloseScroller = ScrollerCompat.create(getContext(),
				mCloseInterpolator);
	} else {
		mCloseScroller = ScrollerCompat.create(getContext());
	}
	if (mOpenInterpolator != null) {
		mOpenScroller = ScrollerCompat.create(getContext(),
				mOpenInterpolator);
	} else {
		mOpenScroller = ScrollerCompat.create(getContext());
	}

	LayoutParams contentParams = new LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	mContentView.setLayoutParams(contentParams);
	if (mContentView.getId() < 1) {
		mContentView.setId(CONTENT_VIEW_ID);
	}

	mMenuView.setId(MENU_VIEW_ID);
	mMenuView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
			LayoutParams.WRAP_CONTENT));

	addView(mContentView);
	addView(mMenuView);

	// if (mContentView.getBackground() == null) {
	// mContentView.setBackgroundColor(Color.WHITE);
	// }

	// in android 2.x, MenuView height is MATCH_PARENT is not work.
	// getViewTreeObserver().addOnGlobalLayoutListener(
	// new OnGlobalLayoutListener() {
	// @Override
	// public void onGlobalLayout() {
	// setMenuHeight(mContentView.getHeight());
	// // getViewTreeObserver()
	// // .removeGlobalOnLayoutListener(this);
	// }
	// });

}
 
Example 20
Source File: Attacher.java    From CanPhotos with Apache License 2.0 4 votes vote down vote up
public FlingRunnable(Context context) {
    mScroller = ScrollerCompat.create(context);
}