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

ItemFilter publishResults NPE #1037

Closed
AlexDeadman opened this issue Sep 22, 2022 · 1 comment · Fixed by #1038
Closed

ItemFilter publishResults NPE #1037

AlexDeadman opened this issue Sep 22, 2022 · 1 comment · Fixed by #1038
Assignees

Comments

@AlexDeadman
Copy link

Initializing itemFilterListener like

itemFilterListener =
    object : ItemFilterListener<ListItem> {
        override fun itemsFiltered(
            constraint: CharSequence?,
            results: List<ListItem>?
        ) {
            // code
        }

        override fun onReset() {
            // code
        }
    }

and filtering with SearchView

searchView.setOnQueryTextListener(
    object : SearchView.OnQueryTextListener {
        override fun onQueryTextChange(newText: String): Boolean {
            itemAdapter.filter(newText)
            return true
        }

        override fun onQueryTextSubmit(query: String): Boolean = false
    }
)

throws an exception on navigation between fragments (on navigate back to fragment having SearchView)

java.lang.NullPointerException: null cannot be cast to non-null type kotlin.collections.List<Item of com.mikepenz.fastadapter.adapters.ItemFilter>
    at com.mikepenz.fastadapter.adapters.ItemFilter.publishResults(ItemFilter.kt:104)
    at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:284)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:246)
    at android.app.ActivityThread.main(ActivityThread.java:8653)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
@AlexDeadman
Copy link
Author

Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants