From 3437ad7e5991fc777f666e100c5d79763d9589c1 Mon Sep 17 00:00:00 2001 From: Mosayeb Angashteh <108512702+mosayeb-a@users.noreply.github.com> Date: Mon, 8 Jan 2024 00:53:31 -0800 Subject: [PATCH] fix CursorIndexOutOfBoundsException (#630) * handle CursorIndexOutOfBoundsException exception with coerceAtLeast method --- .../kotlin/com/looker/droidify/ui/appList/AppListAdapter.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/looker/droidify/ui/appList/AppListAdapter.kt b/app/src/main/kotlin/com/looker/droidify/ui/appList/AppListAdapter.kt index 64fa6a6a5..f62ef3fc7 100644 --- a/app/src/main/kotlin/com/looker/droidify/ui/appList/AppListAdapter.kt +++ b/app/src/main/kotlin/com/looker/droidify/ui/appList/AppListAdapter.kt @@ -1,5 +1,6 @@ package com.looker.droidify.ui.appList +import android.annotation.SuppressLint import android.content.Context import android.view.Gravity import android.view.View @@ -76,12 +77,14 @@ class AppListAdapter( } var repositories: Map = emptyMap() + @SuppressLint("NotifyDataSetChanged") set(value) { field = value notifyDataSetChanged() } var emptyText: String = "" + @SuppressLint("NotifyDataSetChanged") set(value) { if (field != value) { field = value @@ -109,7 +112,7 @@ class AppListAdapter( } private fun getProductItem(position: Int): ProductItem { - return Database.ProductAdapter.transformItem(moveTo(position)) + return Database.ProductAdapter.transformItem(moveTo(position.coerceAtLeast(0))) } override fun onCreateViewHolder(