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

Avoid multiselect ANRs #1315

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
7.46
-----

7.45.1
-----
* Bug Fixes:
* Fixed issue where that could cause app freeze when using multiselect
([#1315](https://github.com/Automattic/pocket-casts-android/pull/1315))

7.45
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ class FilterEpisodeListFragment : BaseFragment() {
override fun multiSelectSelectNone() {
val episodes = viewModel.episodesList.value
if (episodes != null) {
episodes.forEach { multiSelectHelper.deselect(it) }
multiSelectHelper.deselectAllInList(episodes)
adapter.notifyDataSetChanged()
}
}
Expand All @@ -488,7 +488,7 @@ class FilterEpisodeListFragment : BaseFragment() {
val startIndex = episodes.indexOf(multiSelectable)
if (startIndex > -1) {
val episodesBelow = episodes.subList(startIndex, episodes.size)
episodesBelow.forEach { multiSelectHelper.deselect(it) }
multiSelectHelper.deselectAllInList(episodesBelow)
adapter.notifyDataSetChanged()
}
}
Expand All @@ -501,7 +501,7 @@ class FilterEpisodeListFragment : BaseFragment() {
val startIndex = episodes.indexOf(multiSelectable)
if (startIndex > -1) {
val episodesAbove = episodes.subList(0, startIndex + 1)
episodesAbove.forEach { multiSelectHelper.deselect(it) }
multiSelectHelper.deselectAllInList(episodesAbove)
adapter.notifyDataSetChanged()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,21 @@ class UpNextFragment : BaseFragment(), UpNextListener, UpNextTouchCallback.ItemT
multiSelectHelper.listener = object : MultiSelectHelper.Listener<BaseEpisode> {
override fun multiSelectSelectAll() {
trackUpNextEvent(AnalyticsEvent.UP_NEXT_SELECT_ALL_TAPPED, mapOf(SELECT_ALL_KEY to true))
upNextEpisodes.forEach { multiSelectHelper.select(it) }
multiSelectHelper.selectAllInList(upNextEpisodes)
adapter.notifyDataSetChanged()
}

override fun multiSelectSelectNone() {
trackUpNextEvent(AnalyticsEvent.UP_NEXT_SELECT_ALL_TAPPED, mapOf(SELECT_ALL_KEY to false))
upNextEpisodes.forEach { multiSelectHelper.deselect(it) }
multiSelectHelper.deselectAllInList(upNextEpisodes)
adapter.notifyDataSetChanged()
}

override fun multiSelectSelectAllUp(multiSelectable: BaseEpisode) {
val startIndex = upNextEpisodes.indexOf(multiSelectable)
if (startIndex > -1) {
upNextEpisodes.subList(0, startIndex + 1).forEach { multiSelectHelper.select(it) }
val episodesAbove = upNextEpisodes.subList(0, startIndex + 1)
multiSelectHelper.selectAllInList(episodesAbove)
}

adapter.notifyDataSetChanged()
Expand All @@ -267,7 +268,8 @@ class UpNextFragment : BaseFragment(), UpNextListener, UpNextTouchCallback.ItemT
override fun multiSelectSelectAllDown(multiSelectable: BaseEpisode) {
val startIndex = upNextEpisodes.indexOf(multiSelectable)
if (startIndex > -1) {
upNextEpisodes.subList(startIndex, upNextEpisodes.size).forEach { multiSelectHelper.select(it) }
val episodesBelow = upNextEpisodes.subList(startIndex, upNextEpisodes.size)
multiSelectHelper.selectAllInList(episodesBelow)
}

adapter.notifyDataSetChanged()
Expand All @@ -276,15 +278,17 @@ class UpNextFragment : BaseFragment(), UpNextListener, UpNextTouchCallback.ItemT
override fun multiDeselectAllBelow(multiSelectable: BaseEpisode) {
val startIndex = upNextEpisodes.indexOf(multiSelectable)
if (startIndex > -1) {
upNextEpisodes.subList(startIndex, upNextEpisodes.size).forEach { multiSelectHelper.deselect(it) }
val episodesBelow = upNextEpisodes.subList(startIndex, upNextEpisodes.size)
multiSelectHelper.deselectAllInList(episodesBelow)
}
adapter.notifyDataSetChanged()
}

override fun multiDeselectAllAbove(multiSelectable: BaseEpisode) {
val startIndex = upNextEpisodes.indexOf(multiSelectable)
if (startIndex > -1) {
upNextEpisodes.subList(0, startIndex + 1).forEach { multiSelectHelper.deselect(it) }
val episdesAbove = upNextEpisodes.subList(0, startIndex + 1)
multiSelectHelper.deselectAllInList(episdesAbove)
}
adapter.notifyDataSetChanged()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class BookmarksViewModel

override fun multiSelectSelectNone() {
(_uiState.value as? UiState.Loaded)?.bookmarks?.let { bookmarks ->
bookmarks.forEach { multiSelectHelper.deselect(it) }
multiSelectHelper.deselectAllInList(bookmarks)
}
}

Expand All @@ -128,8 +128,8 @@ class BookmarksViewModel
(_uiState.value as? UiState.Loaded)?.bookmarks?.let { bookmarks ->
val startIndex = bookmarks.indexOf(multiSelectable)
if (startIndex > -1) {
bookmarks.subList(startIndex, bookmarks.size)
.forEach { multiSelectHelper.deselect(it) }
val bookmarksBelow = bookmarks.subList(startIndex, bookmarks.size)
multiSelectHelper.deselectAllInList(bookmarksBelow)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class ProfileEpisodeListFragment : BaseFragment(), Toolbar.OnMenuItemClickListen
override fun multiSelectSelectNone() {
val episodes = viewModel.episodeList.value
if (episodes != null) {
episodes.forEach { multiSelectHelper.deselect(it) }
multiSelectHelper.deselectAllInList(episodes)
adapter.notifyDataSetChanged()
trackSelectAll(false)
}
Expand Down Expand Up @@ -289,7 +289,8 @@ class ProfileEpisodeListFragment : BaseFragment(), Toolbar.OnMenuItemClickListen
if (episodes != null) {
val startIndex = episodes.indexOf(multiSelectable)
if (startIndex > -1) {
episodes.subList(startIndex, episodes.size).forEach { multiSelectHelper.deselect(it) }
val episodesBelow = episodes.subList(startIndex, episodes.size)
multiSelectHelper.deselectAllInList(episodesBelow)
adapter.notifyDataSetChanged()
}
}
Expand All @@ -300,7 +301,8 @@ class ProfileEpisodeListFragment : BaseFragment(), Toolbar.OnMenuItemClickListen
if (episodes != null) {
val startIndex = episodes.indexOf(multiSelectable)
if (startIndex > -1) {
episodes.subList(0, startIndex + 1).forEach { multiSelectHelper.deselect(it) }
val episodesAbove = episodes.subList(0, startIndex + 1)
multiSelectHelper.deselectAllInList(episodesAbove)
adapter.notifyDataSetChanged()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class CloudFilesFragment : BaseFragment(), Toolbar.OnMenuItemClickListener {
override fun multiSelectSelectNone() {
val episodes = viewModel.cloudFilesList.value
if (episodes != null) {
episodes.forEach { multiSelectHelper.deselect(it) }
multiSelectHelper.deselectAllInList(episodes)
adapter.notifyDataSetChanged()
analyticsTracker.track(AnalyticsEvent.UPLOADED_FILES_SELECT_ALL_TAPPED, mapOf(SELECT_ALL_KEY to false))
}
Expand Down