├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── corona.jpg
│ │ │ │ ├── globe_icon.png
│ │ │ │ ├── india_icon.png
│ │ │ │ └── ic_night_mode.xml
│ │ │ ├── mipmap
│ │ │ │ ├── corona.jpg
│ │ │ │ └── corona_round.png
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_increase_blue.png
│ │ │ │ ├── ic_increase_red.png
│ │ │ │ ├── ic_increase_green.png
│ │ │ │ └── ic_increase_primary.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_increase_blue.png
│ │ │ │ ├── ic_increase_red.png
│ │ │ │ ├── ic_increase_green.png
│ │ │ │ └── ic_increase_primary.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── ic_increase_red.png
│ │ │ │ ├── ic_increase_blue.png
│ │ │ │ ├── ic_increase_green.png
│ │ │ │ └── ic_increase_primary.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── ic_increase_blue.png
│ │ │ │ ├── ic_increase_red.png
│ │ │ │ ├── ic_increase_green.png
│ │ │ │ └── ic_increase_primary.png
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── menu
│ │ │ │ └── main_menu.xml
│ │ │ ├── values-night
│ │ │ │ └── colors.xml
│ │ │ ├── layout
│ │ │ │ ├── fragment_states.xml
│ │ │ │ ├── fragment_main.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── state_item_card.xml
│ │ │ │ └── fragment_india.xml
│ │ │ └── drawable-anydpi
│ │ │ │ ├── ic_increase_blue.xml
│ │ │ │ ├── ic_increase_green.xml
│ │ │ │ ├── ic_increase_red.xml
│ │ │ │ └── ic_increase_primary.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── covidtracker
│ │ │ │ ├── data
│ │ │ │ └── RetrofitObjectAPI.java
│ │ │ │ ├── classes
│ │ │ │ ├── Results.java
│ │ │ │ ├── Statewise.java
│ │ │ │ └── Count.java
│ │ │ │ ├── ui
│ │ │ │ └── main
│ │ │ │ │ ├── PageViewModel.java
│ │ │ │ │ ├── SectionsPagerAdapter.java
│ │ │ │ │ └── PlaceholderFragment.java
│ │ │ │ ├── notifications
│ │ │ │ ├── NotificationHelper.java
│ │ │ │ └── AlertReceiver.java
│ │ │ │ ├── fragments
│ │ │ │ ├── StatesFragment.java
│ │ │ │ └── IndiaFragment.java
│ │ │ │ ├── adapter
│ │ │ │ └── StatesAdapter.java
│ │ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── covidtracker
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── covidtracker
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── .idea
├── .name
├── dictionaries
│ └── sukesh.xml
├── vcs.xml
├── misc.xml
├── runConfigurations.xml
├── gradle.xml
├── jarRepositories.xml
└── codeStyles
│ └── Project.xml
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | Covid Tracker
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name = "Covid Tracker"
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/corona.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable/corona.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap/corona.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/mipmap/corona.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/globe_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable/globe_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/india_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable/india_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap/corona_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/mipmap/corona_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_increase_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-hdpi/ic_increase_blue.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_increase_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-hdpi/ic_increase_red.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_increase_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-mdpi/ic_increase_blue.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_increase_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-mdpi/ic_increase_red.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_increase_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-xhdpi/ic_increase_red.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_increase_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-hdpi/ic_increase_green.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_increase_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-mdpi/ic_increase_green.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_increase_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-xhdpi/ic_increase_blue.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_increase_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-xhdpi/ic_increase_green.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_increase_blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-xxhdpi/ic_increase_blue.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_increase_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-xxhdpi/ic_increase_red.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_increase_primary.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-hdpi/ic_increase_primary.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_increase_primary.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-mdpi/ic_increase_primary.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_increase_primary.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-xhdpi/ic_increase_primary.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_increase_green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-xxhdpi/ic_increase_green.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_increase_primary.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/saisukesh04/Covid_Tracker/HEAD/app/src/main/res/drawable-xxhdpi/ic_increase_primary.png
--------------------------------------------------------------------------------
/.idea/dictionaries/sukesh.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | statewise
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
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 | #Tue Jun 23 10:41:26 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-6.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 | 16dp
7 | 8dp
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
7 | #FFFFFF
8 |
9 |
10 | #CC313131
11 | #FFFFFF
12 | #FF313131
13 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/covidtracker/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker;
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/java/com/example/covidtracker/data/RetrofitObjectAPI.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker.data;
2 |
3 | import com.example.covidtracker.classes.Results;
4 | import com.example.covidtracker.classes.Statewise;
5 |
6 | import retrofit2.Call;
7 | import retrofit2.http.GET;
8 |
9 | public interface RetrofitObjectAPI {
10 |
11 | @GET("free-api?global=stats")
12 | Call getWorldStats();
13 |
14 | @GET("free-api?countryTotal=IN")
15 | Call getIndiaStats();
16 |
17 | @GET("data.json")
18 | Call getAllStatesStats();
19 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
7 | #FFFFFF
8 | #FF0000
9 | #00BA00
10 | #0000FF
11 |
12 |
13 | #FFFFFF
14 | #000000
15 | #FFFFFF
16 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_states.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_night_mode.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Covid Tracker
3 | India Count
4 | State-wise Count
5 | Night Mode
6 | Deaths
7 | Recovered
8 | Total
9 | State
10 | World \
11 | 0
12 | India \
13 | Active
14 | Swipe for State-wise Data -> \
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/covidtracker/classes/Results.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker.classes;
2 |
3 | import java.util.List;
4 |
5 | public class Results {
6 |
7 | private List results;
8 | private List countrydata;
9 |
10 | public Results(List results, List countrydata) {
11 | this.results = results;
12 | this.countrydata = countrydata;
13 | }
14 |
15 | public List getResults() {
16 | return results;
17 | }
18 |
19 | public void setResults(List results) {
20 | this.results = results;
21 | }
22 |
23 | public List getCountrydata() {
24 | return countrydata;
25 | }
26 |
27 | public void setCountrydata(List countrydata) {
28 | this.countrydata = countrydata;
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
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-anydpi/ic_increase_blue.xml:
--------------------------------------------------------------------------------
1 |
8 |
12 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-anydpi/ic_increase_green.xml:
--------------------------------------------------------------------------------
1 |
8 |
12 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-anydpi/ic_increase_red.xml:
--------------------------------------------------------------------------------
1 |
8 |
12 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-anydpi/ic_increase_primary.xml:
--------------------------------------------------------------------------------
1 |
8 |
12 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/covidtracker/ui/main/PageViewModel.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker.ui.main;
2 |
3 | import androidx.arch.core.util.Function;
4 | import androidx.lifecycle.LiveData;
5 | import androidx.lifecycle.MutableLiveData;
6 | import androidx.lifecycle.Transformations;
7 | import androidx.lifecycle.ViewModel;
8 |
9 | public class PageViewModel extends ViewModel {
10 |
11 | private MutableLiveData mIndex = new MutableLiveData<>();
12 | private LiveData mText = Transformations.map(mIndex, new Function() {
13 | @Override
14 | public String apply(Integer input) {
15 | return "Hello world from section: " + input;
16 | }
17 | });
18 |
19 | public void setIndex(int index) {
20 | mIndex.setValue(index);
21 | }
22 |
23 | public LiveData getText() {
24 | return mText;
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/covidtracker/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker;
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 | assertEquals("com.example.covidtracker", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/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=-Xmx2048m
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
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
27 |
28 |
--------------------------------------------------------------------------------
/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.covidtracker"
9 | minSdkVersion 19
10 | targetSdkVersion 29
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 |
16 | compileOptions {
17 | sourceCompatibility JavaVersion.VERSION_1_8
18 | targetCompatibility JavaVersion.VERSION_1_8
19 | }
20 | }
21 |
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 | }
29 |
30 | dependencies {
31 | implementation fileTree(dir: "libs", include: ["*.jar"])
32 | implementation 'androidx.appcompat:appcompat:1.1.0'
33 | implementation 'com.google.android.material:material:1.0.0'
34 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
35 | implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
36 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
37 | testImplementation 'junit:junit:4.12'
38 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
39 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
40 |
41 | implementation 'com.squareup.retrofit2:retrofit:2.4.0'
42 | implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
43 |
44 | implementation 'com.jakewharton:butterknife:10.2.1'
45 | annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
46 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/covidtracker/ui/main/SectionsPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker.ui.main;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.annotation.Nullable;
6 | import androidx.annotation.StringRes;
7 | import androidx.fragment.app.Fragment;
8 | import androidx.fragment.app.FragmentManager;
9 | import androidx.fragment.app.FragmentPagerAdapter;
10 |
11 | import com.example.covidtracker.R;
12 | import com.example.covidtracker.fragments.IndiaFragment;
13 | import com.example.covidtracker.fragments.StatesFragment;
14 |
15 | /**
16 | * A [FragmentPagerAdapter] that returns a fragment corresponding to
17 | * one of the sections/tabs/pages.
18 | */
19 | public class SectionsPagerAdapter extends FragmentPagerAdapter {
20 |
21 | @StringRes
22 | private static final int[] TAB_TITLES = new int[]{R.string.tab_text_1, R.string.tab_text_2};
23 | private final Context mContext;
24 |
25 | public SectionsPagerAdapter(Context context, FragmentManager fm) {
26 | super(fm);
27 | mContext = context;
28 | }
29 |
30 | @Override
31 | public Fragment getItem(int position) {
32 | Fragment fragment = null;
33 | switch (position){
34 | case 0:
35 | fragment = new IndiaFragment();
36 | break;
37 |
38 | case 1:
39 | fragment = new StatesFragment();
40 |
41 | }
42 | return fragment;
43 | }
44 |
45 | @Nullable
46 | @Override
47 | public CharSequence getPageTitle(int position) {
48 | return mContext.getResources().getString(TAB_TITLES[position]);
49 | }
50 |
51 | @Override
52 | public int getCount() {
53 | // Show 2 total pages.
54 | return 2;
55 | }
56 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/covidtracker/ui/main/PlaceholderFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker.ui.main;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | import androidx.annotation.Nullable;
10 | import androidx.annotation.NonNull;
11 | import androidx.fragment.app.Fragment;
12 | import androidx.lifecycle.Observer;
13 | import androidx.lifecycle.ViewModelProviders;
14 |
15 | import com.example.covidtracker.R;
16 |
17 | /**
18 | * A placeholder fragment containing a simple view.
19 | */
20 | public class PlaceholderFragment extends Fragment {
21 |
22 | private static final String ARG_SECTION_NUMBER = "section_number";
23 |
24 | private PageViewModel pageViewModel;
25 |
26 | public static PlaceholderFragment newInstance(int index) {
27 | PlaceholderFragment fragment = new PlaceholderFragment();
28 | Bundle bundle = new Bundle();
29 | bundle.putInt(ARG_SECTION_NUMBER, index);
30 | fragment.setArguments(bundle);
31 | return fragment;
32 | }
33 |
34 | @Override
35 | public void onCreate(Bundle savedInstanceState) {
36 | super.onCreate(savedInstanceState);
37 | pageViewModel = ViewModelProviders.of(this).get(PageViewModel.class);
38 | int index = 1;
39 | if (getArguments() != null) {
40 | index = getArguments().getInt(ARG_SECTION_NUMBER);
41 | }
42 | pageViewModel.setIndex(index);
43 | }
44 |
45 | @Override
46 | public View onCreateView(
47 | @NonNull LayoutInflater inflater, ViewGroup container,
48 | Bundle savedInstanceState) {
49 | View root = inflater.inflate(R.layout.fragment_main, container, false);
50 | final TextView textView = root.findViewById(R.id.section_label);
51 | pageViewModel.getText().observe(this, new Observer() {
52 | @Override
53 | public void onChanged(@Nullable String s) {
54 | textView.setText(s);
55 | }
56 | });
57 | return root;
58 | }
59 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/covidtracker/notifications/NotificationHelper.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker.notifications;
2 |
3 | import android.annotation.TargetApi;
4 | import android.app.NotificationChannel;
5 | import android.app.NotificationManager;
6 | import android.content.Context;
7 | import android.content.ContextWrapper;
8 | import android.os.Build;
9 | import android.util.Log;
10 |
11 | import androidx.core.app.NotificationCompat;
12 |
13 | import com.example.covidtracker.R;
14 | import com.example.covidtracker.classes.Count;
15 | import com.example.covidtracker.classes.Results;
16 | import com.example.covidtracker.data.RetrofitObjectAPI;
17 |
18 | import java.util.List;
19 |
20 | import retrofit2.Call;
21 | import retrofit2.Callback;
22 | import retrofit2.Response;
23 | import retrofit2.Retrofit;
24 | import retrofit2.converter.gson.GsonConverterFactory;
25 |
26 | import static com.example.covidtracker.fragments.IndiaFragment.baseURL;
27 | import static com.example.covidtracker.notifications.AlertReceiver.INDIA_COUNT;
28 | import static com.example.covidtracker.notifications.AlertReceiver.WORLD_COUNT;
29 |
30 | public class NotificationHelper extends ContextWrapper {
31 |
32 | public static final String channelID = "channelID";
33 | public static final String channelName = "Channel Name";
34 | private NotificationManager mManager;
35 |
36 | public NotificationHelper(Context base) {
37 | super(base);
38 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
39 | createChannel();
40 | }
41 | }
42 |
43 | @TargetApi(Build.VERSION_CODES.O)
44 | private void createChannel() {
45 | NotificationChannel channel = new NotificationChannel(channelID, channelName, NotificationManager.IMPORTANCE_HIGH);
46 | getManager().createNotificationChannel(channel);
47 | }
48 |
49 | public NotificationManager getManager() {
50 | if (mManager == null) {
51 | mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
52 | }
53 | return mManager;
54 | }
55 |
56 | public NotificationCompat.Builder getChannelNotification() {
57 |
58 | return new NotificationCompat.Builder(getApplicationContext(), channelID)
59 | .setContentTitle("Cases Update")
60 | .setContentText("World Cases: " + WORLD_COUNT + ", India Cases: " + INDIA_COUNT)
61 | .setSmallIcon(R.drawable.corona);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/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/covidtracker/classes/Statewise.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker.classes;
2 |
3 | import java.util.List;
4 |
5 | public class Statewise {
6 |
7 | private List statewise;
8 | private String active, confirmed, deaths, deltaconfirmed, deltadeaths, recovered, deltarecovered, state;
9 |
10 | public Statewise() {
11 | }
12 |
13 | public Statewise(String active, String confirmed, String deaths, String deltaconfirmed, String deltadeaths, String recovered, String deltarecovered, String state) {
14 | this.active = active;
15 | this.confirmed = confirmed;
16 | this.deaths = deaths;
17 | this.deltaconfirmed = deltaconfirmed;
18 | this.deltadeaths = deltadeaths;
19 | this.recovered = recovered;
20 | this.deltarecovered = deltarecovered;
21 | this.state = state;
22 | }
23 |
24 | public List getStatewise() {
25 | return statewise;
26 | }
27 |
28 | public void setStatewise(List statewise) {
29 | this.statewise = statewise;
30 | }
31 |
32 | public String getActive() {
33 | return active;
34 | }
35 |
36 | public void setActive(String active) {
37 | this.active = active;
38 | }
39 |
40 | public String getConfirmed() {
41 | return confirmed;
42 | }
43 |
44 | public void setConfirmed(String confirmed) {
45 | this.confirmed = confirmed;
46 | }
47 |
48 | public String getDeaths() {
49 | return deaths;
50 | }
51 |
52 | public void setDeaths(String deaths) {
53 | this.deaths = deaths;
54 | }
55 |
56 | public String getDeltaconfirmed() {
57 | return deltaconfirmed;
58 | }
59 |
60 | public void setDeltaconfirmed(String deltaconfirmed) {
61 | this.deltaconfirmed = deltaconfirmed;
62 | }
63 |
64 | public String getDeltadeaths() {
65 | return deltadeaths;
66 | }
67 |
68 | public void setDeltadeaths(String deltadeaths) {
69 | this.deltadeaths = deltadeaths;
70 | }
71 |
72 | public String getRecovered() {
73 | return recovered;
74 | }
75 |
76 | public void setRecovered(String recovered) {
77 | this.recovered = recovered;
78 | }
79 |
80 | public String getDeltarecovered() {
81 | return deltarecovered;
82 | }
83 |
84 | public void setDeltarecovered(String deltarecovered) {
85 | this.deltarecovered = deltarecovered;
86 | }
87 |
88 | public String getState() {
89 | return state;
90 | }
91 |
92 | public void setState(String state) {
93 | this.state = state;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/covidtracker/fragments/StatesFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker.fragments;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.fragment.app.Fragment;
6 | import androidx.recyclerview.widget.LinearLayoutManager;
7 | import androidx.recyclerview.widget.RecyclerView;
8 |
9 | import android.util.Log;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | import com.example.covidtracker.R;
15 | import com.example.covidtracker.adapter.StatesAdapter;
16 | import com.example.covidtracker.classes.Statewise;
17 | import com.example.covidtracker.data.RetrofitObjectAPI;
18 |
19 | import java.util.List;
20 |
21 | import retrofit2.Call;
22 | import retrofit2.Callback;
23 | import retrofit2.Response;
24 | import retrofit2.Retrofit;
25 | import retrofit2.converter.gson.GsonConverterFactory;
26 |
27 | public class StatesFragment extends Fragment {
28 |
29 | public final String baseURL = "https://api.covid19india.org/";
30 | private RecyclerView state_stats_recycler_view;
31 |
32 | public StatesFragment() {
33 | // Required empty public constructor
34 | }
35 |
36 | @Override
37 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
38 | Bundle savedInstanceState) {
39 | // Inflate the layout for this fragment
40 | View view = inflater.inflate(R.layout.fragment_states, container, false);
41 |
42 | state_stats_recycler_view = view.findViewById(R.id.state_stats_recycler_view);
43 |
44 | LinearLayoutManager mLayout = new LinearLayoutManager(getContext());
45 | state_stats_recycler_view.setHasFixedSize(true);
46 | state_stats_recycler_view.setLayoutManager(mLayout);
47 |
48 | Retrofit retrofit = new Retrofit.Builder()
49 | .baseUrl(baseURL)
50 | .addConverterFactory(GsonConverterFactory.create())
51 | .build();
52 |
53 | RetrofitObjectAPI service = retrofit.create(RetrofitObjectAPI.class);
54 | Call stateCountCall;
55 |
56 | stateCountCall = service.getAllStatesStats();
57 |
58 | stateCountCall.enqueue(new Callback() {
59 | @Override
60 | public void onResponse(Call call, Response response) {
61 | assert response.body() != null;
62 | List stateStats = response.body().getStatewise();
63 | stateStats.remove(0);
64 | StatesAdapter adapter = new StatesAdapter(getActivity(), stateStats);
65 | state_stats_recycler_view.setAdapter(adapter);
66 | }
67 |
68 | @Override
69 | public void onFailure(Call call, Throwable t) {
70 | Log.i("info: Error: ", t.getMessage());
71 | }
72 | });
73 |
74 | return view;
75 | }
76 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/covidtracker/notifications/AlertReceiver.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker.notifications;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.util.Log;
7 |
8 | import androidx.core.app.NotificationCompat;
9 |
10 | import com.example.covidtracker.classes.Count;
11 | import com.example.covidtracker.classes.Results;
12 | import com.example.covidtracker.data.RetrofitObjectAPI;
13 |
14 | import java.util.List;
15 |
16 | import retrofit2.Call;
17 | import retrofit2.Callback;
18 | import retrofit2.Response;
19 | import retrofit2.Retrofit;
20 | import retrofit2.converter.gson.GsonConverterFactory;
21 |
22 | import static com.example.covidtracker.fragments.IndiaFragment.baseURL;
23 |
24 | public class AlertReceiver extends BroadcastReceiver {
25 |
26 | public static String WORLD_COUNT;
27 | public static String INDIA_COUNT;
28 |
29 | @Override
30 | public void onReceive(Context context, Intent intent) {
31 |
32 | Retrofit retrofit = new Retrofit.Builder()
33 | .baseUrl(baseURL)
34 | .addConverterFactory(GsonConverterFactory.create())
35 | .build();
36 |
37 | RetrofitObjectAPI service = retrofit.create(RetrofitObjectAPI.class);
38 | Call worldCountCall, indiaCountCall;
39 |
40 | worldCountCall = service.getWorldStats();
41 | indiaCountCall = service.getIndiaStats();
42 |
43 | worldCountCall.enqueue(new Callback() {
44 | @Override
45 | public void onResponse(Call call, Response response) {
46 | assert response.body() != null;
47 | List worldStats = response.body().getResults();
48 | WORLD_COUNT = worldStats.get(0).getTotal_cases();
49 | }
50 |
51 | @Override
52 | public void onFailure(Call call, Throwable t) {
53 | Log.i("info: Error: ", t.getMessage());
54 | }
55 | });
56 |
57 | indiaCountCall.enqueue(new Callback() {
58 | @Override
59 | public void onResponse(Call call, Response response) {
60 | assert response.body() != null;
61 | List indiaStats = response.body().getCountrydata();
62 | INDIA_COUNT = indiaStats.get(0).getTotal_cases();
63 |
64 | NotificationHelper notificationHelper = new NotificationHelper(context);
65 | NotificationCompat.Builder nb = notificationHelper.getChannelNotification();
66 | notificationHelper.getManager().notify(1, nb.build());
67 | }
68 |
69 | @Override
70 | public void onFailure(Call call, Throwable t) {
71 | Log.i("info: Error: ", t.getMessage());
72 | }
73 | });
74 | }
75 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/covidtracker/classes/Count.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker.classes;
2 |
3 | public class Count {
4 |
5 | private String total_cases, total_recovered, total_unresolved, total_deaths,
6 | total_new_cases_today, total_new_deaths_today, total_active_cases, total_serious_cases;
7 |
8 | public Count() {
9 | }
10 |
11 | public Count(String total_cases, String total_recovered, String total_unresolved, String total_deaths, String total_new_cases_today, String total_new_deaths_today, String total_active_cases, String total_serious_cases) {
12 | this.total_cases = total_cases;
13 | this.total_recovered = total_recovered;
14 | this.total_unresolved = total_unresolved;
15 | this.total_deaths = total_deaths;
16 | this.total_new_cases_today = total_new_cases_today;
17 | this.total_new_deaths_today = total_new_deaths_today;
18 | this.total_active_cases = total_active_cases;
19 | this.total_serious_cases = total_serious_cases;
20 | }
21 |
22 | public String getTotal_cases() {
23 | return total_cases;
24 | }
25 |
26 | public void setTotal_cases(String total_cases) {
27 | this.total_cases = total_cases;
28 | }
29 |
30 | public String getTotal_recovered() {
31 | return total_recovered;
32 | }
33 |
34 | public void setTotal_recovered(String total_recovered) {
35 | this.total_recovered = total_recovered;
36 | }
37 |
38 | public String getTotal_unresolved() {
39 | return total_unresolved;
40 | }
41 |
42 | public void setTotal_unresolved(String total_unresolved) {
43 | this.total_unresolved = total_unresolved;
44 | }
45 |
46 | public String getTotal_deaths() {
47 | return total_deaths;
48 | }
49 |
50 | public void setTotal_deaths(String total_deaths) {
51 | this.total_deaths = total_deaths;
52 | }
53 |
54 | public String getTotal_new_cases_today() {
55 | return total_new_cases_today;
56 | }
57 |
58 | public void setTotal_new_cases_today(String total_new_cases_today) {
59 | this.total_new_cases_today = total_new_cases_today;
60 | }
61 |
62 | public String getTotal_new_deaths_today() {
63 | return total_new_deaths_today;
64 | }
65 |
66 | public void setTotal_new_deaths_today(String total_new_deaths_today) {
67 | this.total_new_deaths_today = total_new_deaths_today;
68 | }
69 |
70 | public String getTotal_active_cases() {
71 | return total_active_cases;
72 | }
73 |
74 | public void setTotal_active_cases(String total_active_cases) {
75 | this.total_active_cases = total_active_cases;
76 | }
77 |
78 | public String getTotal_serious_cases() {
79 | return total_serious_cases;
80 | }
81 |
82 | public void setTotal_serious_cases(String total_serious_cases) {
83 | this.total_serious_cases = total_serious_cases;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/covidtracker/adapter/StatesAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker.adapter;
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.TextView;
8 |
9 | import androidx.annotation.NonNull;
10 | import androidx.recyclerview.widget.RecyclerView;
11 |
12 | import com.example.covidtracker.R;
13 | import com.example.covidtracker.classes.Statewise;
14 |
15 | import java.util.List;
16 |
17 | public class StatesAdapter extends RecyclerView.Adapter {
18 |
19 | private List stateData;
20 | private Context context;
21 |
22 | public StatesAdapter(Context context, List stateData) {
23 | this.context = context;
24 | this.stateData = stateData;
25 | }
26 |
27 | @NonNull
28 | @Override
29 | public StatesAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
30 | View view = LayoutInflater.from(context).inflate(R.layout.state_item_card,parent,false);
31 | return new ViewHolder(view);
32 | }
33 |
34 | @Override
35 | public void onBindViewHolder(@NonNull StatesAdapter.ViewHolder holder, int position) {
36 | Statewise statewise = stateData.get(position);
37 | holder.state_name_text.setText(statewise.getState());
38 | holder.total_count.setText(statewise.getConfirmed());
39 | holder.active_count.setText(statewise.getActive());
40 | holder.recovered_count.setText(statewise.getRecovered());
41 | holder.death_count.setText(statewise.getDeaths());
42 | holder.increase_total_count.setText(statewise.getDeltaconfirmed());
43 | holder.increase_recovered_count.setText(statewise.getDeltarecovered());
44 | holder.increase_death_count.setText(statewise.getDeltadeaths());
45 | }
46 |
47 | @Override
48 | public int getItemCount() {
49 | return stateData != null ? stateData.size() :0;
50 | }
51 |
52 | public class ViewHolder extends RecyclerView.ViewHolder{
53 |
54 | TextView total_count, active_count, recovered_count, death_count, state_name_text;
55 | TextView increase_total_count, increase_recovered_count, increase_death_count;
56 |
57 | public ViewHolder(@NonNull View itemView) {
58 | super(itemView);
59 | state_name_text = itemView.findViewById(R.id.state_name_text);
60 | total_count = itemView.findViewById(R.id.total_count);
61 | active_count = itemView.findViewById(R.id.active_count);
62 | recovered_count = itemView.findViewById(R.id.recovered_count);
63 | death_count = itemView.findViewById(R.id.death_count);
64 | increase_total_count = itemView.findViewById(R.id.increase_total_count);
65 | increase_recovered_count = itemView.findViewById(R.id.increase_recovered_count);
66 | increase_death_count = itemView.findViewById(R.id.increase_death_count);
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/.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/java/com/example/covidtracker/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker;
2 |
3 | import android.app.AlarmManager;
4 | import android.app.PendingIntent;
5 | import android.content.Context;
6 | import android.content.DialogInterface;
7 | import android.content.Intent;
8 | import android.content.SharedPreferences;
9 | import android.net.ConnectivityManager;
10 | import android.net.NetworkInfo;
11 | import android.os.Bundle;
12 |
13 | import androidx.annotation.NonNull;
14 | import androidx.appcompat.app.AlertDialog;
15 | import androidx.appcompat.app.AppCompatDelegate;
16 | import androidx.appcompat.widget.Toolbar;
17 | import androidx.viewpager.widget.ViewPager;
18 | import androidx.appcompat.app.AppCompatActivity;
19 |
20 | import android.view.Menu;
21 | import android.view.MenuItem;
22 | import android.widget.Toast;
23 |
24 | import com.example.covidtracker.notifications.AlertReceiver;
25 | import com.example.covidtracker.ui.main.SectionsPagerAdapter;
26 |
27 | public class MainActivity extends AppCompatActivity {
28 |
29 | private SharedPreferences modeSetting;
30 | private SharedPreferences.Editor modeEdit;
31 | private boolean nightMode;
32 |
33 | @Override
34 | protected void onCreate(Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_main);
37 |
38 | modeSetting = getSharedPreferences("ModeSetting", 0);
39 | modeEdit = modeSetting.edit();
40 | nightMode = modeSetting.getBoolean("NightMode", false);
41 |
42 | if (nightMode) {
43 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
44 | }
45 |
46 | ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
47 | assert cm != null;
48 | NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
49 | boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
50 |
51 | if (isConnected) {
52 | SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager());
53 | ViewPager viewPager = findViewById(R.id.view_pager);
54 | viewPager.setAdapter(sectionsPagerAdapter);
55 | } else {
56 | AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
57 | builder.setMessage("Please check your Internet connection and try again");
58 | builder.setTitle("No Internet!!");
59 | builder.setCancelable(false);
60 |
61 | builder.setPositiveButton("CLOSE", new DialogInterface.OnClickListener() {
62 | @Override
63 | public void onClick(DialogInterface dialog, int which) {
64 | finish();
65 | }
66 | });
67 |
68 | AlertDialog alertDialog = builder.create();
69 | alertDialog.show();
70 | }
71 |
72 | Toolbar toolbar = findViewById(R.id.toolbar);
73 | setSupportActionBar(toolbar);
74 | setNotification();
75 | }
76 |
77 | @Override
78 | public boolean onCreateOptionsMenu(Menu menu) {
79 | getMenuInflater().inflate(R.menu.main_menu, menu);
80 | return true;
81 | }
82 |
83 | @Override
84 | public boolean onOptionsItemSelected(@NonNull MenuItem item) {
85 | switch (item.getItemId()) {
86 | case R.id.action_mode:
87 | if (!nightMode) {
88 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
89 | nightMode = true;
90 | Toast.makeText(this, "Dark Mode On", Toast.LENGTH_SHORT).show();
91 | modeEdit.putBoolean("NightMode", true);
92 | } else {
93 | AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
94 | nightMode = false;
95 | Toast.makeText(this, "Dark Mode Off", Toast.LENGTH_SHORT).show();
96 | modeEdit.putBoolean("NightMode", false);
97 | }
98 | modeEdit.apply();
99 | return true;
100 |
101 | default:
102 | return false;
103 | }
104 | }
105 |
106 | public void setNotification(){
107 | AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
108 | Intent intent = new Intent(this, AlertReceiver.class);
109 | PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1, intent, 0);
110 |
111 | alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 3600000, pendingIntent);
112 | }
113 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/covidtracker/fragments/IndiaFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.covidtracker.fragments;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.fragment.app.Fragment;
6 |
7 | import android.util.Log;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.TextView;
12 |
13 | import com.example.covidtracker.classes.Count;
14 | import com.example.covidtracker.R;
15 | import com.example.covidtracker.classes.Results;
16 | import com.example.covidtracker.data.RetrofitObjectAPI;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | import butterknife.BindView;
22 | import butterknife.ButterKnife;
23 | import retrofit2.Call;
24 | import retrofit2.Callback;
25 | import retrofit2.Response;
26 | import retrofit2.Retrofit;
27 | import retrofit2.converter.gson.GsonConverterFactory;
28 |
29 | public class IndiaFragment extends Fragment {
30 |
31 | @BindView(R.id.world_total_count) TextView world_total_count;
32 | @BindView(R.id.world_active_count) TextView world_active_count;
33 | @BindView(R.id.world_recovered_count) TextView world_recovered_count;
34 | @BindView(R.id.world_death_count) TextView world_death_count;
35 | @BindView(R.id.increase_world_total_count) TextView increase_world_total_count;
36 | @BindView(R.id.increase_world_death_count) TextView increase_world_death_count;
37 | @BindView(R.id.india_total_count) TextView india_total_count;
38 | @BindView(R.id.india_active_count) TextView india_active_count;
39 | @BindView(R.id.india_recovered_count) TextView india_recovered_count;
40 | @BindView(R.id.india_death_count) TextView india_death_count;
41 | @BindView(R.id.increase_india_total_count) TextView increase_india_total_count;
42 | @BindView(R.id.increase_india_death_count) TextView increase_india_death_count;
43 |
44 | public final static String baseURL = "https://api.thevirustracker.com/";
45 |
46 | public IndiaFragment() {
47 | // Required empty public constructor
48 | }
49 |
50 | @Override
51 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
52 | Bundle savedInstanceState) {
53 | // Inflate the layout for this fragment
54 | View view = inflater.inflate(R.layout.fragment_india, container, false);
55 |
56 | ButterKnife.bind(this, view);
57 |
58 | Retrofit retrofit = new Retrofit.Builder()
59 | .baseUrl(baseURL)
60 | .addConverterFactory(GsonConverterFactory.create())
61 | .build();
62 |
63 | RetrofitObjectAPI service = retrofit.create(RetrofitObjectAPI.class);
64 | Call worldCountCall, indiaCountCall;
65 |
66 | worldCountCall = service.getWorldStats();
67 | indiaCountCall = service.getIndiaStats();
68 |
69 | worldCountCall.enqueue(new Callback() {
70 | @Override
71 | public void onResponse(Call call, Response response) {
72 | assert response.body() != null;
73 | List worldStats = response.body().getResults();
74 | world_total_count.setText(worldStats.get(0).getTotal_cases());
75 | world_active_count.setText(worldStats.get(0).getTotal_unresolved());
76 | world_recovered_count.setText(worldStats.get(0).getTotal_recovered());
77 | world_death_count.setText(worldStats.get(0).getTotal_deaths());
78 | increase_world_total_count.setText(worldStats.get(0).getTotal_new_cases_today());
79 | increase_world_death_count.setText(worldStats.get(0).getTotal_new_deaths_today());
80 | }
81 |
82 | @Override
83 | public void onFailure(Call call, Throwable t) {
84 | Log.i("info: Error: ", t.getMessage());
85 | }
86 | });
87 |
88 | indiaCountCall.enqueue(new Callback() {
89 | @Override
90 | public void onResponse(Call call, Response response) {
91 | assert response.body() != null;
92 | List indiaStats = response.body().getCountrydata();
93 | india_total_count.setText(indiaStats.get(0).getTotal_cases());
94 | if(indiaStats.get(0).getTotal_unresolved().equals("0"))
95 | india_active_count.setText("-");
96 | else
97 | india_active_count.setText(indiaStats.get(0).getTotal_unresolved());
98 | india_recovered_count.setText(indiaStats.get(0).getTotal_recovered());
99 | india_death_count.setText(indiaStats.get(0).getTotal_deaths());
100 | increase_india_total_count.setText(indiaStats.get(0).getTotal_new_cases_today());
101 | increase_india_death_count.setText(indiaStats.get(0).getTotal_new_deaths_today());
102 | }
103 |
104 | @Override
105 | public void onFailure(Call call, Throwable t) {
106 | Log.i("info: Error: ", t.getMessage());
107 | }
108 | });
109 |
110 | return view;
111 | }
112 | }
--------------------------------------------------------------------------------
/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/layout/state_item_card.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
18 |
19 |
31 |
32 |
41 |
42 |
53 |
54 |
63 |
64 |
72 |
73 |
74 |
75 |
84 |
85 |
96 |
97 |
106 |
107 |
108 |
109 |
118 |
119 |
130 |
131 |
140 |
141 |
149 |
150 |
151 |
152 |
161 |
162 |
173 |
174 |
175 |
184 |
185 |
193 |
194 |
195 |
196 |
197 |
198 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_india.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
12 |
20 |
21 |
26 |
27 |
40 |
41 |
50 |
51 |
62 |
63 |
72 |
73 |
81 |
82 |
83 |
84 |
93 |
94 |
105 |
106 |
115 |
116 |
117 |
118 |
127 |
128 |
139 |
140 |
149 |
150 |
151 |
152 |
161 |
162 |
173 |
174 |
175 |
184 |
185 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
206 |
207 |
212 |
213 |
226 |
227 |
236 |
237 |
248 |
249 |
258 |
259 |
267 |
268 |
269 |
270 |
279 |
280 |
291 |
292 |
301 |
302 |
303 |
304 |
313 |
314 |
325 |
326 |
335 |
336 |
337 |
338 |
347 |
348 |
359 |
360 |
369 |
370 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
393 |
394 |
--------------------------------------------------------------------------------