ManuelPeinado / MultiChoiceAdapter

Android - A ListView adapter with support for multiple choice modal selection
Apache License 2.0
849 stars 260 forks source link

removing item won't adjust checked indizes #13

Open MFlisar opened 11 years ago

MFlisar commented 11 years ago

Is there a reason for that? You did not override the remove functions...

So you always have to adjust all the selected items indizes afterwards manually

Normally, that's no problem, because after deleting the selected items, 'finishActionMode();' should be called... But I discovered this problem, because I'm deleting local/online files and I'm waiting for my thread callback and it may happen, that only some of the files could be deleted, so I don't necessaraly call the 'finishActionMode();'...

ManuelPeinado commented 11 years ago

Hi, thanks for the feedback and for using the library.

When you talk about the "remove functions", you mean just ArrayAdapter#remove, right?

I guess I could have overridden that to deselect the remove item automatically, but as you point out the most common thing is to call finishActionMode() afterwards so I didn't think it would be that useful.

As a workaround, you can probably do this ("adapter" is an instance of MultiChoiceArrayAdapter):

int position = adapter.getPosition(item);
adapter.remove(item);
adapter.setItemChecked(position);