Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TrackList: Fix crashes in selection mode #1723

Merged
merged 1 commit into from
Oct 8, 2023

Conversation

lmarz
Copy link
Contributor

@lmarz lmarz commented Oct 8, 2023

Fixes: #1711

The long click crash happened, because we didn't check whether we are already in selection mode.

The context menu item crash happened in setAllSelected, because item count != view holder count. That was a design error of me that the SparseBooleanArray uses the view holder positions, which change their contents, as the keys. So now I switched to using the trackIds, which are stored as Integers in the database, so we can easily convert them to long and back. This also simplifies the getSelectedIds method. The values from getSelectedPositions don't get used in the TrackListActivity, so we can just use null.

In regards to the recyclerview-selection library you mentioned, I deliberately decided against it, because

  1. It's an extra library we would need to include.
  2. The API, in my opinion, is awful. The method I used with the SparseBooleanArray is much more intuitive and easier to read to me.

I won't reimplement the selection mode using this library, but if someone gets along with the API and wants to implement this, feel free to :)

@dennisguse
Copy link
Member

Works!
Thx.

@lmarz is the MarkerList also affected by this?

@dennisguse dennisguse merged commit afbe941 into OpenTracksApp:main Oct 8, 2023
1 of 2 checks passed
@lmarz
Copy link
Contributor Author

lmarz commented Oct 8, 2023

Yes, thanks for reminding me

@lmarz lmarz deleted the fix_selection_crash branch October 8, 2023 11:29
@dennisguse
Copy link
Member

Fix is released as v4.9.1

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

Successfully merging this pull request may close these issues.

App crash in track selection mode
2 participants