Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: DeckPicker-NullPointerException in onQueryTextChange #17403

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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