use of android.widget.Scroller in project android_packages_apps_Launcher2 by CyanogenMod.
the class SmoothPagedView method init.
/**
* Initializes various states for this workspace.
*/
@Override
protected void init() {
super.init();
mScrollMode = getScrollMode();
if (mScrollMode == DEFAULT_MODE) {
mBaseLineFlingVelocity = 2500.0f;
mFlingVelocityInfluence = 0.4f;
mScrollInterpolator = new OvershootInterpolator();
mScroller = new Scroller(getContext(), mScrollInterpolator);
}
}
use of android.widget.Scroller in project InfiniteCycleViewPager by Devlight.
the class VerticalViewPager method initViewPager.
void initViewPager() {
setWillNotDraw(false);
setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
setFocusable(true);
final Context context = getContext();
mScroller = new Scroller(context, sInterpolator);
final ViewConfiguration configuration = ViewConfiguration.get(context);
final float density = context.getResources().getDisplayMetrics().density;
mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
mMinimumVelocity = (int) (MIN_FLING_VELOCITY * density);
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
mTopEdge = new EdgeEffectCompat(context);
mBottomEdge = new EdgeEffectCompat(context);
mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
mCloseEnough = (int) (CLOSE_ENOUGH * density);
mDefaultGutterSize = (int) (DEFAULT_GUTTER_SIZE * density);
ViewCompat.setAccessibilityDelegate(this, new MyAccessibilityDelegate());
if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
}
use of android.widget.Scroller in project Reader by TheKeeperOfPie.
the class ImageViewZoom method initialize.
private void initialize() {
setClickable(true);
scroller = new Scroller(getContext());
scaleGestureDetector = new ScaleGestureDetector(getContext(), new ScaleGestureDetector.SimpleOnScaleGestureListener() {
@Override
public boolean onScale(ScaleGestureDetector detector) {
// Log.d(TAG, "onScale() called with: " + "detector = [" + detector + "]");
//
// Log.d(TAG, "onScale() called with: " + "focusX = [" + detector.getFocusX() + "], focusY = [" + detector.getFocusY() + "], width = [" + getWidth() + "], height = [" + getHeight() + "]");
// float translationX = detector.getFocusX() * (translationMaxX - translationMinX) / getWidth() + translationMinX;
// float translationY = detector.getFocusY() * (translationMaxY - translationMinY) / getHeight() + translationMinY;
// setTranslation(translationX, translationY);
applyScaleFactor(detector.getFocusX(), detector.getFocusY(), detector.getScaleFactor());
return true;
}
});
gestureDetector = new GestureDetectorCompat(getContext(), new GestureDetector.SimpleOnGestureListener() {
private int pointerCount;
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
// Log.d(TAG, "onScroll() called with: " + "translationX = [" + translationX + "], translationMinX = [" + translationMinX + "], translationMaxX = [" + translationMaxX + "], scaleStart = [" + scaleStart + "], scaleCurrent = [" + scaleCurrent + "], contentWidth = [" + contentWidth + "]");
// Log.d(TAG, "onScroll() called with relative: " + "x = [" + getRelativeX() + "], y = [" + getRelativeY() + "]");
scroller.forceFinished(true);
if (pointerCount == 1) {
applyTranslation(-distanceX, -distanceY);
}
return super.onScroll(e1, e2, distanceX, distanceY);
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
scroller.forceFinished(true);
if (pointerCount == 1) {
Log.d(TAG, "onFling() called with: " + "e1 = [" + e1 + "], e2 = [" + e2 + "], velocityX = [" + velocityX + "], velocityY = [" + velocityY + "]");
scroller.fling((int) translationX, (int) translationY, (int) velocityX, (int) velocityY, (int) translationMinX, (int) translationMaxX, (int) translationMinY, (int) translationMaxY);
post(runnableScroll);
}
return super.onFling(e1, e2, velocityX, velocityY);
}
@Override
public boolean onDown(MotionEvent e) {
pointerCount = e.getPointerCount();
return super.onDown(e);
}
});
}
use of android.widget.Scroller in project Fairphone by Kwamecorp.
the class SmoothPagedView method init.
/**
* Initializes various states for this workspace.
*/
@Override
protected void init() {
super.init();
mScrollMode = getScrollMode();
if (mScrollMode == DEFAULT_MODE) {
mBaseLineFlingVelocity = 2500.0f;
mFlingVelocityInfluence = 0.4f;
mScrollInterpolator = new OvershootInterpolator();
mScroller = new Scroller(getContext(), mScrollInterpolator);
}
}
use of android.widget.Scroller in project StickyHeaderListView by sfsheng0322.
the class SmoothListView method initWithContext.
private void initWithContext(Context context) {
mScroller = new Scroller(context, new DecelerateInterpolator());
// XListView need the scroll event, and it will dispatch the event to
// user's listener (as a proxy).
super.setOnScrollListener(this);
// init header view
mHeaderView = new SmoothListViewHeader(context);
mHeaderViewContent = (RelativeLayout) mHeaderView.findViewById(R.id.smoothlistview_header_content);
mHeaderTimeView = (TextView) mHeaderView.findViewById(R.id.smoothlistview_header_time);
addHeaderView(mHeaderView);
// init footer view
mFooterView = new SmoothListViewFooter(context);
// init header height
mHeaderView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
mHeaderViewHeight = mHeaderViewContent.getHeight();
getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
});
}
Aggregations