0

I had seen lot of tutorials, but everywhere they have used dummy data while implementing heterogeneous Recyclerview( Text type, image type and video type posts in same recycler view).

Firebase database node structure: Firebase database

 Timeline   
       |---XqAWXQry50djimz8A5vg0sxskC43   
             |----LI0FKzQH4YhMEOePT91  
                     |---text_message:"the best painter in past centur"  
                     |---name: "Rahul"  
                     |---profile_pic:"https://firebasestorage.google..  
                     |---Image_post:"default"  
             |----KY1TWaSZ2MnRSXaCD68  
                     |---text_message:"default"  
                     |---name:"rahul"  
                     |---profile_pic:"https://firebasestorage.google....
                     |---Image_post:"https://firebasestorage.google.com/  

My model class:
Fmodel.java

model class

My First question is: How can i use constructor within the adapter class to retrive these data values from model class.
My Second question is: In the database structure i shared, First post is Text post and Second is Image post, how can i differentiate in the getItemViewType method in the adapter class.

From one of the fragment.java file in my project am setting the atributes setHasFixedSize(true) and setLayoutManager(linearLayoutManager). I have implemented recyclerview couple of times but with only one view type posts.

I have created adapter class, and seperate viewholders for text posts and image posts..But the basic thing is how can i retrieve model class dtata items using constructor within adapter class and how do i differentiate b/n
text post and image post within getItemViewType method.

Adapter class rough snippet:Adapter class

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
srini
  • 11
  • 1
  • 1
  • 1
    Welcome to Stack Overflow! Please don't post images of code. It's a real pain to work with images of text. Ideally, all relevant code should be included _as text_ directly in the question in form of a [mcve]. It's fine to _additionally_ provide a link to off-site code in order to give some context. – anothernode Jul 30 '18 at 12:38
  • **[This](https://stackoverflow.com/questions/49383687/how-can-i-retrieve-data-from-firebase-to-my-adapter/49384849)** is a recommended way in which you can retrieve data from a Firebase Realtime database and display it in a `RecyclerView` using `FirebaseRecyclerAdapter`. – Alex Mamo Jul 30 '18 at 12:54
  • I am trying to implement heterogeneous recyclerview . Trying to show Text post and Image posts in the same recyclerview using Multiadapter class. – srini Jul 30 '18 at 12:58

0 Answers0