How add photo to recycleview using Android kotlin firebase - android

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

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?

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
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?
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?

Related

MVVM : fetch data from server and notify item

I will take an example to explain my problem : in a search screen, I need to search for a big list of movies.
I can bookmark each movie, so I need to notify my item in my recycler, here is my problem.
Do I need to put every movies searched in room database and it will be simple after for the notify with MVVM & DiffUtils?
Because, when I used MVP, I created a small database with MovieId and a boolean for bookmark, and when the user bookmark a movie, I run through in my items in adapter and notify the concerned item. But this solution is very ugly now with MVVM.
Thanks in advance
Just for the search screen you don't need to save data to local database. Instead of that you can just bind one list to RecyclerView and update it with another list from API using DiffUtils.

How to customzie my RecyclerView Adapter to show the ImageView directly for the sender?

I am working on an Android/Firebase chat app that send images.
After a gallery intent, I get the Uri in onActivityResult and assign it to a public Uri in the activity.
My question is that how can I customize the RecyclerView adapter to show the image directly for the sender only without the need to wait the image to be uploaded to Firebase then retrieving it?
Try in the sender bind in your adapter to set the image with Picasso and with if statement: if(theUri != null)

String Image Url set in imageview Android

I Need a help for My First develop android app. I want to set a image with the help of url in my ImageView which is coming from google Api. I have a listView in Which the data are coming from google apis. in Listview, I implement a image with the help of picasso android libruary. I am using a fragment when the user click on each list item from listView. On CLick of listItem I am opening a fragment on Which I need To display a data of list Item.
For ListView, I am using a userDefined List in which the images are of type
In DetailFragment where I want to display the details I am using the below Source Code.
#Override
public void findViewById() {
foodtitle=(TextView)mView.findViewById(R.id.detail_foodtext);
foodsubtitle=(TextView)mView.findViewById(R.id.detail_foodsubtext);
foodresImage=(ImageView)mView.findViewById(R.id.detail_image_left);
foodaddress=(TextView) mView.findViewById(R.id.detail_foodaddress);
Bundle b=getArguments();
b.getString("ItemName");
b.getString("ItemSubItem");
b.getInt("ItemImage");
b.getString("ItemAddress");
foodtitle.setText(b.getString("ItemName"));
foodsubtitle.setText(b.getString("ItemSubItem"));
foodresImage.setImageResource(b.getInt("ItemImage"));
foodaddress.setText(b.getString("ItemAddress"));
}
on This place
foodresImage.setImageResource(b.getInt("ItemImage"));
I want my Image which is one imageView in detail Fragment.
Since you are using Picasso then you should use it like:
Picasso.with(getContext()).load(fb.getString("ItemImage")).into(foodresImage);
You are using fb.getInt() in your setImageResource and you are getting a string from the Google API. You cannot convert the link to an int resource.

Android Gallery objects obtained from network to Individual gallery object

GridGalleryThumbnailFragment to photoActivity
All the gallery objects are obtained from internet, my current setup is whenever user reaches the Fragment a network request is made and if it successful the gallery objects with thumbnails and image urls are returned. When the user clicks on an individual item a intent will start the activity and puts extra intent data with image title and image url and the image is opened in full screen. Now I want to implement a next/previous functionality in the Activity, what is the best approach for it.
Make a second network request in the activity and get the values from this new adapter.
Remove the activity workflow and just replace View in the fragment with the full image view.
Store all the values obtained the first time around in android local storage.
You need two adapters which have the same data in the same order:
a GalleryAdapter and a ImagePagerAdapter
When the GalleryView starts the ImageView the ImageView needs the gallery-s current offset. next/previous is just adding 1 to or subtracting 1 from the offset.
I have implemented something similar but based on a database query using a CursorAdapter and a android.support.v4.view.PagerAdapter . Both GalleryView and ImageView share the same sql.
[Update]
If you donot want to load the data twice you can use a LoaderManager where GalleryView and ImageView both use the same loader-Impementation/loader-ID

show data in list view in Sales Force?

I am new to Sales Force
I want display list in Android program based on my Sales Force object data i was done the following steps:
based on call back and consumer key i successfully lo-gin to the API.and i navigate though all the controls in the trail version
how can i display the list of the items in Android Program is there any sample program to fetch and display data in the Android List view.please send any useful links to me to achieve this.
Thanks in Advance.....
if you want to display the list of items using ListView .you can write a DataAdapter which extend BaseAdapter ,in the construtor method ,you set the data that you want to display as the parameter . then overwrite getView() method , you will make the item displayed .
key words: ListActivity , BaseAdapter.

Categories

Resources