codelab-friendlychat-android icon indicating copy to clipboard operation
codelab-friendlychat-android copied to clipboard

LinearLayoutManager tends to crash when new image inserted

Open Bela-Szilagyi opened this issue 3 years ago • 3 comments

I can catch the exception using this wrapper, and then everything goes fine, but it is not the properr way... class LlmWrapper(context: Context) : LinearLayoutManager(context) { override fun onLayoutChildren(recycler: RecyclerView.Recycler?, state: RecyclerView.State?) { Log.i("olc", state.toString()) try { super.onLayoutChildren(recycler, state) } catch (e: Exception) { Log.e("olc", "$e.localizedMessage") } } }

Bela-Szilagyi avatar Oct 06 '22 13:10 Bela-Szilagyi

I was also able to reproduce this issue. To mitigate this issue I downgrading firebase UI components to 7.2.0

    implementation 'com.firebaseui:firebase-ui-auth:7.2.0'
    implementation 'com.firebaseui:firebase-ui-database:7.2.0'

AndreasKl avatar Nov 09 '22 11:11 AndreasKl

I also experience this with version 8.0.2.

landov avatar Mar 07 '23 19:03 landov

I also ran into the same issue with version 8.0.2. This commit removed notifyDataSetChanged() from FirebaseRecyclerAdapter, so the process of notifying the adapter about changes is now gone. This is the cause of RecyclerView and java.lang.IndexOutOfBoundsException: Inconsistency detected. Text submissions are reflected in the RecyclerView without any problems, however, images don’t work well because adapter.stopListening() is called during image selection at onPause.

A simple solution is to add the following code to FriendlyMessageAdapter:

override fun stopListening() {
    super.stopListening()
    notifyDataSetChanged()
}

Aniokrait avatar Oct 01 '23 08:10 Aniokrait