pinned-section-listview icon indicating copy to clipboard operation
pinned-section-listview copied to clipboard

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

Open farmazon3000 opened this issue 8 years ago • 1 comments

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 avatar Jul 08 '15 11:07 farmazon3000

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

miroslavign avatar Aug 23 '16 22:08 miroslavign