mpcjanssen / simpletask-android

GNU General Public License v3.0
545 stars 124 forks source link

Use actionMode for selection #624

Open smichel17 opened 7 years ago

smichel17 commented 7 years ago

Instead of abusing onCreateOptionsMenu, there's already a class in the support library for that.

https://developer.android.com/reference/android/support/v7/view/ActionMode.html

mpcjanssen commented 7 years ago

I wouldn't call it abusing. And using ActionMode again adds another layer of confusion. Considering it's working fine as is, I prefer to only do this if it's really needed.

smichel17 commented 7 years ago

Okay, abusing may be a little harsh.

I still think we should look into it; I believe actionMode will implement the default animations for entering selection, which is nice. I think it will also simplify our selection code, since it keeps track of when items in the RecyclerView are selected and triggers the right callbacks automatically.

mpcjanssen commented 7 years ago

Especially the second point looks interesting. I will look into it.

smichel17 commented 7 years ago

Go here and then scroll to Enabling batch contextual actions in a ListView or GridView.

mpcjanssen commented 7 years ago

@smichel17 Note that a ListView and a RecyclerView are quite different. Not sure if it matters here.

smichel17 commented 7 years ago

@mpcjanssen once we

it'll be trivial to call the correct actionMode callback upon receiving a message that selection has changed.

smichel17 commented 7 years ago

It does matter that ListView and RecyclerView are different. Here's someone making them work together. It's a reasonable amount of code, but that's because he made it very modular.

https://medium.com/@BladeCoder/implementing-a-modal-selection-helper-for-recyclerview-1e888b4cd5b9