From 61a89472e359ad97e2499a32443c052c187487df Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 27 Dec 2022 17:24:55 +0100 Subject: [PATCH] adding some recording adapter improvements --- .../voicerecorder/adapters/RecordingsAdapter.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/adapters/RecordingsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/adapters/RecordingsAdapter.kt index 17d6712..e714ca7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/adapters/RecordingsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/adapters/RecordingsAdapter.kt @@ -191,12 +191,13 @@ class RecordingsAdapter( } private fun doDeleteAnimation(oldRecordingIndex: Int, recordingsToRemove: ArrayList, positions: ArrayList) { - recordings.removeAll(recordingsToRemove) + recordings.removeAll(recordingsToRemove.toSet()) activity.runOnUiThread { if (recordings.isEmpty()) { refreshListener.refreshRecordings() finishActMode() } else { + positions.sortDescending() removeSelectedItems(positions) if (recordingsToRemove.map { it.id }.contains(currRecordingId)) { val newRecordingIndex = Math.min(oldRecordingIndex, recordings.size - 1) @@ -247,6 +248,11 @@ class RecordingsAdapter( override fun onChange(position: Int) = recordings.getOrNull(position)?.title ?: "" private fun showPopupMenu(view: View, recording: Recording) { + if (selectedKeys.isNotEmpty()) { + selectedKeys.clear() + notifyDataSetChanged() + } + finishActMode() val theme = activity.getPopupMenuTheme() val contextTheme = ContextThemeWrapper(activity, theme)