Search code examples
androidfirebasefirebase-realtime-databasefirebaseui

FirebaseListAdapter, How to update individual list views after populateView


I have implemented a firebase list adapter to load a list of items (List A). My data structure is setup such that within List A, each item also contains a reference id to some information located somewhere else (isNice) in the database. Likewise:

ListA
- ObjA
  - title : "hi"
  - id : "ObjAid"

isNice
- ObjAid : "true"

I'm currently using another database operation to look up the id in the "isNice" child, passing the "ObjAid", the list position, and then a resultReceiver to get the result back. My problem is, when the resultReceiver get a resultData (the value "true"), I have no idea how modify the data within firebase list at the specific position.

My past experience is to use load my data into my own ArrayList and create a custom adapter for the listView, in that case, I could easily update the populated view as extra information is loaded. I would like to avoid setting up my own ArrayList to store the data for the time being, favoring the simplicity of the FirebaseListAdapter. All tips are appreciated, thx :)


Solution

  • After some trial and error, I've instead gone with the RecyclerView + FirebaseRecyclerViewAdapter approach. Using recycler is better for the long run too, in my use case the list could get to 3K+. Using RecyclerView.findViewHolderForAdapterPosition() I can reference the specific itemView after I get the data from the result receiver likewise:

    // Reference the Item's view at the specific position
    myViewHolder itemViewHolder = recyclerView.findViewHolderForAdapterPosition(position);
    // Reference and set the views and here......