get data from api and show in recyclerview - java

i want to get data from API and show that in RecyclerView, then after click on any items, go to another activity and show the result that a get from another api.
i share image from postman with you and i hope you could help me for this
i'm using android stdio and java and i prefer to use retrofit for call from api
thanks for your attention...
Brands Api for MainActivity.java
Products Api for Second Activity

you need to use Retrofit for getting data from API.. you can checkout a tutorial like this - https://howtodoandroid.com/retrofit-android-example/

Related

How to make a search with autosuggest in the Bing Maps SDK?

I am trying to use the Bing Maps SDK to display a map in which I show a SearchView. In this SearchView I want to search for locations and when I click on a suggested location, put a marker on the map at that location.
I have previously used the HERE SDK which has a documentation to do this but on Android I can't find any documentation about this Bing Maps SDK.
What I want to achieve is this in Android: https://www.bing.com/api/maps/sdk/mapcontrol/isdk/autosuggestui#TS
Documentation on Bing Maps autosuggest service can be found here: https://learn.microsoft.com/en-us/bingmaps/rest-services/autosuggest
You can use this with Androids AutoCompleteTextView to create a suggestion UI. You will retrieve the suggestions asynchronously from the above service. Here are a few good samples:
https://www.truiton.com/2018/06/android-autocompletetextview-suggestions-from-webservice-call/
How to implement autocompletetextview in Android Studio with an API call?
This service does not return coordinates. This is done so that it isn't used as a replacement for the geocoding service and thus allows them to make this a lower cost service. When a suggestion is selected by the user, you will need to make a single call to a geocoder to get the coordinates of the formattedAddress, then you can use that to display a marker on the map. I recommend setting the result limit to 1 since you only want to top result.
In summary;
Use addTextChangedListener event of AutoCompleteTextView to retrieve suggestions from the autosuggest service.
Use setOnItemClickListener event of AutoCompleteTextView to retrieve the selection from the user, and pass the formattedAddress value into the geocoding service.
Use the coordinates from the geocoder response to create a marker and add to the map.

Recyclerview in a recyclerview activity

using firebase-ui and some coding I have set up my code to work like this:
1) it retrieves data from firebase (image, text and so on), then it passes them to another activity.
2) the new activity receives datas like strings and shows them.
Just to give you an idea I am looking forward to building a streaming app. What I want to do is to show an episode list via recyclerview.
What I am doing right now is a nested scroll view and a copy-paste script to pass up to 26 episodes, but this is not a really good method and I would like to have some suggestions in order to go forward in the best way and solve this problem.
this is a screenshot of the app: https://imgur.com/a/vgBnZTA I am just passing strings to the 2nd activity, then i check if it is not a null string, if it is i hide the layout, otherwise it shows, but it is just a copypaste of code. I hope i was clear enough
Thanks everyone for your support

Where to do network calls to download JSON for RecyclerView

I am writing a small app which queries a REST API to get JSON Data about movies. Which includes
Movie ID
Movie's Poster
URL Movie Overview etc
My main view consists of a RecyclerView which uses a GridLayout Manager to display a grid of movie posters. On tapping, a grid view item would transition to an activity where details of the movie will be presented.
As mentioned above, the API Call would return all important details to build the experience, including the URL to download the Poster.
I will be using Okhttp and Picasso for networking and Image Download. This is my first app which interacts with the network so I need to know where should I put the Okhttp Async Networking Code to get the JSON Data and WHY?
In the Fragment's OnCreate?
In the hosting Activity's OnCreate?
In the RecyclerView's Adapter?
I don't want the code, I just need to know what's the right place to fetch the JSON via Okhttp and why?
You can fetch the JSON via Okhttp in your main fragment or activity, and parse it and store it in an ArrayList, then pass the ArrayList in adapter class, where you need to use picasso library for image download.

android MultiAutoCompleteTextView - displaying custom views in it

I'm implementing MultiAutoCompleteTextView with email contact suggestions. What i want to have is to display contact badges in the MultiAutoCompleteTextView content instead of strings. The Gmail Android app does it.
Basically I Want what is shown in the drop down to be shown in the MultiAutoCompleteTextView (contact photo, name and email) after i typed in/selected the contact.
Is it possible?
Google does this via using a custom ImageSpan. I just implemented this successfully for one of my apps. You should look at RecipientEditTextView.java to see how they do it. Essentially they create a drawable via Canvas and assign that drawable to a custom ImageSpan. I cannot post any code since ... well there is a ton, however you should get a good idea looking thru the source.

Animate newly added items to my listview?

I have a adapter that displays the SMS / MMS messages on the phone. I am trying to animate a new message being either sent or received. Instead of the message item just appearing in the list I want to animate a new message into the listview. Here is a video of something similar to what I am wanting to accomplish
Listview Animation Video
I know that I could apply the animation into the getView() method of the adapter, but I want to only animate the new messages. Anyone know of a possible way for me to do this? Thanks!
You can do that using Layout Transitions. This link also may help you.
But this class is available only on API Level 11+, so if you want to provide compatibility to earlier android API Levels, you have to try something different.

Categories