0

Using Android kotlin firebase recycle view

I want to make the user take a picture of his phone or get a photo from gallery and add it to recyclerView list , and every time he takes a photo the recycler list increase automatically it works if i get the photo from drawable now i want to get it from camera or gallery. how to achieve it thanks

2 Answers2

0

Please refer to the documentation https://developer.android.com/guide/topics/ui/layout/recyclerview, under section Add a list adapter you can read a following information :

To feed all your data to the list, you must extend the RecyclerView.Adapter class. This object creates views for items, and replaces the content of some of the views with new data items when the original item is no longer visible.

So, basically you have to create adapter for your recycler view, from which you can insert new item (photo) to you recyclerview.

More information about implementation the functionality is here: How to update RecyclerView Adapter Data?

paweo90
  • 73
  • 8
0
  1. To capture/select photo from your gallery first you need permission accessing internal/external storage and camera I suggest you to read this https://developer.android.com/training/permissions/requesting

  2. If you are willing to use Firebase to get these drawable/imgs, so you've to get the URL of the image as a string and put it in ArrayList/List. Then your adapter class get URL and then use bitmap to download the image and convert it to bitmap (data type), How to load an ImageView by URL in Android?

  3. Now when retrieving data from fire base: https://firebase.google.com/docs/database/admin/retrieve-data add the string you got from the database in your arraylist then usenotifyOnDataChanged() to update your recyclerview. How to update RecyclerView Adapter Data?

dippas
  • 49,171
  • 15
  • 93
  • 105
Mina Roger
  • 39
  • 4