The Pandemic tracker

The blog post is about how i created an android application to track the pandemic data in 2 days

Saptarshi
5 min readMay 9, 2020
COVID-UPDATES

Hello guys , so this is my first ever blog post on medium regarding one of my project which i have done in lockdown. Due to the pandemic most of us are in lockdown . Previously I was wasting most of my time on PUBG, Youtube & netflix ,suddenly one fine day I felt distressed as i was wasting my time pretty peacefully. So I thought of using this weekends to learn and create some useful stuffs.

Day -1

How I ended up with the app idea?

So i was thiniking about some project ideas and suddenly a web application popped up in my mind which i saw few days back , one of my friend forwarded it to me on Whatsapp. This website tracks the updated counts of COVID-19 like Total no. of cases , deaths, recovered , also state based data of India. So after seeing the website I decided to make an Android application which can track Global data of the pandemic as well as country specific data and also India’s region based data.

So I fired up the android studio quickly and the first thing which popped up in my mind is to make a navigation bar which will have four fragments. I have tons of collection of libraries to implement widgets, after spending 20 mins I picked up a library to make the navigation bar. You can check the library below.

https://github.com/gauravk95/bubble-navigation

So to implement the navigation bar i created four fragments.

  1. Tips : To show various tips related to the Pandemic
  2. Worldwide : To show the global data count
  3. Coutry Based : To show country specific data count
  4. India : To show India based data
The Bubble navigation bar

Now the grind !

After finishing the navigation bar I jumped straight to the fragments.

Implementing the WorldWide fragment

I wanted to plot the global data in a pie chart , so to make things less complex and finish the project in less time i went on searching some libraries to implement a pie chart and luckily found a great one . The Anychart library that i have used in my project provides many visulizations to show your data. So I quickly jumped to their github project and started reading the documentation so that i can implement the pie chart visulization. After figuring out all the things about the pie chart the only thing that left undone was to get the global data and feed it to the chart. So i went on searching for an API which will give the json data i want . Below is the API that i have used for this purpose.

https://coronavirus-monitor.p.rapidapi.com/coronavirus/worldstat.php

You need to generate a key for your application in their website though.So after parsing the JSON data using GSON library in no time i was able to get the global data which i fed to the pie chart and was able to show the pie chart seamlessly. Below i’m attaching the screenshot , how it looks at the end of the first day.

Worldwide fragment

Day-2

The most hard part

The most challeging part which i faced during the project was while i was trying to implement the India specific fragment. This time i used a different api to get the india specific json data. Below is the api i used

https://api.rootnet.in/covid19-in/stats/latest

I quickly parsed the data and splitted them into two catagories. One catagory for summarize data and one catagory for region based data . Without wasting time i completed the easy part which was to show the summarize data in text views ( Total cases, deaths , recovered etc). Then comes the hard part which was to display the regional data.

Idea to show the region specific data

I wasted almost two hours to figure out how should i display the region based data ? at first i thought to show it as a simple list view , than finally after some time i got the idea to make this thing more user interactive. I decided to show the data in a Choropleth map(Indian) , when a user taps any region of the map it will show the total number of cases , that is the thing i wanted to implement. Luckily the visulization library that i have used earlier (AnyChart) has a interactive Choropleth map also. So I quickly jumped to their documentation again and after spending a hour i was able to show the region based data in the choropleth . Also in addition with the chropleth i decied to make a list view seperately to show the regional data. Here is the final look of the both

The Choropleth map view
Regional data in list view

The tips fragment

After finishing the Worldwide and India fragment I decided to implement the Tips fragment. Before starting It was already known to me that this is one of the simlpliest task to do in the whole project . Why ? because all the things will be pretty static in this fragment. So without wasting much time I started working on a design. After finishing the whole design i decided to add a dynamic part in this fragment which will show random hygiene tips to the users at specific time interval . For this purpose i created a seperate java file. There i created String array and stored some hygiene tips collected from WHO website in that array, after that in the tips fragment i simply implemented a list and initialized the list with the String array that i have created earlier. Then i implemented a post handler to show the hygiene tips in a textView at 5 seconds time interval , and with this i achieved what i wanted to do with this fragment. The final look of the fragment is attached below

The Tips fragment

The app is created for learning purpose and the code is available to fork at

--

--