├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── us.png
│ │ │ │ ├── virus.png
│ │ │ │ ├── coronavirus.png
│ │ │ │ ├── line_divider.xml
│ │ │ │ ├── home_selector.xml
│ │ │ │ ├── country_selector.xml
│ │ │ │ ├── ic_sort_by_cases.xml
│ │ │ │ ├── ic_home_black_24dp.xml
│ │ │ │ ├── ic_dashboard_black_24dp.xml
│ │ │ │ ├── home_fill.xml
│ │ │ │ ├── home_line.xml
│ │ │ │ ├── ic_notifications_black_24dp.xml
│ │ │ │ ├── ic_search.xml
│ │ │ │ ├── ic_sort_by_alpha.xml
│ │ │ │ ├── progress.xml
│ │ │ │ ├── ic_language_black_24dp.xml
│ │ │ │ ├── country_line.xml
│ │ │ │ ├── country_fill.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── font
│ │ │ │ ├── poppins.ttf
│ │ │ │ └── poppins_bold.ttf
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── values
│ │ │ │ ├── ids.xml
│ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ ├── strings.xml
│ │ │ │ ├── preloaded_fonts.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── font_certs.xml
│ │ │ ├── anim
│ │ │ │ └── mytransition.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── menu
│ │ │ │ ├── bottom_nav_menu.xml
│ │ │ │ └── country_menu.xml
│ │ │ ├── navigation
│ │ │ │ └── mobile_navigation.xml
│ │ │ ├── layout
│ │ │ │ ├── fragment_country.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── item_list_covid_country.xml
│ │ │ │ ├── activity_splash.xml
│ │ │ │ ├── fragment_home.xml
│ │ │ │ └── activity_covid_country_detail.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── ic_launcher-playstore.png
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── trackcovid
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── splashActivity.java
│ │ │ │ └── ui
│ │ │ │ ├── country
│ │ │ │ ├── CovidCountryDetail.java
│ │ │ │ ├── CovidCountry.java
│ │ │ │ ├── ItemClickSupport.java
│ │ │ │ ├── CovidCountryAdapter.java
│ │ │ │ └── CountryFragment.java
│ │ │ │ └── home
│ │ │ │ └── HomeFragment.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── trackcovid
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── trackcovid
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── apk
└── TrackCovid.apk
├── screenshots
├── page1.png
├── page2.png
├── page3.png
└── page4.png
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── .idea
├── misc.xml
├── runConfigurations.xml
├── gradle.xml
└── codeStyles
│ └── Project.xml
├── README.md
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name='TrackCovid'
2 | include ':app'
3 |
--------------------------------------------------------------------------------
/apk/TrackCovid.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/apk/TrackCovid.apk
--------------------------------------------------------------------------------
/screenshots/page1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/screenshots/page1.png
--------------------------------------------------------------------------------
/screenshots/page2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/screenshots/page2.png
--------------------------------------------------------------------------------
/screenshots/page3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/screenshots/page3.png
--------------------------------------------------------------------------------
/screenshots/page4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/screenshots/page4.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/us.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/drawable/us.png
--------------------------------------------------------------------------------
/app/src/main/res/font/poppins.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/font/poppins.ttf
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/virus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/drawable/virus.png
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/res/font/poppins_bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/font/poppins_bold.ttf
--------------------------------------------------------------------------------
/app/src/main/res/drawable/coronavirus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/drawable/coronavirus.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Suvoo/CovidTrackerApp/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #143D59
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TrackCovid
3 | Home
4 | Country
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/preloaded_fonts.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - @font/poppins
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/mytransition.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 22 19:07:46 IST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/line_divider.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/home_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/country_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_sort_by_cases.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_home_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_dashboard_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #143d59
4 | #f4b41a
5 | #03DAC5
6 |
7 | #E40404
8 | #999999
9 | #32EE1D
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/home_fill.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/home_line.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/bottom_nav_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/trackcovid/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.trackcovid;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_notifications_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_search.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_sort_by_alpha.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CovidTrackerApp
2 | ***App to track the cases,deaths and recovered people from all countries across the world
3 | Coronavirus Covid-19 Tracking App Realtime Data - Volley Fetch REST API in Android Studio***
4 |
5 | # 📱 APK file Link ► https://bit.ly/TrackCovid19
6 |
7 | Preview of the app :
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | Data is always updated regularly
22 | Public JSON API obtained from :
23 |
24 | ► https://corona.lmao.ninja/v2/all
25 |
26 | ► https://corona.lmao.ninja/v2/countries
27 |
28 | NovelCOVID-API Github repository for the JSON API ► https://github.com/NovelCOVID/API
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/country_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/navigation/mobile_navigation.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/progress.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
19 |
20 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/trackcovid/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.trackcovid;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 |
25 | assertEquals("com.example.trackcovid", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_country.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
15 |
16 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
17 |
18 |
19 |
23 |
24 |
28 |
29 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/trackcovid/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.trackcovid;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.google.android.material.bottomnavigation.BottomNavigationView;
6 |
7 | import androidx.appcompat.app.AppCompatActivity;
8 | import androidx.navigation.NavController;
9 | import androidx.navigation.Navigation;
10 | import androidx.navigation.ui.AppBarConfiguration;
11 | import androidx.navigation.ui.NavigationUI;
12 |
13 | public class MainActivity extends AppCompatActivity {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_main);
19 | BottomNavigationView navView = findViewById(R.id.nav_view);
20 |
21 | navView.setItemIconTintList(null);
22 | // Passing each menu ID as a set of Ids because each
23 | // menu should be considered as top level destinations.
24 |
25 | NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
26 |
27 | NavigationUI.setupWithNavController(navView, navController);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_language_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/country_line.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/country_fill.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/trackcovid/splashActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.trackcovid;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.content.Intent;
6 | import android.os.Bundle;
7 | import android.view.animation.Animation;
8 | import android.view.animation.AnimationUtils;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | public class splashActivity extends AppCompatActivity {
13 | private TextView tv;
14 | private ImageView iv;
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_splash);
20 | tv = (TextView)findViewById(R.id.tv);
21 | iv = (ImageView)findViewById(R.id.iv);
22 | Animation myanim = AnimationUtils.loadAnimation(this,R.anim.mytransition);
23 | tv.startAnimation(myanim);
24 | iv.startAnimation(myanim);
25 | final Intent i = new Intent(splashActivity.this,MainActivity.class);
26 | Thread timer = new Thread(){
27 | public void run() {
28 | try {
29 | sleep(5000);
30 | } catch (InterruptedException e) {
31 | e.printStackTrace();
32 | }
33 | finally {
34 | startActivity(i);
35 | finish();
36 |
37 | }
38 | }
39 | }; timer.start();
40 | }
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 29
5 | buildToolsVersion "29.0.3"
6 |
7 | defaultConfig {
8 | applicationId "com.example.trackcovid"
9 | minSdkVersion 21
10 | targetSdkVersion 29
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 |
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(dir: 'libs', include: ['*.jar'])
28 |
29 | implementation 'androidx.appcompat:appcompat:1.1.0'
30 | implementation 'com.google.android.material:material:1.1.0'
31 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
32 | implementation 'androidx.navigation:navigation-fragment:2.2.2'
33 | implementation 'androidx.navigation:navigation-ui:2.2.2'
34 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
35 | testImplementation 'junit:junit:4.12'
36 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
37 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
38 | implementation 'com.android.volley:volley:1.1.1'
39 | implementation 'androidx.recyclerview:recyclerview:1.0.0'
40 |
41 | // Glide library for image
42 | implementation 'com.github.bumptech.glide:glide:4.11.0'
43 | annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_list_covid_country.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
15 |
16 |
22 |
23 |
32 |
33 |
42 |
43 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
24 |
34 |
35 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/trackcovid/ui/country/CovidCountryDetail.java:
--------------------------------------------------------------------------------
1 | package com.example.trackcovid.ui.country;
2 |
3 | import android.os.Bundle;
4 | import android.widget.TextView;
5 |
6 | import androidx.appcompat.app.AppCompatActivity;
7 | import com.example.trackcovid.R;
8 |
9 | public class CovidCountryDetail extends AppCompatActivity {
10 |
11 | TextView tvDetailCountryName, tvDetailTotalCases, tvDetailTodayCases, tvDetailTotalDeaths,
12 | tvDetailTodayDeaths, tvDetailTotalRecovered, tvDetailTotalActive, tvDetailTotalCritical;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_covid_country_detail);
18 |
19 | // call view
20 | tvDetailCountryName = findViewById(R.id.tvDetailCountryName);
21 | tvDetailTotalCases = findViewById(R.id.tvDetailTotalCases);
22 | tvDetailTodayCases = findViewById(R.id.tvDetailTodayCases);
23 | tvDetailTotalDeaths = findViewById(R.id.tvDetailTotalDeaths);
24 | tvDetailTodayDeaths = findViewById(R.id.tvDetailTodayDeaths);
25 | tvDetailTotalRecovered = findViewById(R.id.tvDetailTotalRecovered);
26 | tvDetailTotalActive = findViewById(R.id.tvDetailTotalActive);
27 | tvDetailTotalCritical = findViewById(R.id.tvDetailTotalCritical);
28 |
29 |
30 | // call Covid Country
31 | CovidCountry covidCountry = getIntent().getParcelableExtra("EXTRA_COVID");
32 |
33 | // set text view
34 | tvDetailCountryName.setText(covidCountry.getmCovidCountry());
35 | tvDetailTotalCases.setText(Integer.toString(covidCountry.getmCases()));
36 | tvDetailTodayCases.setText(covidCountry.getmTodayCases());
37 | tvDetailTotalDeaths.setText(covidCountry.getmDeaths());
38 | tvDetailTodayDeaths.setText(covidCountry.getmTodayDeaths());
39 | tvDetailTotalRecovered.setText(covidCountry.getmRecovered());
40 | tvDetailTotalActive.setText(covidCountry.getmActive());
41 | tvDetailTotalCritical.setText(covidCountry.getmCritical());
42 |
43 | }
44 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/trackcovid/ui/country/CovidCountry.java:
--------------------------------------------------------------------------------
1 | package com.example.trackcovid.ui.country;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | public class CovidCountry implements Parcelable {
7 | String mCovidCountry, mTodayCases, mDeaths, mTodayDeaths, mRecovered, mActive, mCritical, mFlags;
8 | int mCases;
9 |
10 | public CovidCountry(String mCovidCountry, int mCases, String mTodayCases, String mDeaths, String mTodayDeaths, String mRecovered, String mActive, String mCritical, String mFlags) {
11 | this.mCovidCountry = mCovidCountry;
12 | this.mCases = mCases;
13 | this.mTodayCases = mTodayCases;
14 | this.mDeaths = mDeaths;
15 | this.mTodayDeaths = mTodayDeaths;
16 | this.mRecovered = mRecovered;
17 | this.mActive = mActive;
18 | this.mCritical = mCritical;
19 | this.mFlags = mFlags;
20 | }
21 |
22 | public String getmCovidCountry() {
23 | return mCovidCountry;
24 | }
25 |
26 | public int getmCases() {
27 | return mCases;
28 | }
29 |
30 | public String getmTodayCases() {
31 | return mTodayCases;
32 | }
33 |
34 | public String getmDeaths() {
35 | return mDeaths;
36 | }
37 |
38 | public String getmTodayDeaths() {
39 | return mTodayDeaths;
40 | }
41 |
42 | public String getmRecovered() {
43 | return mRecovered;
44 | }
45 |
46 | public String getmActive() {
47 | return mActive;
48 | }
49 |
50 | public String getmCritical() {
51 | return mCritical;
52 | }
53 |
54 | public String getmFlags() {
55 | return mFlags;
56 | }
57 |
58 |
59 | @Override
60 | public int describeContents() {
61 | return 0;
62 | }
63 |
64 | @Override
65 | public void writeToParcel(Parcel dest, int flags) {
66 | dest.writeString(this.mCovidCountry);
67 | dest.writeInt(this.mCases);
68 | dest.writeString(this.mTodayCases);
69 | dest.writeString(this.mDeaths);
70 | dest.writeString(this.mTodayDeaths);
71 | dest.writeString(this.mRecovered);
72 | dest.writeString(this.mActive);
73 | dest.writeString(this.mCritical);
74 | dest.writeString(this.mFlags);
75 | }
76 |
77 | protected CovidCountry(Parcel in) {
78 | this.mCovidCountry = in.readString();
79 | this.mCases = in.readInt();
80 | this.mTodayCases = in.readString();
81 | this.mDeaths = in.readString();
82 | this.mTodayDeaths = in.readString();
83 | this.mRecovered = in.readString();
84 | this.mActive = in.readString();
85 | this.mCritical = in.readString();
86 | this.mFlags = in.readString();
87 | }
88 |
89 | public static final Creator CREATOR = new Creator() {
90 | @Override
91 | public CovidCountry createFromParcel(Parcel source) {
92 | return new CovidCountry(source);
93 | }
94 |
95 | @Override
96 | public CovidCountry[] newArray(int size) {
97 | return new CovidCountry[size];
98 | }
99 | };
100 | }
101 |
--------------------------------------------------------------------------------
/app/src/main/res/values/font_certs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - @array/com_google_android_gms_fonts_certs_dev
5 | - @array/com_google_android_gms_fonts_certs_prod
6 |
7 |
8 | -
9 | MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBANbOLggKv+IxTdGNs8/TGFy0PTP6DHThvbbR24kT9ixcOd9W+EaBPWW+wPPKQmsHxajtWjmQwWfna8mZuSeJS48LIgAZlKkpFeVyxW0qMBujb8X8ETrWy550NaFtI6t9+u7hZeTfHwqNvacKhp1RbE6dBRGWynwMVX8XW8N1+UjFaq6GCJukT4qmpN2afb8sCjUigq0GuMwYXrFVee74bQgLHWGJwPmvmLHC69EH6kWr22ijx4OKXlSIx2xT1AsSHee70w5iDBiK4aph27yH3TxkXy9V89TDdexAcKk/cVHYNnDBapcavl7y0RiQ4biu8ymM8Ga/nmzhRKya6G0cGw8CAQOjgfwwgfkwHQYDVR0OBBYEFI0cxb6VTEM8YYY6FbBMvAPyT+CyMIHJBgNVHSMEgcEwgb6AFI0cxb6VTEM8YYY6FbBMvAPyT+CyoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJANWFuGx90071MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBABnTDPEF+3iSP0wNfdIjIz1AlnrPzgAIHVvXxunW7SBrDhEglQZBbKJEk5kT0mtKoOD1JMrSu1xuTKEBahWRbqHsXclaXjoBADb0kkjVEJu/Lh5hgYZnOjvlba8Ld7HCKePCVePoTJBdI4fvugnL8TsgK05aIskyY0hKI9L8KfqfGTl1lzOv2KoWD0KWwtAWPoGChZxmQ+nBli+gwYMzM1vAkP+aayLe0a1EQimlOalO762r0GXO0ks+UeXde2Z4e+8S/pf7pITEI/tP+MxJTALw9QUWEv9lKTk+jkbqxbsh8nfBUapfKqYn0eidpwq2AzVp3juYl7//fKnaPhJD9gs=
10 |
11 |
12 |
13 | -
14 | MIIEQzCCAyugAwIBAgIJAMLgh0ZkSjCNMA0GCSqGSIb3DQEBBAUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEzMzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASAwDQYJKoZIhvcNAQEBBQADggENADCCAQgCggEBAKtWLgDYO6IIrgqWbxJOKdoR8qtW0I9Y4sypEwPpt1TTcvZApxsdyxMJZ2JORland2qSGT2y5b+3JKkedxiLDmpHpDsz2WCbdxgxRczfey5YZnTJ4VZbH0xqWVW/8lGmPav5xVwnIiJS6HXk+BVKZF+JcWjAsb/GEuq/eFdpuzSqeYTcfi6idkyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/trackcovid/ui/home/HomeFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.trackcovid.ui.home;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ProgressBar;
9 | import android.widget.TextView;
10 |
11 | import androidx.annotation.NonNull;
12 | import androidx.fragment.app.Fragment;
13 |
14 | import com.android.volley.Request;
15 | import com.android.volley.RequestQueue;
16 | import com.android.volley.Response;
17 | import com.android.volley.VolleyError;
18 | import com.android.volley.toolbox.StringRequest;
19 | import com.android.volley.toolbox.Volley;
20 | import com.example.trackcovid.R;
21 |
22 | import org.json.JSONException;
23 | import org.json.JSONObject;
24 |
25 | import java.lang.ref.ReferenceQueue;
26 | import java.text.SimpleDateFormat;
27 | import java.util.Calendar;
28 |
29 | public class HomeFragment extends Fragment {
30 |
31 | private TextView tvTotalConfirmed, tvTotalDeaths, tvTotalRecovered, tvLastUpdated;
32 | private ProgressBar progressBar;
33 |
34 | public View onCreateView(@NonNull LayoutInflater inflater,
35 | ViewGroup container, Bundle savedInstanceState) {
36 |
37 | View root = inflater.inflate(R.layout.fragment_home, container, false);
38 |
39 | // call view
40 | tvTotalConfirmed = root.findViewById(R.id.tvTotalConfirmed);
41 | tvTotalDeaths = root.findViewById(R.id.tvTotalDeaths);
42 | tvTotalRecovered = root.findViewById(R.id.tvTotalRecovered);
43 | tvLastUpdated = root.findViewById(R.id.tvLastUpdated);
44 | progressBar = root.findViewById(R.id.progress_circular_home);
45 |
46 | // Action Bar title
47 | getActivity().setTitle("Overview");
48 |
49 | // call Volley
50 | getData();
51 |
52 | return root;
53 | }
54 |
55 | private String getDate(long milliSecond){
56 | // Mon, 23 Mar 2020 02:01:04 PM
57 | SimpleDateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss aaa");
58 |
59 | Calendar calendar= Calendar.getInstance();
60 | calendar.setTimeInMillis(milliSecond);
61 | return formatter.format(calendar.getTime());
62 | }
63 |
64 | private void getData() {
65 | RequestQueue queue = Volley.newRequestQueue(getActivity());
66 |
67 | String url = "https://corona.lmao.ninja/v2/all";
68 |
69 | StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener() {
70 | @Override
71 | public void onResponse(String response) {
72 | progressBar.setVisibility(View.GONE);
73 |
74 | try {
75 | JSONObject jsonObject = new JSONObject(response.toString());
76 |
77 | tvTotalConfirmed.setText(jsonObject.getString("cases"));
78 | tvTotalDeaths.setText(jsonObject.getString("deaths"));
79 | tvTotalRecovered.setText(jsonObject.getString("recovered"));
80 | tvLastUpdated.setText("Last Updated"+"\n"+getDate(jsonObject.getLong("updated")));
81 | } catch (JSONException e) {
82 | e.printStackTrace();
83 | }
84 | }
85 | }, new Response.ErrorListener() {
86 | @Override
87 | public void onErrorResponse(VolleyError error) {
88 | progressBar.setVisibility(View.GONE);
89 | Log.d("Error Response", error.toString());
90 | }
91 | });
92 |
93 | queue.add(stringRequest);
94 | }
95 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/trackcovid/ui/country/ItemClickSupport.java:
--------------------------------------------------------------------------------
1 | package com.example.trackcovid.ui.country;
2 |
3 | import android.view.View;
4 |
5 | import androidx.annotation.NonNull;
6 | import androidx.recyclerview.widget.RecyclerView;
7 |
8 | import com.example.trackcovid.R;
9 |
10 | public class ItemClickSupport {
11 | private final RecyclerView mRecyclerView;
12 | private OnItemClickListener mOnItemClickListener;
13 | private OnItemLongClickListener mOnItemLongClickListener;
14 | private View.OnClickListener mOnClickListener = new View.OnClickListener() {
15 | @Override
16 | public void onClick(View v) {
17 | if (mOnItemClickListener != null) {
18 | RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(v);
19 | mOnItemClickListener.onItemClicked(mRecyclerView, holder.getAdapterPosition(), v);
20 | }
21 | }
22 | };
23 | private View.OnLongClickListener mOnLongClickListener = new View.OnLongClickListener() {
24 | @Override
25 | public boolean onLongClick(View v) {
26 | if (mOnItemLongClickListener != null) {
27 | RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(v);
28 | return mOnItemLongClickListener.onItemLongClicked(mRecyclerView, holder.getAdapterPosition(), v);
29 | }
30 | return false;
31 | }
32 | };
33 | private RecyclerView.OnChildAttachStateChangeListener mAttachListener
34 | = new RecyclerView.OnChildAttachStateChangeListener() {
35 | @Override
36 | public void onChildViewAttachedToWindow(@NonNull View view) {
37 | if (mOnItemClickListener != null) {
38 | view.setOnClickListener(mOnClickListener);
39 | }
40 | if (mOnItemLongClickListener != null) {
41 | view.setOnLongClickListener(mOnLongClickListener);
42 | }
43 | }
44 |
45 | @Override
46 | public void onChildViewDetachedFromWindow(@NonNull View view) {
47 | }
48 | };
49 |
50 | private ItemClickSupport(RecyclerView recyclerView) {
51 | mRecyclerView = recyclerView;
52 | mRecyclerView.setTag(R.id.item_click_support, this);
53 | mRecyclerView.addOnChildAttachStateChangeListener(mAttachListener);
54 | }
55 |
56 | public static ItemClickSupport addTo(RecyclerView view) {
57 | ItemClickSupport support = (ItemClickSupport) view.getTag(R.id.item_click_support);
58 | if (support == null) {
59 | support = new ItemClickSupport(view);
60 | }
61 | return support;
62 | }
63 |
64 | public static ItemClickSupport removeFrom(RecyclerView view) {
65 | ItemClickSupport support = (ItemClickSupport) view.getTag(R.id.item_click_support);
66 | if (support != null) {
67 | support.detach(view);
68 | }
69 | return support;
70 | }
71 |
72 | public void setOnItemClickListener(OnItemClickListener listener) {
73 | mOnItemClickListener = listener;
74 | }
75 |
76 | public void setOnItemLongClickListener(OnItemLongClickListener listener) {
77 | mOnItemLongClickListener = listener;
78 | }
79 |
80 | private void detach(RecyclerView view) {
81 | view.removeOnChildAttachStateChangeListener(mAttachListener);
82 | view.setTag(R.id.item_click_support, null);
83 | }
84 |
85 | public interface OnItemClickListener {
86 | void onItemClicked(RecyclerView recyclerView, int position, View v);
87 | }
88 |
89 | public interface OnItemLongClickListener {
90 | boolean onItemLongClicked(RecyclerView recyclerView, int position, View v);
91 | }
92 | }
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
26 |
27 |
34 |
35 |
42 |
43 |
50 |
51 |
58 |
59 |
66 |
67 |
74 |
75 |
84 |
85 |
86 |
87 |
94 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/trackcovid/ui/country/CovidCountryAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.trackcovid.ui.country;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.Filter;
8 | import android.widget.Filterable;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import androidx.annotation.NonNull;
13 | import androidx.recyclerview.widget.RecyclerView;
14 |
15 | import com.example.trackcovid.R;
16 | import com.bumptech.glide.Glide;
17 | import com.bumptech.glide.request.RequestOptions;
18 |
19 | import java.util.ArrayList;
20 | import java.util.List;
21 |
22 | public class CovidCountryAdapter extends RecyclerView.Adapter implements Filterable {
23 |
24 | private List covidCountries;
25 | private List covidCountriesFull;
26 |
27 | private Context context;
28 |
29 | public CovidCountryAdapter(List covidCountries, Context context) {
30 | this.covidCountries = covidCountries;
31 | this.context = context;
32 | covidCountriesFull = new ArrayList<>(covidCountries);
33 | }
34 |
35 | @NonNull
36 | @Override
37 | public CovidCountryAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
38 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list_covid_country, parent, false);
39 |
40 | return new ViewHolder(view);
41 | }
42 |
43 | @Override
44 | public void onBindViewHolder(@NonNull CovidCountryAdapter.ViewHolder holder, int position) {
45 | CovidCountry covidCountry = covidCountries.get(position);
46 | holder.tvTotalCases.setText(Integer.toString(covidCountry.getmCases()));
47 | holder.tvCountryName.setText(covidCountry.getmCovidCountry());
48 |
49 | // Glide
50 | Glide.with(context)
51 | .load(covidCountry.getmFlags())
52 | .apply(new RequestOptions().override(240, 160))
53 | .into(holder.imgCountryFlag);
54 | }
55 |
56 | @Override
57 | public int getItemCount() {
58 | return covidCountries.size();
59 | }
60 |
61 | public class ViewHolder extends RecyclerView.ViewHolder {
62 | TextView tvTotalCases, tvCountryName;
63 | ImageView imgCountryFlag;
64 |
65 | public ViewHolder(@NonNull View itemView) {
66 | super(itemView);
67 | tvTotalCases = itemView.findViewById(R.id.tvTotalCases);
68 | tvCountryName = itemView.findViewById(R.id.tvCountryName);
69 | imgCountryFlag = itemView.findViewById(R.id.imgCountryFlag);
70 | }
71 | }
72 |
73 | @Override
74 | public Filter getFilter() {
75 | return covidCountriesFilter;
76 | }
77 |
78 | private Filter covidCountriesFilter = new Filter() {
79 | @Override
80 | protected FilterResults performFiltering(CharSequence constraint) {
81 | List filteredCovidCountry = new ArrayList<>();
82 |
83 | if (constraint == null || constraint.length() == 0) {
84 | filteredCovidCountry.addAll(covidCountriesFull);
85 | } else {
86 | String filterPattern = constraint.toString().toLowerCase().trim();
87 | for (CovidCountry itemCovidCountry : covidCountriesFull) {
88 | if (itemCovidCountry.getmCovidCountry().toLowerCase().contains(filterPattern)) {
89 | filteredCovidCountry.add(itemCovidCountry);
90 | }
91 | }
92 | }
93 |
94 | FilterResults results = new FilterResults();
95 | results.values = filteredCovidCountry;
96 | return results;
97 | }
98 |
99 | @Override
100 | protected void publishResults(CharSequence constraint, FilterResults results) {
101 | covidCountries.clear();
102 | covidCountries.addAll((List) results.values);
103 | notifyDataSetChanged();
104 | }
105 | };
106 | }
107 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_covid_country_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
17 |
18 |
26 |
27 |
28 |
34 |
35 |
40 |
41 |
48 |
49 |
58 |
59 |
60 |
65 |
66 |
73 |
74 |
83 |
84 |
85 |
86 |
87 |
93 |
94 |
99 |
100 |
107 |
108 |
117 |
118 |
119 |
124 |
125 |
132 |
133 |
142 |
143 |
144 |
145 |
146 |
152 |
153 |
158 |
159 |
166 |
167 |
176 |
177 |
178 |
179 |
180 |
181 |
186 |
187 |
192 |
193 |
200 |
201 |
210 |
211 |
212 |
217 |
218 |
225 |
226 |
235 |
236 |
237 |
238 |
239 |
240 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/trackcovid/ui/country/CountryFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.trackcovid.ui.country;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.view.LayoutInflater;
7 | import android.view.Menu;
8 | import android.view.MenuInflater;
9 | import android.view.MenuItem;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.ProgressBar;
13 | import android.widget.Toast;
14 |
15 | import androidx.annotation.NonNull;
16 | import androidx.appcompat.widget.SearchView;
17 | import androidx.core.content.ContextCompat;
18 | import androidx.fragment.app.Fragment;
19 | import androidx.recyclerview.widget.DividerItemDecoration;
20 | import androidx.recyclerview.widget.LinearLayoutManager;
21 | import androidx.recyclerview.widget.RecyclerView;
22 |
23 | import com.android.volley.Request;
24 | import com.android.volley.Response;
25 | import com.android.volley.VolleyError;
26 | import com.android.volley.toolbox.StringRequest;
27 | import com.android.volley.toolbox.Volley;
28 | import com.example.trackcovid.R;
29 |
30 | import org.json.JSONArray;
31 | import org.json.JSONException;
32 | import org.json.JSONObject;
33 |
34 | import java.util.ArrayList;
35 | import java.util.Collections;
36 | import java.util.Comparator;
37 | import java.util.List;
38 |
39 | public class CountryFragment extends Fragment {
40 |
41 | RecyclerView rvCovidCountry;
42 | ProgressBar progressBar;
43 | CovidCountryAdapter covidCountryAdapter;
44 |
45 | private static final String TAG = CountryFragment.class.getSimpleName();
46 | List covidCountries;
47 |
48 | public View onCreateView(@NonNull LayoutInflater inflater,
49 | ViewGroup container, Bundle savedInstanceState) {
50 | View root = inflater.inflate(R.layout.fragment_country, container, false);
51 |
52 | // set has option menu as true because we have menu
53 | setHasOptionsMenu(true);
54 |
55 | // call view
56 | rvCovidCountry = root.findViewById(R.id.rvCovidCountry);
57 | progressBar = root.findViewById(R.id.progress_circular_country);
58 | rvCovidCountry.setLayoutManager(new LinearLayoutManager(getActivity()));
59 |
60 | DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(rvCovidCountry.getContext(), DividerItemDecoration.VERTICAL);
61 | dividerItemDecoration.setDrawable(ContextCompat.getDrawable(getContext(), R.drawable.line_divider));
62 | rvCovidCountry.addItemDecoration(dividerItemDecoration);
63 |
64 | //call list
65 | covidCountries = new ArrayList<>();
66 |
67 | // call Volley method
68 | getDataFromServerSortTotalCases();
69 |
70 | return root;
71 | }
72 |
73 | private void showRecyclerView() {
74 | covidCountryAdapter = new CovidCountryAdapter(covidCountries, getActivity());
75 | rvCovidCountry.setAdapter(covidCountryAdapter);
76 |
77 | ItemClickSupport.addTo(rvCovidCountry).setOnItemClickListener(new ItemClickSupport.OnItemClickListener() {
78 | @Override
79 | public void onItemClicked(RecyclerView recyclerView, int position, View v) {
80 | showSelectedCovidCountry(covidCountries.get(position));
81 | }
82 | });
83 | }
84 |
85 | private void showSelectedCovidCountry(CovidCountry covidCountry) {
86 | Intent covidCovidCountryDetail = new Intent(getActivity(), CovidCountryDetail.class);
87 | covidCovidCountryDetail.putExtra("EXTRA_COVID", covidCountry);
88 | startActivity(covidCovidCountryDetail);
89 | }
90 |
91 | private void getDataFromServerSortTotalCases() {
92 | String url = "https://corona.lmao.ninja/v2/countries";
93 |
94 | StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener() {
95 | @Override
96 | public void onResponse(String response) {
97 | progressBar.setVisibility(View.GONE);
98 | if (response != null) {
99 | Log.e(TAG, "onResponse: " + response);
100 | try {
101 | JSONArray jsonArray = new JSONArray(response);
102 | for (int i = 0; i < jsonArray.length(); i++) {
103 | JSONObject data = jsonArray.getJSONObject(i);
104 |
105 | // Extract JSONObject inside JSONObject
106 | JSONObject countryInfo = data.getJSONObject("countryInfo");
107 |
108 | covidCountries.add(new CovidCountry(
109 | data.getString("country"), data.getInt("cases"),
110 | data.getString("todayCases"), data.getString("deaths"),
111 | data.getString("todayDeaths"), data.getString("recovered"),
112 | data.getString("active"), data.getString("critical"),
113 | countryInfo.getString("flag")
114 | ));
115 | }
116 |
117 | // sort descending
118 | Collections.sort(covidCountries, new Comparator() {
119 | @Override
120 | public int compare(CovidCountry o1, CovidCountry o2) {
121 | if (o1.getmCases() > o2.getmCases()) {
122 | return -1;
123 | } else {
124 | return 1;
125 | }
126 | }
127 | });
128 |
129 | // Action Bar Title
130 | getActivity().setTitle(jsonArray.length() + " countries");
131 |
132 | showRecyclerView();
133 | } catch (JSONException e) {
134 | e.printStackTrace();
135 | }
136 | }
137 | }
138 | },
139 | new Response.ErrorListener() {
140 | @Override
141 | public void onErrorResponse(VolleyError error) {
142 | progressBar.setVisibility(View.GONE);
143 | Log.e(TAG, "onResponse: " + error);
144 | }
145 | });
146 | Volley.newRequestQueue(getActivity()).add(stringRequest);
147 | }
148 |
149 | private void getDataFromServerSortAlphabet() {
150 | String url = "https://corona.lmao.ninja/v2/countries";
151 |
152 | StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener() {
153 | @Override
154 | public void onResponse(String response) {
155 | progressBar.setVisibility(View.GONE);
156 | if (response != null) {
157 | Log.e(TAG, "onResponse: " + response);
158 | try {
159 | JSONArray jsonArray = new JSONArray(response);
160 | for (int i = 0; i < jsonArray.length(); i++) {
161 | JSONObject data = jsonArray.getJSONObject(i);
162 |
163 | // Extract JSONObject inside JSONObject
164 | JSONObject countryInfo = data.getJSONObject("countryInfo");
165 |
166 | covidCountries.add(new CovidCountry(
167 | data.getString("country"), data.getInt("cases"),
168 | data.getString("todayCases"), data.getString("deaths"),
169 | data.getString("todayDeaths"), data.getString("recovered"),
170 | data.getString("active"), data.getString("critical"),
171 | countryInfo.getString("flag")
172 | ));
173 | }
174 |
175 | // Action Bar Title
176 | getActivity().setTitle(jsonArray.length() + " countries");
177 |
178 | showRecyclerView();
179 | } catch (JSONException e) {
180 | e.printStackTrace();
181 | }
182 | }
183 | }
184 | },
185 | new Response.ErrorListener() {
186 | @Override
187 | public void onErrorResponse(VolleyError error) {
188 | progressBar.setVisibility(View.GONE);
189 | Log.e(TAG, "onResponse: " + error);
190 | }
191 | });
192 | Volley.newRequestQueue(getActivity()).add(stringRequest);
193 | }
194 |
195 | @Override
196 | public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
197 | inflater.inflate(R.menu.country_menu, menu);
198 | MenuItem searchItem = menu.findItem(R.id.action_search);
199 | SearchView searchView = new SearchView(getActivity());
200 | searchView.setQueryHint("Search...");
201 | searchView.setMaxWidth(Integer.MAX_VALUE);
202 | searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
203 | @Override
204 | public boolean onQueryTextSubmit(String query) {
205 | return false;
206 | }
207 |
208 | @Override
209 | public boolean onQueryTextChange(String newText) {
210 | if (covidCountryAdapter != null) {
211 | covidCountryAdapter.getFilter().filter(newText);
212 | }
213 | return true;
214 | }
215 | });
216 |
217 | searchItem.setActionView(searchView);
218 | super.onCreateOptionsMenu(menu, inflater);
219 | }
220 |
221 | @Override
222 | public boolean onOptionsItemSelected(@NonNull MenuItem item) {
223 | switch (item.getItemId()) {
224 | case R.id.action_sort_alpha:
225 | Toast.makeText(getContext(), "Sort Alphabetically", Toast.LENGTH_SHORT).show();
226 | covidCountries.clear();
227 | progressBar.setVisibility(View.VISIBLE);
228 | getDataFromServerSortAlphabet();
229 | return true;
230 |
231 | case R.id.action_sort_cases:
232 | Toast.makeText(getContext(), "Sort by Total Cases", Toast.LENGTH_SHORT).show();
233 | covidCountries.clear();
234 | progressBar.setVisibility(View.VISIBLE);
235 | getDataFromServerSortTotalCases();
236 | return true;
237 | }
238 | return super.onOptionsItemSelected(item);
239 | }
240 | }
--------------------------------------------------------------------------------