applm / ma-components

Android library with some Widgets and handy pieces of code I have developed
Other
161 stars 220 forks source link

CoverFlow OnPageChangeListener #5

Open SemonCat opened 9 years ago

SemonCat commented 9 years ago

Hi,

I want to get notify when CoverFlow position change.

Did you write listener for that event?

applm commented 9 years ago

Hi, it wont be completely trivial, but you can add it yourself. Look into computeScroll method.

    if (mTouchState == TOUCH_STATE_ALIGN) {
        if(mAlignScroller.computeScrollOffset()) {
            if(mAlignScroller.getFinalX() == mAlignScroller.getCurrX()){
                mAlignScroller.abortAnimation();
                mTouchState = TOUCH_STATE_RESTING;
                clearChildrenCache();
                return;             
            }

            int x = mAlignScroller.getCurrX();
            scrollTo(x, 0);

            postInvalidate();
            return;
        }
        else{
            mTouchState = TOUCH_STATE_RESTING;
            clearChildrenCache();

                    //Here should be coverflow settled on new position. Use getScrollPosition()
                    //and fire event here.

            return;
        }
   }

Then you will probably need to find more places to cover all situations where coverflow is moved. From top of my head it could be in OnTouchEvent (superclass) on UP event. Then in method setScrollPosition. Let me know how it goes and please submit pull request if you manage to make it.

pangminfu commented 9 years ago

I need this listener as well will is this being fixed?