Feeling Restful? Well, gas up! Because we are about to Launch. This project is a very simple Android Project aimed at getting you to implement some simple concepts that are very important as far as Android Development is concerned.
In this project, you are going to implement a mobile design of the GADS 2020 Leaderboard.
The mobile App will display the Top 20 learners in the Learning Leaders’ category and Top 20 learners in the Skill IQ Leaders’ category. We are going to Fetch Data From an API(Application Programming Interface) which is hosted on Heroku and Display Data on The Mobile App, sounds interesting? We just getting started. This project is for beginners, intermediate and senior developers who would want to get their hands dirty on Restful APIs on Android
https://gadsapi.herokuapp.com/ you can get the hosted API here as well as the endpoints we are going to use.
This Project will make you understand
- View pager
- Customizing Toolbar
- Making Network Request using Retrofit to an endpoint through a @GET request
what it looks like sending requests through a mobile client and getting response from the api web service
- Some Basics on Android mobile development
- Basic fundamentals on Java Programming Language
- Basic Design Concepts
What you need to get started
- install android studio
- you are set to go!
LETS GET YOU STARTED….
- First, open android studio and create a new project
First, start a new Android Project by going to File > New project or just tap the Create New Project button on the start page of your Android Studio.
2. Choose Empty Activity as your project template, then click next.
Give any name to your project, in my case I named it LeaderBoard for this project and then click finish and wait until the project build successfully.
- Now add the following dependencies on the build.gradle(Module :app)
Now when you are done sync the project and wait for build to finish successfully
This is How Your Manifest File Should Look Like remember to add internet permissions
Let’s Get the Layouts done
- learning_leaders_fragmet Layout xml file
- skill_iq_fragmet Layout xml file
LET’S GET HANDS-ON.
Create a new Java class and name it viewpageradapter this class will assist us is scrolling between two tabs which are skill_iq tab and learning_leaders tab the class extends FragmentPagerAdapter
here is a snippet code…
Next, let’s create a new Package under Java Folder and name it Model then inside Model lets create two Java Classes
1 LeaderBoard java class
Here is a snippet code…
NB make sure you use Serialize
2.SkillIQ Java Class
here is the code snippet…
Now we are going to make two fragments by creating the corresponding Java classes which will extend Fragment
- learning_leaders fragment
- skill_iq fragment
1.Learning leaders fragment which extends Fragment
here is a code snippet…
code snippet..Error when loading gists from https://gist.github.com/.
Great we are almost done hold on for a while!!!
The next Step is making adapters package and creating the two adapters
- SkillIQ adapter
Let’s create a Service package and inside the package lets create.
- ServiceBuilder Class
- SkillDataService java interface
- LearningLeaderService java interface
2.SkillIQDataService java interface
2.SkillIQDataService java interface
Finally here is where the Magic happens
We are going to make a request inside the respective learning_leaders fragment and skill_iq fragment and set the adapters as well as the Recyclerview. Inside OnViewCreated, we are going to retrieve data from the base URL and display the data
1.First let’s make the request on the learning_leaders fragment inside the OnViewCreated
NB make sure you initialize the RecyclerView, LearningLeadersAdapter and the List as follows inside the learning_leaders fragment
and add a constructor
here is the data that will be displayed
2.Second and final step lets repeat the same process for Skill_iq fragment
Here is what will be displayed
Find the GitHub Repo HERE