android-GridViewWithHeaderAndFooter icon indicating copy to clipboard operation
android-GridViewWithHeaderAndFooter copied to clipboard

ItemClickHandler wrong position

Open mtrakal opened this issue 10 years ago • 3 comments

Hello I use latest version: compile 'in.srain.cube:grid-view-with-header-footer:1.0.12'

I have 4 items on row and many rows (item is clickable and contains included buttons on layout). It works like expected, but not when I'm scrolled on top (it everytime click on Item on position 0). When I scroll a few pixels, it works like expected (click on item show detail, click on buttons in item layout make action).

When I'm on top of gridView (I have just footer, no header) method:

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (mOnItemClickListener != null) {
                int resPos = position - getHeaderViewCount() * getNumColumnsCompatible();
                if (resPos >= 0) {
                    mOnItemClickListener.onItemClick(parent, view, resPos, id);
                }
            }
        }

has position = 0; But it should has position 3 when I click on item on fourth position.

mtrakal avatar Jun 17 '15 11:06 mtrakal

Hello,

sorry for that. I test it on empty project later and it works. I tried to change your lib to https://github.com/recruit-mp/android-HeaderFooterGridView and it make same issue. So it's some bug in our app.

This issue we see only on KK and LP.

Sorry for open issue which does not exists. Best regard Matej

mtrakal avatar Jun 24 '15 13:06 mtrakal

There is a problem when this both HeaderFooter GridView are nested into SwipeRefreshLayout. It looks on some problem with SwipeRefreshLayout and nested Layouts...

mtrakal avatar Jun 24 '15 13:06 mtrakal

Hi, There is some question,i used this,but sometimes it has exception when click item

and there is the log i take before exception

E/gridwithheaderfooter: position:27 headerviewcount:1 numcolumns:3 repos:24 java.lang.IndexOutOfBoundsException: Invalid index 24, size is 22 GridViewWithHeaderAndFooter$ItemClickHandler.onItemClick(GridViewWithHeaderAndFooter.java:874)

zhaoli-android avatar Nov 20 '15 13:11 zhaoli-android