From ac824c559846135d6b03f7c4bbac908c2a770a08 Mon Sep 17 00:00:00 2001 From: Luca Stefani Date: Thu, 3 Aug 2023 19:07:23 +0200 Subject: [PATCH] Glimpse: Streamline BaseCursorAdapter cursor close-up Change-Id: Ic4e9fb6d04c93e9286640475fc0ce1964b85ac2f --- .../lineageos/glimpse/thumbnail/BaseCursorAdapter.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/lineageos/glimpse/thumbnail/BaseCursorAdapter.kt b/app/src/main/java/org/lineageos/glimpse/thumbnail/BaseCursorAdapter.kt index 60262c1..6556eb0 100644 --- a/app/src/main/java/org/lineageos/glimpse/thumbnail/BaseCursorAdapter.kt +++ b/app/src/main/java/org/lineageos/glimpse/thumbnail/BaseCursorAdapter.kt @@ -15,18 +15,16 @@ abstract class BaseCursorAdapter : RecyclerView.Ada override fun getItemCount() = cursor?.count ?: 0 fun changeCursor(cursor: Cursor?) { - val oldCursor = swapCursor(cursor) - oldCursor?.close() - + swapCursor(cursor) onChangedCursor(cursor) } protected open fun onChangedCursor(cursor: Cursor?) {} @SuppressLint("NotifyDataSetChanged") - private fun swapCursor(cursor: Cursor?): Cursor? { + private fun swapCursor(cursor: Cursor?) { if (this.cursor == cursor) { - return null + return } val oldCursor = this.cursor @@ -36,6 +34,6 @@ abstract class BaseCursorAdapter : RecyclerView.Ada notifyDataSetChanged() } - return oldCursor + oldCursor?.close() } }