etsy / AndroidStaggeredGrid

An Android staggered grid view which supports multiple columns with rows of varying sizes.
https://github.com/etsy/AndroidStaggeredGrid
4.76k stars 1.13k forks source link

How can I implement setSelectionFromTop() method list ListView in ExtendableListView? #119

Open sungeuns opened 10 years ago

sungeuns commented 10 years ago

Hi, at first I want to appreciate about sharing this awesome library.

I've tried to implement setSelectionFromTop() method that exist in ListView. So I look into source code of ListView in AOSP, and did it similar way like this in ExtendableLsitView.java :

    public void setSelectionFromTop(final int position, int y){
        if(mAdapter == null){
            return;
        }

        if(position >= 0){ 
            mLayoutMode = LAYOUT_SPECIFIC;
            mSpecificTop = getListPaddingTop() + y;

            //Utils.log("what is mSpecificTop : "+mSpecificTop);

            if(mNeedSync){
                mSyncPosition = position;
                mSyncRowId = mAdapter.getItemId(position);
            }

            mGeneralPurposePosition = position;
            requestLayout();
        }
    }

Also I added layout mode of LAYOUT_SPECIFIC in layoutChildren() method like below:

                case LAYOUT_SPECIFIC:
                    fillSpecific(mGeneralPurposePosition, mSpecificTop);
                    break;

It seems like almost work, but the position is different that I thought. (That means it moves to inaccurate position)

Is there any hint about how can I implement setSelectionFromTop() function?

Thanks in advance!