Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

Wrong View is passed to Adapter's getView if there are 2 pinned View types #73

Open
farmazon3000 opened this issue Jul 8, 2015 · 1 comment

Comments

@farmazon3000
Copy link

From time to time I'm getting wrong View as convertView in getView

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

I have 3 View types set: 2 of them are pinned SECTION_1 and SECTION_2 and 1 is ITEM

    @Override
    public int getViewTypeCount() {
        return 3;
    }

    @Override
    public int getItemViewType(int position) {
        return getItem(position).getType();
    }

    @Override
    public boolean isItemViewTypePinned(int viewType) {
        return viewType != ITEM;
    }

The Views for SECTION_1 and SECTION_2 are mixed up from time to time

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(null == convertView){
            if(ITEM == getItemViewType(position)){
                convertView = inflater.inflate(R.layout.circle_item, parent, false);
            }
            else if(SECTION_1 == getItemViewType(position)){
                convertView = inflater.inflate(R.layout.section_1, parent, false);
            }
            else if(SECTION_2 == getItemViewType(position)){
                convertView = inflater.inflate(R.layout.section_2, parent, false);
            }
        }
        else{
            if(ITEM == getItemViewType(position)){
                if(null == convertView.findViewById(R.id.item_element)){
                    Log.i(TAG, "ITEM not appropriate View");
                }
            }
            else if(SECTION_1 == getItemViewType(position)){
                if(null == convertView.findViewById(R.id.section_1_element)){
                    Log.i(TAG, "SECTION_1 not appropriate View");
                }
            }
            else if(SECTION_2 == getItemViewType(position)){
                if(null == convertView.findViewById(R.id.section_2_element)){
                    Log.i(TAG, "SECTION_2 not appropriate View");
                }
            }
        }

        return convertView;
    }
@farmazon3000 farmazon3000 changed the title Wrong View is passed to Adapter's getView when View Type Count is 3 Wrong View is passed to Adapter's getView when setShadowVisible is false Jul 8, 2015
@farmazon3000 farmazon3000 changed the title Wrong View is passed to Adapter's getView when setShadowVisible is false Wrong View is passed to Adapter's getView if there are 2 pinned View types Jul 8, 2015
@miroslavign
Copy link

miroslavign commented Aug 23, 2016

Any info about this one. Integrating this lib in a cursor adapter is fairly simple, but this issue is really annoying, and I can not get to the bottom of it.

Just a note, I am using it in a CursorAdapter class
...CursorAdapter implements SectionIndexer, PinnedSectionListView.PinnedSectionListAdapter

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants