Skip to content

Commit

Permalink
Fix DeckPicker-NullPointerException in onQueryTextChange
Browse files Browse the repository at this point in the history
  • Loading branch information
Giyutomioka-SS authored and mikehardy committed Nov 29, 2024
1 parent d0acd30 commit 34b36c1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,21 @@ open class DeckPicker :
}

override fun onQueryTextChange(newText: String): Boolean {
val adapter = recyclerView.adapter as Filterable?
adapter!!.filter.filter(newText)
val adapter = recyclerView.adapter as? Filterable
if (adapter == null || adapter.filter == null) {
Timber.w(
"DeckPicker.onQueryTextChange: adapter is null: %s, filter is null: %s, adapter type: %s",
adapter == null,
adapter?.filter == null,
adapter?.javaClass?.simpleName ?: "Unknown"
)
CrashReportService.sendExceptionReport(
Exception("DeckPicker.onQueryTextChanged with unexpected null adapter or filter. Carefully examine logcat"),
"DeckPicker"
)
return true
}
adapter.filter.filter(newText)
return true
}
})
Expand Down

0 comments on commit 34b36c1

Please sign in to comment.