public OverScrollBounceEffectDecoratorBase(IOverScrollDecoratorAdapter viewAdapter, float decelerateFactor, float touchDragRatioFwd, float touchDragRatioBck) { mViewAdapter = viewAdapter; mBounceBackState = new BounceBackState(decelerateFactor); mOverScrollingState = new OverScrollingState(touchDragRatioFwd, touchDragRatioBck); mIdleState = new IdleState(); mCurrentState = mIdleState; attach(); }
@Override public void handleEntryTransition(IDecoratorState fromState) { mStateListener.onOverScrollStateChange(OverScrollBounceEffectDecoratorBase.this, fromState.getStateId(), this.getStateId()); } }
@Override public void handleEntryTransition(IDecoratorState fromState) { mCurrDragState = (mStartAttr.mDir ? STATE_DRAG_START_SIDE : STATE_DRAG_END_SIDE); mStateListener.onOverScrollStateChange(OverScrollBounceEffectDecoratorBase.this, fromState.getStateId(), this.getStateId()); } }
protected VerticalOverScrollBounceEffectDecorator getUUT(float touchDragRatioFwd, float touchDragRatioBck) { VerticalOverScrollBounceEffectDecorator uut = new VerticalOverScrollBounceEffectDecorator(mViewAdapter, touchDragRatioFwd, touchDragRatioBck, DEFAULT_DECELERATE_FACTOR); uut.setOverScrollStateListener(mStateListener); uut.setOverScrollUpdateListener(mUpdateListener); return uut; } }
@Override public void handleEntryTransition(IDecoratorState fromState) { mStateListener.onOverScrollStateChange(OverScrollBounceEffectDecoratorBase.this, fromState.getStateId(), this.getStateId()); Animator bounceBackAnim = createAnimator(); bounceBackAnim.addListener(this); bounceBackAnim.start(); }
protected HorizontalOverScrollBounceEffectDecorator getUUT(float touchDragRatioFwd, float touchDragRatioBck) { HorizontalOverScrollBounceEffectDecorator uut = new HorizontalOverScrollBounceEffectDecorator(mViewAdapter, touchDragRatioFwd, touchDragRatioBck, DEFAULT_DECELERATE_FACTOR); uut.setOverScrollStateListener(mStateListener); uut.setOverScrollUpdateListener(mUpdateListener); return uut; } }
@Override public boolean handleUpOrCancelTouchEvent(MotionEvent event) { issueStateTransition(mBounceBackState); return false; }
protected void issueStateTransition(IDecoratorState state) { IDecoratorState oldState = mCurrentState; mCurrentState = state; mCurrentState.handleEntryTransition(oldState); }
public OverScrollingState(float touchDragRatioFwd, float touchDragRatioBck) { mMoveAttr = createMotionAttributes(); mTouchDragRatioFwd = touchDragRatioFwd; mTouchDragRatioBck = touchDragRatioBck; }
@Override protected AnimationAttributes createAnimationAttributes() { return new AnimationAttributesHorizontal(); }
@Override protected MotionAttributes createMotionAttributes() { return new MotionAttributesVertical(); }
@Override protected AnimationAttributes createAnimationAttributes() { return new AnimationAttributesVertical(); }
public BounceBackState(float decelerateFactor) { mDecelerateFactor = decelerateFactor; mDoubleDecelerateFactor = 2f * decelerateFactor; mAnimAttributes = createAnimationAttributes(); }
private void initVerticalScrollView(ScrollView scrollView) { OverScrollDecoratorHelper.setUpOverScroll(scrollView); }
@Override public void setOverScrollStateListener(IOverScrollStateListener listener) { mStateListener = (listener != null ? listener : new OverScrollStateListenerStub()); }
@Override public int getCurrentState() { return mCurrentState.getStateId(); }
@Override protected MotionAttributes createMotionAttributes() { return new MotionAttributesHorizontal(); }
protected VerticalOverScrollBounceEffectDecorator getUUT() { VerticalOverScrollBounceEffectDecorator uut = new VerticalOverScrollBounceEffectDecorator(mViewAdapter); uut.setOverScrollStateListener(mStateListener); uut.setOverScrollUpdateListener(mUpdateListener); return uut; }
protected HorizontalOverScrollBounceEffectDecorator getUUT() { HorizontalOverScrollBounceEffectDecorator uut = new HorizontalOverScrollBounceEffectDecorator(mViewAdapter); uut.setOverScrollStateListener(mStateListener); uut.setOverScrollUpdateListener(mUpdateListener); return uut; }
@Override public void onAnimationEnd(Animator animation) { issueStateTransition(mIdleState); }