public ExtendedListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); super.setOnScrollListener(this); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ExtendedListView); final int scrollBarPanelLayoutId = a.getResourceId(R.styleable.ExtendedListView_scrollBarPanel, -1); final int scrollBarPanelInAnimation = a.getResourceId( R.styleable.ExtendedListView_scrollBarPanelInAnimation, R.anim.scroll_bar_panel_in); final int scrollBarPanelOutAnimation = a.getResourceId( R.styleable.ExtendedListView_scrollBarPanelOutAnimation, R.anim.scroll_bar_panel_out); a.recycle(); if (scrollBarPanelLayoutId != -1) { setScrollBarPanel(scrollBarPanelLayoutId); } final int scrollBarPanelFadeDuration = ViewConfiguration.getScrollBarFadeDuration(); if (scrollBarPanelInAnimation > 0) { inAnimation = AnimationUtils.loadAnimation(getContext(), scrollBarPanelInAnimation); } if (scrollBarPanelOutAnimation > 0) { outAnimation = AnimationUtils.loadAnimation(getContext(), scrollBarPanelOutAnimation); outAnimation.setDuration(scrollBarPanelFadeDuration); outAnimation.setAnimationListener( new AnimationListener() { @Override public void onAnimationStart(Animation animation) {} @Override public void onAnimationRepeat(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { if (scrollBarPanel != null) { scrollBarPanel.setVisibility(View.GONE); } } }); } }
@Test public void methodsShouldReturnAndroidConstants() { Activity context = new Activity(); ViewConfiguration viewConfiguration = ViewConfiguration.get(context); assertEquals(10, ViewConfiguration.getScrollBarSize()); assertEquals(250, ViewConfiguration.getScrollBarFadeDuration()); assertEquals(300, ViewConfiguration.getScrollDefaultDelay()); assertEquals(12, ViewConfiguration.getFadingEdgeLength()); assertEquals(125, ViewConfiguration.getPressedStateDuration()); assertEquals(500, ViewConfiguration.getLongPressTimeout()); assertEquals(115, ViewConfiguration.getTapTimeout()); assertEquals(500, ViewConfiguration.getJumpTapTimeout()); assertEquals(300, ViewConfiguration.getDoubleTapTimeout()); assertEquals(12, ViewConfiguration.getEdgeSlop()); assertEquals(16, ViewConfiguration.getTouchSlop()); assertEquals(16, ViewConfiguration.getWindowTouchSlop()); assertEquals(50, ViewConfiguration.getMinimumFlingVelocity()); assertEquals(4000, ViewConfiguration.getMaximumFlingVelocity()); assertEquals(320 * 480 * 4, ViewConfiguration.getMaximumDrawingCacheSize()); assertEquals(3000, ViewConfiguration.getZoomControlsTimeout()); assertEquals(500, ViewConfiguration.getGlobalActionKeyTimeout()); assertEquals(0.015f, ViewConfiguration.getScrollFriction()); assertEquals(1f, context.getResources().getDisplayMetrics().density); assertEquals(10, viewConfiguration.getScaledScrollBarSize()); assertEquals(12, viewConfiguration.getScaledFadingEdgeLength()); assertEquals(12, viewConfiguration.getScaledEdgeSlop()); assertEquals(16, viewConfiguration.getScaledTouchSlop()); assertEquals(32, viewConfiguration.getScaledPagingTouchSlop()); assertEquals(100, viewConfiguration.getScaledDoubleTapSlop()); assertEquals(16, viewConfiguration.getScaledWindowTouchSlop()); assertEquals(50, viewConfiguration.getScaledMinimumFlingVelocity()); assertEquals(4000, viewConfiguration.getScaledMaximumFlingVelocity()); }