Skip to content

Commit

Permalink
fix CursorIndexOutOfBoundsException (#630)
Browse files Browse the repository at this point in the history
* handle CursorIndexOutOfBoundsException exception with coerceAtLeast method
  • Loading branch information
mosayeb-a authored Jan 8, 2024
1 parent acf5430 commit 3437ad7
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -76,12 +77,14 @@ class AppListAdapter(
}

var repositories: Map<Long, Repository> = emptyMap()
@SuppressLint("NotifyDataSetChanged")
set(value) {
field = value
notifyDataSetChanged()
}

var emptyText: String = ""
@SuppressLint("NotifyDataSetChanged")
set(value) {
if (field != value) {
field = value
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 3437ad7

Please sign in to comment.