Java Code Examples for android.widget.Scroller

The following are top voted examples for showing how to use android.widget.Scroller. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: BaseReadView.java   View source code 6 votes vote down vote up
public BaseReadView(Context context, String bookId, List<BookMixAToc.mixToc.Chapters> chaptersList,
                    OnReadStateChangeListener listener) {
    super(context);
    this.listener = listener;
    this.bookId = bookId;

    mScreenWidth = ScreenUtils.getScreenWidth();
    mScreenHeight = ScreenUtils.getScreenHeight();

    mCurPageBitmap = Bitmap.createBitmap(mScreenWidth, mScreenHeight, Bitmap.Config.ARGB_8888);
    mNextPageBitmap = Bitmap.createBitmap(mScreenWidth, mScreenHeight, Bitmap.Config.ARGB_8888);
    mCurrentPageCanvas = new Canvas(mCurPageBitmap);
    mNextPageCanvas = new Canvas(mNextPageBitmap);

    mScroller = new Scroller(getContext());

    pagefactory = new PageFactory(getContext(), bookId, chaptersList);
    pagefactory.setOnReadStateChangeListener(listener);
}
 
Example 2
Project: microMathematics   File: TwoDScrollView.java   View source code 6 votes vote down vote up
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);
}
 
Example 3
Project: SmoothRefreshLayout   File: SRReflectUtil.java   View source code 6 votes vote down vote up
public static Scroller setScrollerInterpolatorOrReCreateScroller(Context context,
                                                                 Scroller scroller,
                                                                 Interpolator interpolator) {
    try {
        if (sScrollerInterpolatorField == null) {
            sScrollerInterpolatorField = Scroller.class.getDeclaredField("mInterpolator");
            if (sScrollerInterpolatorField != null)
                sScrollerInterpolatorField.setAccessible(true);
        }
        if (sScrollerInterpolatorField == null) {
            return new Scroller(context, interpolator);
        } else {
            sScrollerInterpolatorField.set(scroller, interpolator);
            return scroller;
        }
    } catch (Exception e) {
        return new Scroller(context, interpolator);
    }
}
 
Example 4
Project: Hitalk   File: OverScrollLayout.java   View source code 6 votes vote down vote up
private void init() {
        configuration = ViewConfiguration.get(getContext());
        mScroller = new Scroller(getContext(), new OvershootInterpolator(0.75f));
        flingRunnable = new FlingRunnable();
        overScrollRunnable = new OverScrollRunnable();
        flingScroller = new OverScroller(getContext());
        detector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
            @Override
            public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                if (isOverScrollTop || isOverScrollBottom || isOverScrollLeft || isOverScrollRight) {
                    return false;
                }
//
                flingRunnable.start(velocityX, velocityY);
                return false;
            }
        });
    }
 
Example 5
Project: AndroidBasicLibs   File: HorizontialListView.java   View source code 6 votes vote down vote up
private synchronized void initView() {
	mLeftViewIndex = -1;
	mRightViewIndex = 0;
	mDisplayOffset = 0;
	mCurrentX = 0;
	mNextX = 0;
	mMaxX = Integer.MAX_VALUE;
	mScroller = new Scroller(getContext());

	mGesture = new GestureDetector(getContext(), mOnGesture);
	DisplayMetrics displayMetrics = new DisplayMetrics();
	((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
	screenWidth = displayMetrics.widthPixels-180;

	verticalMinDistance = screenWidth/4;
}
 
Example 6
Project: boohee_v5.6   File: HorizontalListViewPosition.java   View source code 6 votes vote down vote up
private synchronized void initView() {
    this.mLeftViewIndex = -1;
    this.mRightViewIndex = 0;
    this.mDisplayOffset = 0;
    this.mCurrentX = 0;
    this.mNextX = 0;
    this.mFirstPosition = 0;
    this.mSpecificPosition = 0;
    this.mSpecificLeft = 0;
    this.mMaxX = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED;
    this.mMinX = Integer.MIN_VALUE;
    this.mScroller = new Scroller(getContext());
    if (!isInEditMode()) {
        this.mGesture = new GestureDetector(getContext(), this.mOnGesture);
    }
}
 
Example 7
Project: GitHub   File: XListView.java   View source code 5 votes vote down vote up
private void initWithContext(Context context) {
	setFadingEdgeLength(0); // 消除边界模糊
	setOverScrollMode(View.OVER_SCROLL_NEVER); // 消除滚动边框

	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 XListViewHeader(context);
	mHeaderViewContent = (RelativeLayout) mHeaderView
			.findViewById(R.id.xlistview_header_content);
	mHeaderTimeView = (TextView) mHeaderView.findViewById(R.id.xlistview_header_time);
	addHeaderView(mHeaderView);

	// init footer view
	mFooterView = new XListViewFooter(context);

	// init header height
	mHeaderView.getViewTreeObserver().addOnGlobalLayoutListener(
			new OnGlobalLayoutListener() {
				@SuppressWarnings("deprecation")
				@Override
				public void onGlobalLayout() {
					mHeaderViewHeight = mHeaderViewContent.getHeight();
					getViewTreeObserver()
					.removeGlobalOnLayoutListener(this);
				}
			});
}
 
Example 8
Project: AndroidPDF   File: DocumentView.java   View source code 5 votes vote down vote up
public DocumentView(Context context, final ZoomModel zoomModel, DecodingProgressModel progressModel, CurrentPageModel currentPageModel) {
    super(context);
    this.zoomModel = zoomModel;
    this.progressModel = progressModel;
    this.currentPageModel = currentPageModel;
    setKeepScreenOn(true);
    scroller = new Scroller(getContext());
    setFocusable(true);
    setFocusableInTouchMode(true);
    initMultiTouchZoomIfAvailable(zoomModel);
}
 
Example 9
Project: DateTimePicker   File: NumberPicker.java   View source code 5 votes vote down vote up
/**
 * Callback invoked upon completion of a given <code>scroller</code>.
 */
private void onScrollerFinished(Scroller scroller) {
    if (scroller == mFlingScroller) {
        if (!ensureScrollWheelAdjusted()) {
            updateInputTextView();
        }
        onScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
    } else {
        if (mScrollState != OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
            updateInputTextView();
        }
    }
}
 
Example 10
Project: Sega   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    }
    else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 11
Project: Programmers   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 12
Project: Android-TV-FocusLayout   File: HLayoutContainer.java   View source code 5 votes vote down vote up
public HLayoutContainer(Context context, AttributeSet attrs) {
    super(context, attrs);
    // 获取屏幕宽度
    DisplayMetrics metric = new DisplayMetrics();
    Display display = ((Activity) context).getWindowManager().getDefaultDisplay();
    display.getMetrics(metric);
    screenWidth = metric.widthPixels; // 屏幕宽度(像素)
    padding = 36;
    rightOffset = 60;
    offset = 10;
    mScroller = new Scroller(context);
    // 由于动画会导致view出现覆盖,所以我们要打开order开关来主动改变view的绘制顺序
    setChildrenDrawingOrderEnabled(true);
}
 
Example 13
Project: WeatherStream   File: CustomViewAbove.java   View source code 5 votes vote down vote up
void initCustomViewAbove() {
	setWillNotDraw(false);
	setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
	setFocusable(true);
	final Context context = getContext();
	mScroller = new Scroller(context, sInterpolator);
	final ViewConfiguration configuration = ViewConfiguration.get(context);
	mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
	mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
	mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
	setInternalPageChangeListener(new SimpleOnPageChangeListener() {
		public void onPageSelected(int position) {
			if (mViewBehind != null) {
				switch (position) {
				case 0:
				case 2:
					mViewBehind.setChildrenEnabled(true);
					break;
				case 1:
					mViewBehind.setChildrenEnabled(false);
					break;
				}
			}
		}
	});

	final float density = context.getResources().getDisplayMetrics().density;
	mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
}
 
Example 14
Project: android-project-gallery   File: ViewPagerCompat.java   View source code 5 votes vote down vote up
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();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = 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);
    }
}
 
Example 15
Project: BoardView   File: BoardView.java   View source code 5 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mRootLayout = new HorizontalScrollView(getContext());
    mRootLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
    mParentLayout = new LinearLayout(getContext());
    mParentLayout.setOrientation(LinearLayout.HORIZONTAL);
    mScroller = new Scroller(mRootLayout.getContext(), new DecelerateInterpolator(1.2f));
    mParentLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    mRootLayout.addView(mParentLayout);
    addView(mRootLayout);
}
 
Example 16
Project: Amazing   File: DragFrameLayout.java   View source code 5 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    resolveAttr(context, attrs);
    scroller = new Scroller(getContext());
    DisplayMetrics displayMetrics = this.getResources().getDisplayMetrics();
    width = displayMetrics.widthPixels;
    height = displayMetrics.heightPixels;//
    statusBarHeight = getStatusBarHeight();
    if (statusBarHeight == 0) {
        statusBarHeight = (int) (25 * displayMetrics.scaledDensity + 0.5f);
    }
    height -= statusBarHeight;
    //还需要减去actionBar的高度
    margin_edge = 10;
}
 
Example 17
Project: boohee_v5.6   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < 9) {
        this.isPreGingerbread = true;
        this.scroller = new Scroller(context);
        return;
    }
    this.isPreGingerbread = false;
    this.overScroller = new OverScroller(context);
}
 
Example 18
Project: godlibrary   File: HorizontalListView.java   View source code 5 votes vote down vote up
private synchronized void initView() {
    mLeftViewIndex = -1;
    mRightViewIndex = 0;
    mDisplayOffset = 0;
    mCurrentX = 0;
    mNextX = 0;
    mMaxX = Integer.MAX_VALUE;
    mScroller = new Scroller(getContext());
    mGesture = new GestureDetector(getContext(), mOnGesture);
}
 
Example 19
Project: AssistantBySDK   File: WheelScroller.java   View source code 5 votes vote down vote up
/**
 * Constructor
 * @param context the current context
 * @param listener the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, gestureListener);
    gestureDetector.setIsLongpressEnabled(false);
    
    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}
 
Example 20
Project: KUtils   File: WheelView.java   View source code 5 votes vote down vote up
/**
 * Initializes class data
 *
 * @param context the mContext
 */
private void initData(Context context) {
    mContext = context;
    gestureDetector = new GestureDetector(context, gestureListener);
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);
    TEXT_SIZE = ToolUtils.dip2px(context, TEXT_SIZE);
    ITEM_OFFSET = ToolUtils.dip2px(context, ITEM_OFFSET);
}
 
Example 21
Project: social-app-android   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 22
Project: Renrentou   File: XCCycleViewPager.java   View source code 5 votes vote down vote up
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();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = 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);
    }
}
 
Example 23
Project: VerticalWebView   File: VerticalParentViewPager.java   View source code 5 votes vote down vote up
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();
    mLeftEdge = new EdgeEffectCompat(context);
    mRightEdge = 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);
    }
}
 
Example 24
Project: spinify_android   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 25
Project: HorizontalLoopView   File: HorizontalLoopView.java   View source code 5 votes vote down vote up
/**
 * 初始化一些滚动的属性
 */
private void initScroll() {
    mScroller = new Scroller(getContext());
    //水平垂直
    setGravity(Gravity.CENTER_VERTICAL);
    //水平方向
    setOrientation(HORIZONTAL);
    //视图滚动配置
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    //获取最小滚动距离
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    //最大滚动距离
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();

}
 
Example 26
Project: DailyZhiHu   File: CustomViewAbove.java   View source code 5 votes vote down vote up
void initCustomViewAbove() {
	setWillNotDraw(false);
	setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
	setFocusable(true);
	final Context context = getContext();
	mScroller = new Scroller(context, sInterpolator);
	final ViewConfiguration configuration = ViewConfiguration.get(context);
	mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
	mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
	mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
	setInternalPageChangeListener(new SimpleOnPageChangeListener() {
		public void onPageSelected(int position) {
			if (mViewBehind != null) {
				switch (position) {
				case 0:
				case 2:
					mViewBehind.setChildrenEnabled(true);
					break;
				case 1:
					mViewBehind.setChildrenEnabled(false);
					break;
				}
			}
		}
	});

	final float density = context.getResources().getDisplayMetrics().density;
	mFlingDistance = (int) (MIN_DISTANCE_FOR_FLING * density);
}
 
Example 27
Project: MyLife   File: ElasticDrawer.java   View source code 5 votes vote down vote up
@SuppressLint("NewApi")
protected void initDrawer(Context context, AttributeSet attrs, int defStyle) {
    setWillNotDraw(false);
    setFocusable(false);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ElasticDrawer);

    mMenuSize = a.getDimensionPixelSize(R.styleable.ElasticDrawer_edMenuSize, dpToPx(240));

    mMenuBackground = a.getColor(R.styleable.ElasticDrawer_edMenuBackground, 0xFFdddddd);

    mTouchBezelSize = a.getDimensionPixelSize(R.styleable.ElasticDrawer_edTouchBezelSize,
            dpToPx(DEFAULT_DRAG_BEZEL_DP));

    mMaxAnimationDuration = a.getInt(R.styleable.ElasticDrawer_edMaxAnimationDuration, DEFAULT_ANIMATION_DURATION);

    final int position = a.getInt(R.styleable.ElasticDrawer_edPosition, 0);
    setPosition(position);
    a.recycle();

    mMenuContainer = new NoClickThroughFrameLayout(context);
    mMenuContainer.setBackgroundColor(getResources().getColor(android.R.color.transparent));

    mContentContainer = new NoClickThroughFrameLayout(context);

    final ViewConfiguration configuration = ViewConfiguration.get(context);
    mTouchSlop = configuration.getScaledTouchSlop();
    mMaxVelocity = configuration.getScaledMaximumFlingVelocity();

    mScroller = new Scroller(context, SMOOTH_INTERPOLATOR);
    mCloseEnough = dpToPx(CLOSE_ENOUGH);

    mContentContainer.setLayerType(View.LAYER_TYPE_NONE, null);
    mContentContainer.setHardwareLayersEnabled(false);
}
 
Example 28
Project: APIJSON-Android-RxJava   File: XListView.java   View source code 5 votes vote down vote up
private void initWithContext(Context context) {
	setFadingEdgeLength(0); // 消除边界模糊
	setOverScrollMode(View.OVER_SCROLL_NEVER); // 消除滚动边框

	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 XListViewHeader(context);
	mHeaderViewContent = (RelativeLayout) mHeaderView
			.findViewById(R.id.xlistview_header_content);
	mHeaderTimeView = (TextView) mHeaderView.findViewById(R.id.xlistview_header_time);
	addHeaderView(mHeaderView);

	// init footer view
	mFooterView = new XListViewFooter(context);

	// init header height
	mHeaderView.getViewTreeObserver().addOnGlobalLayoutListener(
			new OnGlobalLayoutListener() {
				@SuppressWarnings("deprecation")
				@Override
				public void onGlobalLayout() {
					mHeaderViewHeight = mHeaderViewContent.getHeight();
					getViewTreeObserver()
					.removeGlobalOnLayoutListener(this);
				}
			});
}
 
Example 29
Project: Expert-Android-Programming   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 30
Project: aarLibrary   File: XRefreshView.java   View source code 5 votes vote down vote up
public XRefreshView(Context context, AttributeSet attrs) {
    super(context, attrs);
    setClickable(true);
    setLongClickable(true);
    mContentView = new XRefreshContentView();
    mHolder = new XRefreshHolder();
    mScroller = new Scroller(getContext(), new LinearInterpolator());

    initWithContext(context, attrs);
    setOrientation(VERTICAL);
}
 
Example 31
Project: DailyStudy   File: CoustomViewPager.java   View source code 5 votes vote down vote up
private void initView(Context context) {
    detector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            scrollBy((int) distanceX, 0);
            return true;
        }
    });
    scroller = new Scroller(context);
}
 
Example 32
Project: Building-Android-UIs-with-Custom-Views   File: GLDrawer.java   View source code 5 votes vote down vote up
public GLDrawer(Context context, AttributeSet attributeSet) {
    super(context, attributeSet);

    setEGLContextClientVersion(2);

    listener = null;
    gestureDetector = new GestureDetectorCompat(context, new MenuGestureListener());
    scroller = new Scroller(context);
    glRenderer = new GLRenderer();
    setRenderer(glRenderer);
}
 
Example 33
Project: Hotspot-master-devp   File: WheelView.java   View source code 5 votes vote down vote up
/**
 * Initializes class data
 * 
 * @param context
 *            the context
 */
private void initData(Context context) {
	gestureDetector = new GestureDetector(context, gestureListener);
	gestureDetector.setIsLongpressEnabled(false);

	scroller = new Scroller(context);
}
 
Example 34
Project: Hotspot-master-devp   File: WheelScroller.java   View source code 5 votes vote down vote up
/**
 * Constructor
 * 
 * @param context
 *            the current context
 * @param listener
 *            the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
	gestureDetector = new GestureDetector(context, gestureListener);
	gestureDetector.setIsLongpressEnabled(false);

	scroller = new Scroller(context);

	this.listener = listener;
	this.context = context;
}
 
Example 35
Project: Huochexing12306   File: MsgListView.java   View source code 5 votes vote down vote up
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 MsgHeader(context);
	mHeaderViewContent = (RelativeLayout) mHeaderView
			.findViewById(R.id.msg_header_content);
	// mHeaderTimeView = (TextView) mHeaderView
	// .findViewById(R.id.xlistview_header_time);
	addHeaderView(mHeaderView);

	// init footer view
	mFooterView = new XListViewFooter(context);

	// init header height
	mHeaderView.getViewTreeObserver().addOnGlobalLayoutListener(
			new OnGlobalLayoutListener() {
				@Override
				public void onGlobalLayout() {
					mHeaderViewHeight = mHeaderViewContent.getHeight();
					getViewTreeObserver()
							.removeGlobalOnLayoutListener(this);
				}
			});
}
 
Example 36
Project: CXJPadProject   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);
    }
    else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 37
Project: SelectName   File: DragScrollDetailsLayout.java   View source code 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
public DragScrollDetailsLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DragScrollDetailsLayout, defStyleAttr, 0);
    mPercent = a.getFloat(R.styleable.DragScrollDetailsLayout_percent, DEFAULT_PERCENT);
    mDuration = a.getInt(R.styleable.DragScrollDetailsLayout_duration, DEFAULT_DURATION);
    mDefaultPanel = a.getInt(R.styleable.DragScrollDetailsLayout_default_panel, 0);
    a.recycle();
    mScroller = new Scroller(getContext(), new DecelerateInterpolator());
    mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
    mMaxFlingVelocity = ViewConfiguration.get(getContext()).getScaledMaximumFlingVelocity();
    mMiniFlingVelocity = ViewConfiguration.get(getContext()).getScaledMinimumFlingVelocity();
    setOrientation(VERTICAL);
}
 
Example 38
Project: Android_ImagePicker   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 39
Project: OSchina_resources_android   File: TouchImageView.java   View source code 5 votes vote down vote up
public CompatScroller(Context context) {
    if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
        isPreGingerbread = true;
        scroller = new Scroller(context);

    } else {
        isPreGingerbread = false;
        overScroller = new OverScroller(context);
    }
}
 
Example 40
Project: mupdf-android-viewer-nui   File: WheelScroller.java   View source code 5 votes vote down vote up
/**
 * Constructor
 * @param context the current context
 * @param listener the scrolling listener
 */
public WheelScroller(Context context, ScrollingListener listener) {
    gestureDetector = new GestureDetector(context, gestureListener);
    gestureDetector.setIsLongpressEnabled(false);

    scroller = new Scroller(context);

    this.listener = listener;
    this.context = context;
}