android.support.v4.widget.ScrollerCompat#create ( )源码实例Demo

下面列出了android.support.v4.widget.ScrollerCompat#create ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: DidiLayout   文件: DidiViewDragHelper.java
/**
 * 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);
}
 
源代码2 项目: UltimateAndroid   文件: ViewDragHelper.java
/**
 * 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);
}
 
源代码3 项目: TLint   文件: ViewDragHelper.java
/**
 * 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);
}
 
源代码4 项目: zhangshangwuda   文件: ViewDragHelper.java
/**
 * 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);
}
 
源代码5 项目: ting   文件: ViewDragHelper.java
/**
 * 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);
}
 
源代码6 项目: Nimingban   文件: ViewDragHelper.java
/**
 * 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);
}
 
源代码7 项目: mobile-manager-tool   文件: ViewDragHelper.java
/**
 * 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);
}
 
源代码8 项目: Dragger   文件: ViewDragHelper.java
/**
 * 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);
}
 
/**
 * 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);
}
 
源代码10 项目: Cashew   文件: ViewDragHelper.java
/**
 * 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);
}
 
源代码11 项目: WayHoo   文件: ViewDragHelper.java
/**
 * 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);
}
 
源代码12 项目: ticdesign   文件: HeaderBehavior.java
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;
}
 
源代码13 项目: Tweetin   文件: ViewDragHelper.java
/**
 * 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);
}
 
源代码14 项目: CoreModule   文件: ViewDragHelper.java
/**
 * 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);
}
 
源代码15 项目: SimpleNews   文件: ViewDragHelper.java
/**
 * 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);
}
 
源代码16 项目: Slide   文件: NestedWebView.java
private void initScrollView() {
    mScroller = ScrollerCompat.create(getContext(), null);
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}
 
源代码17 项目: ClassifyView   文件: InsertAbleGridView.java
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);
}
 
源代码18 项目: hellocharts-android   文件: PieChartTouchHandler.java
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.
}
 
源代码19 项目: MapForTour   文件: SwipeMenuLayout.java
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);
	// }
	// });

}
 
源代码20 项目: CanPhotos   文件: Attacher.java
public FlingRunnable(Context context) {
    mScroller = ScrollerCompat.create(context);
}
 
 同类方法