Home Firebase UI RecyclerView - Handling mapping
Reply: 0

Firebase UI RecyclerView - Handling mapping

user1542
1#
user1542 Published in August 16, 2018, 6:15 am

Below is my sample structure:

channels
    |
    |____channel0
               |
               |___messages
                     |
                     |_______ uniqueKey0: true
                     |
                     |_______ uniqueKey1: true   


 messages
   |
   |_____ uniqueKey0
   |          |______ from: Alex
   |          |______ text: Hi!
   |
   |
   |_____ uniqueKey1
             |______ from: Kate
             |______ text: Hello

I am trying out Firebase UI Recycler View to messages. I have two questions:

  1. What I am doing is giving ref of /channels/messages to FirebaseAdapter and get the key. Once key is fetched, I fetch details and then populate the view holder. In this case, am not sure how to handle the case where a message's text is changed. Because since am listening to /channels/messages, I don't get the event of message change.

  2. To tackle the above problem, I was thinking of the following structure, which I know is against the best practices since am supposed to keep data as flat as possible. So I wanted I know that going for this approach is really that bad or makes more sense in this case?

     messages
       |
       |____channel0
             |_____ uniqueKey0
             |          |______ from: Alex
             |          |______ text: Hi!
             |
             |
             |_____ uniqueKey1
                        |______ from: Kate
                        |______ text: Hello
    
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.29821 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO