mirror of
https://github.com/SoPat712/TrackCovid19.git
synced 2025-08-27 21:02:18 -04:00
Initial Upload
This commit is contained in:
95
app/src/main/java/com/josh/trackcovid19v2/data/CountriesRepository.java
Executable file
95
app/src/main/java/com/josh/trackcovid19v2/data/CountriesRepository.java
Executable file
@@ -0,0 +1,95 @@
|
||||
package com.josh.trackcovid19v2.data;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import com.josh.trackcovid19v2.AppExecutors;
|
||||
import com.josh.trackcovid19v2.data.database.CountriesDao;
|
||||
import com.josh.trackcovid19v2.data.database.YesCountriesDao;
|
||||
import com.josh.trackcovid19v2.data.database.entity.Countries;
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesCountries;
|
||||
import com.josh.trackcovid19v2.data.network.UserNetworkDataSource;
|
||||
import com.josh.trackcovid19v2.model.ServiceRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class responsible for handling data operations. This is the mediator between different
|
||||
* data sources (persistent model, web service, cache, etc.)
|
||||
*/
|
||||
public class CountriesRepository {
|
||||
private static final String LOG_TAG = CountriesRepository.class.getSimpleName();
|
||||
|
||||
private CountriesDao mCountriesDao;
|
||||
private YesCountriesDao mYesCountriesDao;
|
||||
private UserNetworkDataSource mNetworkDataSource;
|
||||
|
||||
// For Singleton instantiationz
|
||||
private static final Object LOCK = new Object();
|
||||
private static CountriesRepository sInstance;
|
||||
|
||||
public CountriesRepository(CountriesDao countriesDao,
|
||||
YesCountriesDao yescountriesDao,
|
||||
UserNetworkDataSource networkDataSource, AppExecutors
|
||||
executors) {
|
||||
this.mCountriesDao = countriesDao;
|
||||
this.mYesCountriesDao = yescountriesDao;
|
||||
this.mNetworkDataSource = networkDataSource;
|
||||
|
||||
// As long as the repository exists, observe the network LiveData.
|
||||
// If that LiveData changes, update the database.
|
||||
mNetworkDataSource.getCountriesList().observeForever(countries -> {
|
||||
executors.diskIO().execute(() -> {
|
||||
|
||||
Log.d(LOG_TAG, "countries table is updating");
|
||||
mCountriesDao.updateAll(countries);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
mNetworkDataSource.getYesCountriesList().observeForever(yescountries -> {
|
||||
executors.diskIO().execute(() -> {
|
||||
|
||||
Log.d(LOG_TAG, "yes countries table is updating");
|
||||
mYesCountriesDao.updateAll(yescountries);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static CountriesRepository getInstance(CountriesDao countriesDao,
|
||||
YesCountriesDao yesCountriesDao,
|
||||
UserNetworkDataSource
|
||||
networkDataSource, AppExecutors executors) {
|
||||
Log.d(LOG_TAG, "Getting the yes countries repository");
|
||||
if (sInstance == null) {
|
||||
synchronized (LOCK) {
|
||||
sInstance = new CountriesRepository(countriesDao,
|
||||
yesCountriesDao,
|
||||
networkDataSource, executors);
|
||||
Log.d(LOG_TAG, "Made new countries repository");
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public LiveData<List<Countries>> getCountriesList() {
|
||||
LiveData<List<Countries>> foo = mCountriesDao.getCountriesList();
|
||||
return foo;
|
||||
}
|
||||
|
||||
public void postServiceRequest(ServiceRequest serviceRequest) {
|
||||
mNetworkDataSource.fetchCountriesData(serviceRequest);
|
||||
}
|
||||
|
||||
public LiveData<List<YesCountries>> getYesCountriesList() {
|
||||
LiveData<List<YesCountries>> fie = mYesCountriesDao.getYesCountriesList();
|
||||
return fie;
|
||||
}
|
||||
|
||||
public void postServiceRequest1(ServiceRequest serviceRequest) {
|
||||
mNetworkDataSource.fetchYesCountriesData(serviceRequest);
|
||||
}
|
||||
}
|
95
app/src/main/java/com/josh/trackcovid19v2/data/StateRepository.java
Executable file
95
app/src/main/java/com/josh/trackcovid19v2/data/StateRepository.java
Executable file
@@ -0,0 +1,95 @@
|
||||
package com.josh.trackcovid19v2.data;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import com.josh.trackcovid19v2.AppExecutors;
|
||||
import com.josh.trackcovid19v2.data.database.StateDao;
|
||||
import com.josh.trackcovid19v2.data.database.YesStateDao;
|
||||
import com.josh.trackcovid19v2.data.database.entity.States;
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesStates;
|
||||
import com.josh.trackcovid19v2.data.network.UserNetworkDataSource;
|
||||
import com.josh.trackcovid19v2.model.ServiceRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class responsible for handling data operations. This is the mediator between different
|
||||
* data sources (persistent model, web service, cache, etc.)
|
||||
*/
|
||||
public class StateRepository {
|
||||
private static final String LOG_TAG = StateRepository.class.getSimpleName();
|
||||
|
||||
private StateDao mStatesDao;
|
||||
private YesStateDao mYesStatesDao;
|
||||
private UserNetworkDataSource mNetworkDataSource;
|
||||
|
||||
// For Singleton instantiationz
|
||||
private static final Object LOCK = new Object();
|
||||
private static StateRepository sInstance;
|
||||
|
||||
public StateRepository(StateDao stateDao,
|
||||
YesStateDao yesstatesDao,
|
||||
UserNetworkDataSource networkDataSource, AppExecutors
|
||||
executors) {
|
||||
this.mStatesDao = stateDao;
|
||||
this.mYesStatesDao = yesstatesDao;
|
||||
this.mNetworkDataSource = networkDataSource;
|
||||
|
||||
// As long as the repository exists, observe the network LiveData.
|
||||
// If that LiveData changes, update the database.
|
||||
mNetworkDataSource.getStatesList().observeForever(states -> {
|
||||
executors.diskIO().execute(() -> {
|
||||
|
||||
Log.d(LOG_TAG, "states table is updating");
|
||||
mStatesDao.updateAll(states);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
mNetworkDataSource.getYesStatesList().observeForever(yesstates -> {
|
||||
executors.diskIO().execute(() -> {
|
||||
|
||||
Log.d(LOG_TAG, "yes states table is updating");
|
||||
mYesStatesDao.updateAll(yesstates);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static StateRepository getInstance(StateDao stateDao,
|
||||
YesStateDao yesStateDao,
|
||||
UserNetworkDataSource
|
||||
networkDataSource, AppExecutors executors) {
|
||||
Log.d(LOG_TAG, "Getting the yes states repository");
|
||||
if (sInstance == null) {
|
||||
synchronized (LOCK) {
|
||||
sInstance = new StateRepository(stateDao,
|
||||
yesStateDao,
|
||||
networkDataSource, executors);
|
||||
Log.d(LOG_TAG, "Made new states repository");
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public LiveData<List<States>> getStatesList() {
|
||||
LiveData<List<States>> foo = mStatesDao.getStatesList();
|
||||
return foo;
|
||||
}
|
||||
|
||||
public void postServiceRequest(ServiceRequest serviceRequest) {
|
||||
mNetworkDataSource.fetchStatesData(serviceRequest);
|
||||
}
|
||||
|
||||
public LiveData<List<YesStates>> getYesStatesList() {
|
||||
LiveData<List<YesStates>> fie = mYesStatesDao.getYesStatesList();
|
||||
return fie;
|
||||
}
|
||||
|
||||
public void postServiceRequest1(ServiceRequest serviceRequest) {
|
||||
mNetworkDataSource.fetchYesStatesData(serviceRequest);
|
||||
}
|
||||
}
|
85
app/src/main/java/com/josh/trackcovid19v2/data/WorldRepository.java
Executable file
85
app/src/main/java/com/josh/trackcovid19v2/data/WorldRepository.java
Executable file
@@ -0,0 +1,85 @@
|
||||
package com.josh.trackcovid19v2.data;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
|
||||
import com.josh.trackcovid19v2.AppExecutors;
|
||||
import com.josh.trackcovid19v2.data.database.WorldDao;
|
||||
import com.josh.trackcovid19v2.data.database.YesWorldDao;
|
||||
import com.josh.trackcovid19v2.data.database.entity.World;
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesWorld;
|
||||
import com.josh.trackcovid19v2.data.network.UserNetworkDataSource;
|
||||
import com.josh.trackcovid19v2.model.ServiceRequest;
|
||||
|
||||
/**
|
||||
* This class responsible for handling data operations. This is the mediator between different
|
||||
* data sources (persistent model, web service, cache, etc.)
|
||||
*/
|
||||
public class WorldRepository {
|
||||
private static final String LOG_TAG = WorldRepository.class.getSimpleName();
|
||||
|
||||
private WorldDao mWorldDao;
|
||||
private YesWorldDao mYesWorldDao;
|
||||
private UserNetworkDataSource mNetworkDataSource;
|
||||
|
||||
// For Singleton instantiation
|
||||
private static final Object LOCK = new Object();
|
||||
private static WorldRepository sInstance;
|
||||
|
||||
public WorldRepository(WorldDao worldDao, YesWorldDao yesworldDao, UserNetworkDataSource networkDataSource, AppExecutors
|
||||
executors) {
|
||||
this.mWorldDao = worldDao;
|
||||
this.mYesWorldDao = yesworldDao;
|
||||
this.mNetworkDataSource = networkDataSource;
|
||||
|
||||
// As long as the repository exists, observe the network LiveData.
|
||||
// If that LiveData changes, update the database.
|
||||
mNetworkDataSource.getWorld().observeForever(world -> {
|
||||
executors.diskIO().execute(() -> {
|
||||
|
||||
Log.d(LOG_TAG, "world table is updating");
|
||||
mWorldDao.updateAll(world);
|
||||
});
|
||||
});
|
||||
|
||||
mNetworkDataSource.getYesWorld().observeForever(yesworld -> {
|
||||
executors.diskIO().execute(() -> {
|
||||
|
||||
Log.d(LOG_TAG, "yes world table is updating");
|
||||
mYesWorldDao.updateAll(yesworld);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static WorldRepository getInstance(WorldDao worldDao, YesWorldDao yesworldDao, UserNetworkDataSource
|
||||
networkDataSource, AppExecutors executors) {
|
||||
Log.d(LOG_TAG, "Getting the repository");
|
||||
if (sInstance == null) {
|
||||
synchronized (LOCK) {
|
||||
sInstance = new WorldRepository(worldDao, yesworldDao, networkDataSource, executors);
|
||||
Log.d(LOG_TAG, "Made new world repository");
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public LiveData<World> getWorld() {
|
||||
LiveData<World> foo = mWorldDao.getWorld();
|
||||
return foo;
|
||||
}
|
||||
|
||||
public LiveData<YesWorld> getYesWorld() {
|
||||
LiveData<YesWorld> foo = mYesWorldDao.getYesWorld();
|
||||
return foo;
|
||||
}
|
||||
|
||||
public void postServiceRequest(ServiceRequest serviceRequest) {
|
||||
mNetworkDataSource.fetchWorldData(serviceRequest);
|
||||
}
|
||||
|
||||
public void postServiceRequest1(ServiceRequest serviceRequest) {
|
||||
mNetworkDataSource.fetchYesWorldData(serviceRequest);
|
||||
}
|
||||
|
||||
}
|
33
app/src/main/java/com/josh/trackcovid19v2/data/database/CountriesDao.java
Executable file
33
app/src/main/java/com/josh/trackcovid19v2/data/database/CountriesDao.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package com.josh.trackcovid19v2.data.database;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Transaction;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.Countries;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Dao
|
||||
public abstract class CountriesDao {
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
abstract void bulkInsert(List<Countries> countries);
|
||||
|
||||
@Query("DELETE FROM countries")
|
||||
abstract void deleteAll();
|
||||
|
||||
@Query("Select * FROM countries ORDER BY country ASC")
|
||||
public abstract LiveData<List<Countries>> getCountriesList();
|
||||
|
||||
@Transaction
|
||||
public void updateAll(List<Countries> countries) {
|
||||
deleteAll();
|
||||
bulkInsert(countries);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.josh.trackcovid19v2.data.database;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.Countries;
|
||||
|
||||
//@Database(entities = { YourEntity.class }, version = 1, exportSchema = false)
|
||||
@Database(entities = {Countries.class}, version = 1, exportSchema = false)
|
||||
public abstract class CountriesDatabase extends RoomDatabase {
|
||||
|
||||
private static final String LOG_TAG = CountriesDatabase.class.getSimpleName();
|
||||
private static final String DATABASE_NAME = "countries";
|
||||
|
||||
// For Singleton instantiation
|
||||
private static final Object LOCK = new Object();
|
||||
private static CountriesDatabase mInstance;
|
||||
|
||||
public static CountriesDatabase getInstance(Context context) {
|
||||
Log.d(LOG_TAG, "Getting " + DATABASE_NAME + " database");
|
||||
|
||||
if (mInstance == null) {
|
||||
synchronized (LOCK) {
|
||||
mInstance = Room.databaseBuilder(context, CountriesDatabase.class, DATABASE_NAME).build();
|
||||
Log.d(LOG_TAG, DATABASE_NAME + " database has been created.");
|
||||
}
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
// The associated DAOs for the database
|
||||
public abstract CountriesDao countriesDao();
|
||||
|
||||
}
|
31
app/src/main/java/com/josh/trackcovid19v2/data/database/StateDao.java
Executable file
31
app/src/main/java/com/josh/trackcovid19v2/data/database/StateDao.java
Executable file
@@ -0,0 +1,31 @@
|
||||
package com.josh.trackcovid19v2.data.database;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Transaction;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.States;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public abstract class StateDao {
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
abstract void bulkInsert(List<States> states);
|
||||
|
||||
@Query("DELETE FROM states")
|
||||
abstract void deleteAll();
|
||||
|
||||
@Query("Select * FROM states ORDER BY state ASC")
|
||||
public abstract LiveData<List<States>> getStatesList();
|
||||
|
||||
@Transaction
|
||||
public void updateAll(List<States> states) {
|
||||
deleteAll();
|
||||
bulkInsert(states);
|
||||
}
|
||||
}
|
40
app/src/main/java/com/josh/trackcovid19v2/data/database/StatesDatabase.java
Executable file
40
app/src/main/java/com/josh/trackcovid19v2/data/database/StatesDatabase.java
Executable file
@@ -0,0 +1,40 @@
|
||||
package com.josh.trackcovid19v2.data.database;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.States;
|
||||
|
||||
//@Database(entities = { YourEntity.class }, version = 1, exportSchema = false)
|
||||
@Database(entities = {States.class}, version = 1, exportSchema = false)
|
||||
public abstract class StatesDatabase extends RoomDatabase {
|
||||
|
||||
//public abstract class StatesDatabase {
|
||||
|
||||
private static final String LOG_TAG = StatesDatabase.class.getSimpleName();
|
||||
private static final String DATABASE_NAME = "states";
|
||||
|
||||
// For Singleton instantiation
|
||||
private static final Object LOCK = new Object();
|
||||
private static StatesDatabase mInstance;
|
||||
|
||||
public static StatesDatabase getInstance(Context context) {
|
||||
Log.d(LOG_TAG, "Getting " + DATABASE_NAME + " database");
|
||||
|
||||
if (mInstance == null) {
|
||||
synchronized (LOCK) {
|
||||
mInstance = Room.databaseBuilder(context, StatesDatabase.class, DATABASE_NAME).build();
|
||||
Log.d(LOG_TAG, DATABASE_NAME + " database has been created.");
|
||||
}
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
// The associated DAOs for the database
|
||||
public abstract StateDao stateDao();
|
||||
|
||||
}
|
30
app/src/main/java/com/josh/trackcovid19v2/data/database/WorldDao.java
Executable file
30
app/src/main/java/com/josh/trackcovid19v2/data/database/WorldDao.java
Executable file
@@ -0,0 +1,30 @@
|
||||
package com.josh.trackcovid19v2.data.database;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Transaction;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.World;
|
||||
|
||||
|
||||
@Dao
|
||||
public abstract class WorldDao {
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
abstract void bulkInsert(World all);
|
||||
|
||||
@Query("DELETE FROM world")
|
||||
abstract void deleteAll();
|
||||
|
||||
@Query("Select * FROM world")
|
||||
public abstract LiveData<World> getWorld();
|
||||
|
||||
@Transaction
|
||||
public void updateAll(World world) {
|
||||
deleteAll();
|
||||
bulkInsert(world);
|
||||
}
|
||||
}
|
39
app/src/main/java/com/josh/trackcovid19v2/data/database/WorldDatabase.java
Executable file
39
app/src/main/java/com/josh/trackcovid19v2/data/database/WorldDatabase.java
Executable file
@@ -0,0 +1,39 @@
|
||||
package com.josh.trackcovid19v2.data.database;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.World;
|
||||
|
||||
//@Database(entities = { YourEntity.class }, version = 1, exportSchema = false)
|
||||
@Database(entities = {World.class}, version = 1, exportSchema = false)
|
||||
public abstract class WorldDatabase extends RoomDatabase {
|
||||
|
||||
|
||||
private static final String LOG_TAG = WorldDatabase.class.getSimpleName();
|
||||
private static final String DATABASE_NAME = "all";
|
||||
|
||||
// For Singleton instantiation
|
||||
private static final Object LOCK = new Object();
|
||||
private static WorldDatabase mInstance;
|
||||
|
||||
public static WorldDatabase getInstance(Context context) {
|
||||
Log.d(LOG_TAG, "Getting " + DATABASE_NAME + " database");
|
||||
|
||||
if (mInstance == null) {
|
||||
synchronized (LOCK) {
|
||||
mInstance = Room.databaseBuilder(context, WorldDatabase.class, DATABASE_NAME).build();
|
||||
Log.d(LOG_TAG, DATABASE_NAME + " database has been created.");
|
||||
}
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
// The associated DAOs for the database
|
||||
public abstract WorldDao worldDao();
|
||||
|
||||
}
|
32
app/src/main/java/com/josh/trackcovid19v2/data/database/YesCountriesDao.java
Executable file
32
app/src/main/java/com/josh/trackcovid19v2/data/database/YesCountriesDao.java
Executable file
@@ -0,0 +1,32 @@
|
||||
package com.josh.trackcovid19v2.data.database;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Transaction;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesCountries;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Dao
|
||||
public abstract class YesCountriesDao {
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
abstract void bulkInsert(List<YesCountries> yescountries);
|
||||
|
||||
@Query("DELETE FROM yescountries")
|
||||
abstract void deleteAll();
|
||||
|
||||
@Query("Select * FROM yescountries ORDER BY country ASC")
|
||||
public abstract LiveData<List<YesCountries>> getYesCountriesList();
|
||||
|
||||
@Transaction
|
||||
public void updateAll(List<YesCountries> yescountries) {
|
||||
deleteAll();
|
||||
bulkInsert(yescountries);
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package com.josh.trackcovid19v2.data.database;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesCountries;
|
||||
|
||||
//@Database(entities = { YourEntity.class }, version = 1, exportSchema = false)
|
||||
@Database(entities = {YesCountries.class}, version = 1, exportSchema = false)
|
||||
public abstract class YesCountriesDatabase extends RoomDatabase {
|
||||
|
||||
private static final String LOG_TAG = YesCountriesDatabase.class.getSimpleName();
|
||||
private static final String DATABASE_NAME = "yescountries";
|
||||
|
||||
// For Singleton instantiation
|
||||
private static final Object LOCK = new Object();
|
||||
private static YesCountriesDatabase mInstance;
|
||||
|
||||
public static YesCountriesDatabase getInstance(Context context) {
|
||||
Log.d(LOG_TAG, "Getting " + DATABASE_NAME + " database");
|
||||
|
||||
if (mInstance == null) {
|
||||
synchronized (LOCK) {
|
||||
mInstance = Room.databaseBuilder(context, YesCountriesDatabase.class, DATABASE_NAME).build();
|
||||
Log.d(LOG_TAG, DATABASE_NAME + " database has been created.");
|
||||
}
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
// The associated DAOs for the database
|
||||
public abstract YesCountriesDao yescountriesDao();
|
||||
|
||||
}
|
31
app/src/main/java/com/josh/trackcovid19v2/data/database/YesStateDao.java
Executable file
31
app/src/main/java/com/josh/trackcovid19v2/data/database/YesStateDao.java
Executable file
@@ -0,0 +1,31 @@
|
||||
package com.josh.trackcovid19v2.data.database;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Transaction;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesStates;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Dao
|
||||
public abstract class YesStateDao {
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
abstract void bulkInsert(List<YesStates> yesstates);
|
||||
|
||||
@Query("DELETE FROM yesstates")
|
||||
abstract void deleteAll();
|
||||
|
||||
@Query("Select * FROM yesstates ORDER BY state ASC")
|
||||
public abstract LiveData<List<YesStates>> getYesStatesList();
|
||||
|
||||
@Transaction
|
||||
public void updateAll(List<YesStates> yesstates) {
|
||||
deleteAll();
|
||||
bulkInsert(yesstates);
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
package com.josh.trackcovid19v2.data.database;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.States;
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesStates;
|
||||
|
||||
//@Database(entities = { YourEntity.class }, version = 1, exportSchema = false)
|
||||
@Database(entities = {YesStates.class}, version = 1, exportSchema = false)
|
||||
public abstract class YesStatesDatabase extends RoomDatabase {
|
||||
|
||||
//public abstract class StatesDatabase {
|
||||
|
||||
private static final String LOG_TAG = YesStatesDatabase.class.getSimpleName();
|
||||
private static final String DATABASE_NAME = "yesstates";
|
||||
|
||||
// For Singleton instantiation
|
||||
private static final Object LOCK = new Object();
|
||||
private static YesStatesDatabase mInstance;
|
||||
|
||||
public static YesStatesDatabase getInstance(Context context) {
|
||||
Log.d(LOG_TAG, "Getting " + DATABASE_NAME + " database");
|
||||
|
||||
if (mInstance == null) {
|
||||
synchronized (LOCK) {
|
||||
mInstance = Room.databaseBuilder(context, YesStatesDatabase.class, DATABASE_NAME).build();
|
||||
Log.d(LOG_TAG, DATABASE_NAME + " database has been created.");
|
||||
}
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
// The associated DAOs for the database
|
||||
public abstract YesStateDao yesstateDao();
|
||||
|
||||
}
|
30
app/src/main/java/com/josh/trackcovid19v2/data/database/YesWorldDao.java
Executable file
30
app/src/main/java/com/josh/trackcovid19v2/data/database/YesWorldDao.java
Executable file
@@ -0,0 +1,30 @@
|
||||
package com.josh.trackcovid19v2.data.database;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.room.Dao;
|
||||
import androidx.room.Insert;
|
||||
import androidx.room.OnConflictStrategy;
|
||||
import androidx.room.Query;
|
||||
import androidx.room.Transaction;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesWorld;
|
||||
|
||||
|
||||
@Dao
|
||||
public abstract class YesWorldDao {
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
abstract void bulkInsert(YesWorld all);
|
||||
|
||||
@Query("DELETE FROM yesworld")
|
||||
abstract void deleteAll();
|
||||
|
||||
@Query("Select * FROM yesworld")
|
||||
public abstract LiveData<YesWorld> getYesWorld();
|
||||
|
||||
@Transaction
|
||||
public void updateAll(YesWorld yesworld) {
|
||||
deleteAll();
|
||||
bulkInsert(yesworld);
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package com.josh.trackcovid19v2.data.database;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.room.Database;
|
||||
import androidx.room.Room;
|
||||
import androidx.room.RoomDatabase;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesWorld;
|
||||
|
||||
//@Database(entities = { YourEntity.class }, version = 1, exportSchema = false)
|
||||
@Database(entities = {YesWorld.class}, version = 1, exportSchema = false)
|
||||
public abstract class YesWorldDatabase extends RoomDatabase {
|
||||
|
||||
|
||||
private static final String LOG_TAG = YesWorldDatabase.class.getSimpleName();
|
||||
private static final String DATABASE_NAME = "yesall";
|
||||
|
||||
// For Singleton instantiation
|
||||
private static final Object LOCK = new Object();
|
||||
private static YesWorldDatabase mInstance;
|
||||
|
||||
public static YesWorldDatabase getInstance(Context context) {
|
||||
Log.d(LOG_TAG, "Getting " + DATABASE_NAME + " database");
|
||||
|
||||
if (mInstance == null) {
|
||||
synchronized (LOCK) {
|
||||
mInstance = Room.databaseBuilder(context, YesWorldDatabase.class, DATABASE_NAME).build();
|
||||
Log.d(LOG_TAG, DATABASE_NAME + " database has been created.");
|
||||
}
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
// The associated DAOs for the database
|
||||
public abstract YesWorldDao yesworldDao();
|
||||
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package com.josh.trackcovid19v2.data.database.entity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
/**
|
||||
* Created by evrencoskun on 1.12.2017.
|
||||
*/
|
||||
@Entity(tableName = "countries")
|
||||
public class Countries {
|
||||
@PrimaryKey
|
||||
@NonNull
|
||||
public String country;
|
||||
public int cases;
|
||||
public int active;
|
||||
public int todayCases;
|
||||
public int deaths;
|
||||
public int todayDeaths;
|
||||
public int recovered;
|
||||
public int tests;
|
||||
public int testsPerMillion;
|
||||
public String flag;
|
||||
public int critical;
|
||||
public long updated;
|
||||
//@TypeConverters(CountryInfo.class)
|
||||
//public List<CountryInfo> countryinfo;
|
||||
}
|
||||
|
22
app/src/main/java/com/josh/trackcovid19v2/data/database/entity/States.java
Executable file
22
app/src/main/java/com/josh/trackcovid19v2/data/database/entity/States.java
Executable file
@@ -0,0 +1,22 @@
|
||||
package com.josh.trackcovid19v2.data.database.entity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
/**
|
||||
* Created by evrencoskun on 1.12.2017.
|
||||
*/
|
||||
@Entity(tableName = "states")
|
||||
public class States {
|
||||
@PrimaryKey
|
||||
@NonNull
|
||||
public String state;
|
||||
public int cases;
|
||||
public int todayCases;
|
||||
public int deaths;
|
||||
public int todayDeaths;
|
||||
public int active;
|
||||
public int tests;
|
||||
public int testsPerMillion;
|
||||
}
|
21
app/src/main/java/com/josh/trackcovid19v2/data/database/entity/World.java
Executable file
21
app/src/main/java/com/josh/trackcovid19v2/data/database/entity/World.java
Executable file
@@ -0,0 +1,21 @@
|
||||
package com.josh.trackcovid19v2.data.database.entity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
/**
|
||||
* Created by evrencoskun on 1.12.2017.
|
||||
*/
|
||||
@Entity(tableName = "world")
|
||||
public class World {
|
||||
@PrimaryKey
|
||||
@NonNull
|
||||
public int cases;
|
||||
public int deaths;
|
||||
public int recovered;
|
||||
public long updated;
|
||||
public int active;
|
||||
public int affectedCountries;
|
||||
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.josh.trackcovid19v2.data.database.entity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
/**
|
||||
* Created by evrencoskun on 1.12.2017.
|
||||
*/
|
||||
@Entity(tableName = "yescountries")
|
||||
public class YesCountries {
|
||||
@PrimaryKey
|
||||
@NonNull
|
||||
public String country;
|
||||
public int cases;
|
||||
public int active;
|
||||
public int todayCases;
|
||||
public int deaths;
|
||||
public int todayDeaths;
|
||||
public int recovered;
|
||||
public int tests;
|
||||
public int testsPerMillion;
|
||||
public String flag;
|
||||
public int critical;
|
||||
public long updated;
|
||||
|
||||
//@TypeConverters(CountryInfo.class)
|
||||
//public List<CountryInfo> countryinfo;
|
||||
}
|
||||
|
@@ -0,0 +1,22 @@
|
||||
package com.josh.trackcovid19v2.data.database.entity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
/**
|
||||
* Created by evrencoskun on 1.12.2017.
|
||||
*/
|
||||
@Entity(tableName = "yesstates")
|
||||
public class YesStates {
|
||||
@PrimaryKey
|
||||
@NonNull
|
||||
public String state;
|
||||
public int cases;
|
||||
public int todayCases;
|
||||
public int deaths;
|
||||
public int todayDeaths;
|
||||
public int active;
|
||||
public int tests;
|
||||
public int testsPerMillion;
|
||||
}
|
21
app/src/main/java/com/josh/trackcovid19v2/data/database/entity/YesWorld.java
Executable file
21
app/src/main/java/com/josh/trackcovid19v2/data/database/entity/YesWorld.java
Executable file
@@ -0,0 +1,21 @@
|
||||
package com.josh.trackcovid19v2.data.database.entity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.PrimaryKey;
|
||||
|
||||
/**
|
||||
* Created by evrencoskun on 1.12.2017.
|
||||
*/
|
||||
@Entity(tableName = "yesworld")
|
||||
public class YesWorld {
|
||||
@PrimaryKey
|
||||
@NonNull
|
||||
public int cases;
|
||||
public int deaths;
|
||||
public int recovered;
|
||||
public long updated;
|
||||
public int active;
|
||||
public int affectedCountries;
|
||||
|
||||
}
|
322
app/src/main/java/com/josh/trackcovid19v2/data/network/NetworkUtils.java
Executable file
322
app/src/main/java/com/josh/trackcovid19v2/data/network/NetworkUtils.java
Executable file
@@ -0,0 +1,322 @@
|
||||
package com.josh.trackcovid19v2.data.network;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.Countries;
|
||||
import com.josh.trackcovid19v2.data.database.entity.States;
|
||||
import com.josh.trackcovid19v2.data.database.entity.World;
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesCountries;
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesStates;
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesWorld;
|
||||
import com.josh.trackcovid19v2.data.network.pojo.CountriesPojo;
|
||||
import com.josh.trackcovid19v2.data.network.pojo.StatesPojo;
|
||||
import com.josh.trackcovid19v2.data.network.pojo.YesCountriesPojo;
|
||||
import com.josh.trackcovid19v2.data.network.pojo.YesStatesPojo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
public class NetworkUtils {
|
||||
|
||||
private static final String LOG_TAG = NetworkUtils.class.getSimpleName();
|
||||
private static final String BASE_URL = "https://corona.lmao.ninja/";
|
||||
|
||||
private static Retrofit getRetrofit() {
|
||||
return new Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(GsonConverterFactory
|
||||
.create()).build();
|
||||
}
|
||||
|
||||
// For getting states data -- create similar for countries
|
||||
/*
|
||||
public static Call<List<States>> getDataFromService() {
|
||||
Log.d(LOG_TAG, "Getting data from the server");
|
||||
List<States> foo = null;
|
||||
|
||||
RestApi service = getRetrofit().create(RestApi.class);
|
||||
|
||||
Call<List<States>> call = service.getStates();
|
||||
|
||||
|
||||
return call;
|
||||
}
|
||||
*/
|
||||
public static Call<List<StatesPojo>> getStatesDataFromService() {
|
||||
Log.d(LOG_TAG, "Getting states data from the server");
|
||||
|
||||
RestApi service = getRetrofit().create(RestApi.class);
|
||||
|
||||
Call<List<StatesPojo>> call = service.getStates(0);
|
||||
|
||||
return call;
|
||||
}
|
||||
|
||||
public static Call<List<YesStatesPojo>> getYesStatesDataFromService() {
|
||||
Log.d(LOG_TAG, "Getting yes states data from the server");
|
||||
|
||||
RestApi service = getRetrofit().create(RestApi.class);
|
||||
|
||||
Call<List<YesStatesPojo>> call = service.getYesStates(1);
|
||||
|
||||
return call;
|
||||
}
|
||||
|
||||
// For getting countries data
|
||||
public static Call<List<CountriesPojo>> getCountriesDataFromService() {
|
||||
Log.d(LOG_TAG, "Getting countries data from the server");
|
||||
//List<Countries> foo = null;
|
||||
|
||||
RestApi service = getRetrofit().create(RestApi.class);
|
||||
|
||||
Call<List<CountriesPojo>> call = service.getCountries(0);
|
||||
|
||||
|
||||
return call;
|
||||
}
|
||||
|
||||
public static Call<List<YesCountriesPojo>> getYesCountriesDataFromService() {
|
||||
Log.d(LOG_TAG, "Getting yesterdays countries data from the server");
|
||||
//List<Countries> foo = null;
|
||||
|
||||
RestApi service = getRetrofit().create(RestApi.class);
|
||||
|
||||
Call<List<YesCountriesPojo>> call = service.getYesCountries(1);
|
||||
|
||||
|
||||
return call;
|
||||
}
|
||||
|
||||
public static List<Countries> convertToCountriesList(List<CountriesPojo> data) {
|
||||
List<Countries> countries = new ArrayList<>();
|
||||
Log.d(LOG_TAG, "Converting the response.");
|
||||
|
||||
try {
|
||||
|
||||
|
||||
for (CountriesPojo ddd : data) {
|
||||
Countries country_data = new Countries();
|
||||
country_data.country = ddd.getCountry();
|
||||
country_data.cases = Integer.parseInt(ddd.getCases());
|
||||
country_data.active = Integer.parseInt(ddd.getActive());
|
||||
country_data.deaths = Integer.parseInt(ddd.getDeaths());
|
||||
country_data.todayCases = Integer.parseInt(ddd.getTodayCases());
|
||||
country_data.todayDeaths = Integer.parseInt(ddd.getTodayDeaths());
|
||||
country_data.recovered = Integer.parseInt(ddd.getRecovered());
|
||||
//country_data.recovered = 0;
|
||||
country_data.tests = Integer.parseInt(ddd.getTests());
|
||||
country_data.testsPerMillion = Integer.parseInt(ddd.getTestsPerOneMillion());
|
||||
country_data.flag = ddd.getCountryInfoPojo().getFlag();
|
||||
country_data.critical = Integer.parseInt(ddd.getCritical());
|
||||
country_data.updated = Long.parseLong(ddd.getUpdated());
|
||||
|
||||
|
||||
// add
|
||||
countries.add(country_data);
|
||||
}
|
||||
|
||||
|
||||
Log.d(LOG_TAG, "Converting the response process has been success. ");
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.d(LOG_TAG, "Converting the response process has been failed. ", e);
|
||||
}
|
||||
|
||||
return countries;
|
||||
}
|
||||
|
||||
public static List<States> convertToStatesList(List<StatesPojo> data) {
|
||||
List<States> states = new ArrayList<>();
|
||||
Log.d(LOG_TAG, "Converting the response.");
|
||||
|
||||
try {
|
||||
|
||||
|
||||
for (StatesPojo ddd : data) {
|
||||
States state_data = new States();
|
||||
state_data.state = ddd.getState();
|
||||
state_data.cases = Integer.parseInt(ddd.getCases());
|
||||
state_data.active = Integer.parseInt(ddd.getActive());
|
||||
state_data.deaths = Integer.parseInt(ddd.getDeaths());
|
||||
state_data.todayCases = Integer.parseInt(ddd.getTodayCases());
|
||||
state_data.todayDeaths = Integer.parseInt(ddd.getTodayDeaths());
|
||||
state_data.tests = Integer.parseInt(ddd.getTests());
|
||||
state_data.testsPerMillion = Integer.parseInt(ddd.getTestsPerOneMillion());
|
||||
|
||||
|
||||
|
||||
// add
|
||||
states.add(state_data);
|
||||
}
|
||||
|
||||
|
||||
Log.d(LOG_TAG, "Converting the response process has been success. ");
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.d(LOG_TAG, "Converting the response process has been failed. ", e);
|
||||
}
|
||||
|
||||
return states;
|
||||
}
|
||||
|
||||
public static List<YesStates> convertToYesStatesList(List<YesStatesPojo> data) {
|
||||
List<YesStates> yesstates = new ArrayList<>();
|
||||
Log.d(LOG_TAG, "Converting the response.");
|
||||
|
||||
try {
|
||||
|
||||
|
||||
for (YesStatesPojo ddd : data) {
|
||||
YesStates state_data = new YesStates();
|
||||
state_data.state = ddd.getState();
|
||||
state_data.cases = Integer.parseInt(ddd.getCases());
|
||||
state_data.active = Integer.parseInt(ddd.getActive());
|
||||
state_data.deaths = Integer.parseInt(ddd.getDeaths());
|
||||
state_data.todayCases = Integer.parseInt(ddd.getTodayCases());
|
||||
state_data.todayDeaths = Integer.parseInt(ddd.getTodayDeaths());
|
||||
state_data.tests = Integer.parseInt(ddd.getTests());
|
||||
state_data.testsPerMillion = Integer.parseInt(ddd.getTestsPerOneMillion());
|
||||
|
||||
|
||||
|
||||
// add
|
||||
yesstates.add(state_data);
|
||||
}
|
||||
|
||||
|
||||
Log.d(LOG_TAG, "Converting the response process has been success. ");
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.d(LOG_TAG, "Converting the response process has been failed. ", e);
|
||||
}
|
||||
|
||||
return yesstates;
|
||||
}
|
||||
|
||||
///
|
||||
public static List<States> convertToStatesList1(List<States> data) {
|
||||
List<States> states = new ArrayList<>();
|
||||
Log.d(LOG_TAG, "Converting the response.");
|
||||
|
||||
try {
|
||||
|
||||
/*
|
||||
for (States ddd : data) {
|
||||
States state_data = new States();
|
||||
state_data.state = ddd.state;
|
||||
state_data.cases = ddd.cases;
|
||||
state_data.todayCases = ddd.todayCases;
|
||||
state_data.deaths = ddd.deaths;
|
||||
state_data.todayDeaths = ddd.todayDeaths;
|
||||
state_data.active = ddd.active;
|
||||
|
||||
// add
|
||||
states.add(state_data);
|
||||
}
|
||||
*/
|
||||
|
||||
Log.d(LOG_TAG, "Converting the response process has been success. ");
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.d(LOG_TAG, "Converting the response process has been failed. ", e);
|
||||
}
|
||||
|
||||
//return states;
|
||||
return data;
|
||||
}
|
||||
|
||||
//private static Date getDate(String stringData) throws ParseException {
|
||||
// DateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.getDefault());
|
||||
// return format.parse(stringData);
|
||||
//}
|
||||
|
||||
|
||||
public static Call<World> getWorldDataFromService() {
|
||||
Log.d(LOG_TAG, "Getting data from the server");
|
||||
|
||||
RestApi service = getRetrofit().create(RestApi.class);
|
||||
|
||||
Call<World> call = service.getWorld();
|
||||
|
||||
return call;
|
||||
}
|
||||
public static Call<YesWorld> getYesWorldDataFromService() {
|
||||
Log.d(LOG_TAG, "Getting yesterdays data from the server");
|
||||
|
||||
RestApi service = getRetrofit().create(RestApi.class);
|
||||
|
||||
Call<YesWorld> call = service.getYesWorld();
|
||||
|
||||
return call;
|
||||
}
|
||||
|
||||
public static List<YesCountries> convertToYesCountriesList(List<YesCountriesPojo> data) {
|
||||
List<YesCountries> yescountries = new ArrayList<>();
|
||||
Log.d(LOG_TAG, "Converting the response.");
|
||||
|
||||
try {
|
||||
|
||||
|
||||
for (YesCountriesPojo ddd : data) {
|
||||
YesCountries country_data = new YesCountries();
|
||||
country_data.country = ddd.getCountry();
|
||||
country_data.cases = Integer.parseInt(ddd.getCases());
|
||||
country_data.active = Integer.parseInt(ddd.getActive());
|
||||
country_data.deaths = Integer.parseInt(ddd.getDeaths());
|
||||
country_data.todayCases = Integer.parseInt(ddd.getTodayCases());
|
||||
country_data.todayDeaths = Integer.parseInt(ddd.getTodayDeaths());
|
||||
country_data.recovered = Integer.parseInt(ddd.getRecovered());
|
||||
//country_data.recovered = 0;
|
||||
country_data.tests = Integer.parseInt(ddd.getTests());
|
||||
country_data.testsPerMillion = Integer.parseInt(ddd.getTestsPerOneMillion());
|
||||
country_data.flag = ddd.getCountryInfoPojo().getFlag();
|
||||
country_data.critical = Integer.parseInt(ddd.getCritical());
|
||||
country_data.updated = Long.parseLong(ddd.getUpdated());
|
||||
// add
|
||||
yescountries.add(country_data);
|
||||
}
|
||||
|
||||
|
||||
Log.d(LOG_TAG, "Converting the response process has been success. ");
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.d(LOG_TAG, "Converting the response process has been failed. ", e);
|
||||
}
|
||||
|
||||
return yescountries;
|
||||
}
|
||||
|
||||
/*
|
||||
public static List<States> convertToStatesList(List<States> data) {
|
||||
List<States> states = new ArrayList<>();
|
||||
Log.d(LOG_TAG, "Converting the response.");
|
||||
|
||||
try {
|
||||
|
||||
|
||||
for (States ddd : data) {
|
||||
States state_data = new States();
|
||||
state_data.state = ddd.state;
|
||||
state_data.cases = ddd.cases;
|
||||
state_data.todayCases = ddd.todayCases;
|
||||
state_data.deaths = ddd.deaths;
|
||||
state_data.todayDeaths = ddd.todayDeaths;
|
||||
state_data.active = ddd.active;
|
||||
|
||||
// add
|
||||
states.add(state_data);
|
||||
}
|
||||
|
||||
//Log.d(LOG_TAG, "Converting the response process has been success. ");
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.d(LOG_TAG, "Converting the response process has been failed. ", e);
|
||||
}
|
||||
|
||||
//return states;
|
||||
return data;
|
||||
}
|
||||
*/
|
||||
}
|
48
app/src/main/java/com/josh/trackcovid19v2/data/network/RestApi.java
Executable file
48
app/src/main/java/com/josh/trackcovid19v2/data/network/RestApi.java
Executable file
@@ -0,0 +1,48 @@
|
||||
package com.josh.trackcovid19v2.data.network;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.States;
|
||||
import com.josh.trackcovid19v2.data.database.entity.World;
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesWorld;
|
||||
import com.josh.trackcovid19v2.data.network.pojo.CountriesPojo;
|
||||
import com.josh.trackcovid19v2.data.network.pojo.StatesPojo;
|
||||
import com.josh.trackcovid19v2.data.network.pojo.YesCountriesPojo;
|
||||
import com.josh.trackcovid19v2.data.network.pojo.YesStatesPojo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Headers;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface RestApi {
|
||||
|
||||
@Headers("Content-Type: application/json")
|
||||
@GET("v2/states")
|
||||
Call<List<States>> getStatess();
|
||||
|
||||
@GET("v2/states")
|
||||
Call<List<StatesPojo>> getStates(@Query("yesterday") int y);
|
||||
|
||||
@GET("v2/states")
|
||||
Call<List<YesStatesPojo>> getYesStates(@Query("yesterday") int y);
|
||||
|
||||
@GET("/v2/countries")
|
||||
Call<List<CountriesPojo>> getCountries(@Query("yesterday") int y);
|
||||
|
||||
@GET("/v2/countries")
|
||||
Call<List<YesCountriesPojo>> getYesCountries(@Query("yesterday") int y);
|
||||
|
||||
@GET("v2/all")
|
||||
Call<World> getWorld();
|
||||
|
||||
@GET("v2/all?yesterday=true")
|
||||
Call<YesWorld> getYesWorld();
|
||||
|
||||
//countries/USA
|
||||
//yesterday/USA
|
||||
|
||||
//
|
||||
|
||||
//Observable<List<ServiceResponse>> getStates();
|
||||
}
|
24
app/src/main/java/com/josh/trackcovid19v2/data/network/StatesWrapper.java
Executable file
24
app/src/main/java/com/josh/trackcovid19v2/data/network/StatesWrapper.java
Executable file
@@ -0,0 +1,24 @@
|
||||
package com.josh.trackcovid19v2.data.network;
|
||||
|
||||
import com.josh.trackcovid19v2.data.database.entity.States;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class StatesWrapper {
|
||||
|
||||
@SerializedName("states")
|
||||
@Expose
|
||||
private List<States> states = null;
|
||||
|
||||
public List<States> getStates() {
|
||||
return states;
|
||||
}
|
||||
|
||||
public void setStates(List<States> states) {
|
||||
this.states = states;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,308 @@
|
||||
package com.josh.trackcovid19v2.data.network;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.josh.trackcovid19v2.AppExecutors;
|
||||
import com.josh.trackcovid19v2.data.database.entity.Countries;
|
||||
import com.josh.trackcovid19v2.data.database.entity.States;
|
||||
import com.josh.trackcovid19v2.data.database.entity.World;
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesCountries;
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesStates;
|
||||
import com.josh.trackcovid19v2.data.database.entity.YesWorld;
|
||||
import com.josh.trackcovid19v2.data.network.pojo.CountriesPojo;
|
||||
import com.josh.trackcovid19v2.data.network.pojo.StatesPojo;
|
||||
import com.josh.trackcovid19v2.data.network.pojo.YesCountriesPojo;
|
||||
import com.josh.trackcovid19v2.data.network.pojo.YesStatesPojo;
|
||||
import com.josh.trackcovid19v2.model.ServiceRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class UserNetworkDataSource {
|
||||
|
||||
private static final String LOG_TAG = UserNetworkDataSource.class.getSimpleName();
|
||||
|
||||
// For Singleton instantiation
|
||||
private static UserNetworkDataSource sInstance;
|
||||
private static final Object LOCK = new Object();
|
||||
|
||||
private AppExecutors mAppExecutors;
|
||||
private final MutableLiveData<List<States>> mDownloadedStatesData;
|
||||
private final MutableLiveData<List<YesStates>> mDownloadedYesStatesData;
|
||||
private final MutableLiveData<List<Countries>> mDownloadedCountriesData;
|
||||
private final MutableLiveData<List<YesCountries>> mDownloadedYesCountriesData;
|
||||
private final MutableLiveData<World> mDownloadedWorldData;
|
||||
private final MutableLiveData<YesWorld> mDownloadedYesWorldData;
|
||||
|
||||
public UserNetworkDataSource(AppExecutors mAppExecutors) {
|
||||
this.mAppExecutors = mAppExecutors;
|
||||
this.mDownloadedStatesData = new MutableLiveData<>();
|
||||
this.mDownloadedYesStatesData = new MutableLiveData<>();
|
||||
this.mDownloadedCountriesData = new MutableLiveData<>();
|
||||
this.mDownloadedYesCountriesData = new MutableLiveData<>();
|
||||
this.mDownloadedWorldData = new MutableLiveData<>();
|
||||
this.mDownloadedYesWorldData = new MutableLiveData<>();
|
||||
}
|
||||
|
||||
public static UserNetworkDataSource getInstance(AppExecutors executors) {
|
||||
Log.d(LOG_TAG, "Getting the network data source");
|
||||
if (sInstance == null) {
|
||||
synchronized (LOCK) {
|
||||
sInstance = new UserNetworkDataSource(executors);
|
||||
Log.d(LOG_TAG, "Made new network data source");
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
/*
|
||||
public void fetchData(ServiceRequest serviceRequest) {
|
||||
mAppExecutors.networkIO().execute(() -> {
|
||||
try {
|
||||
Call<List<States>> call = NetworkUtils.getDataFromService();
|
||||
call.enqueue(new Callback<List<States>>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<States>> call, Response<List<States>> response) {
|
||||
//Toast.makeText(MainActivity.this,response.body().toString(),Toast.LENGTH_SHORT).show();
|
||||
Log.e("Info", "got data");
|
||||
//ArrayList<States> foo = new ArrayList<States>();
|
||||
List<States> data = response.body();
|
||||
setStatesList(NetworkUtils.convertToStatesList(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<List<States>> call, Throwable t) {
|
||||
Log.d(LOG_TAG, "fofofofofofof");
|
||||
Log.d("Error",t.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception ex) {
|
||||
Log.e(LOG_TAG, "Getting data process has been failed.", ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
public void fetchStatesData(ServiceRequest serviceRequest) {
|
||||
mAppExecutors.networkIO().execute(() -> {
|
||||
try {
|
||||
Call<List<StatesPojo>> call = NetworkUtils.getStatesDataFromService();
|
||||
call.enqueue(new Callback<List<StatesPojo>>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<StatesPojo>> call, Response<List<StatesPojo>> response) {
|
||||
//Toast.makeText(MainActivity.this,response.body().toString(),Toast.LENGTH_SHORT).show();
|
||||
Log.e("Info", "got states data");
|
||||
//ArrayList<States> foo = new ArrayList<States>();
|
||||
List<StatesPojo> data = response.body();
|
||||
setStatesList(NetworkUtils.convertToStatesList(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<List<StatesPojo>> call, Throwable t) {
|
||||
Log.d(LOG_TAG, "states error");
|
||||
Log.d("Error",t.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception ex) {
|
||||
Log.e(LOG_TAG, "Getting states data process has been failed.", ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void fetchYesStatesData(ServiceRequest serviceRequest) {
|
||||
mAppExecutors.networkIO().execute(() -> {
|
||||
try {
|
||||
Call<List<YesStatesPojo>> call = NetworkUtils.getYesStatesDataFromService();
|
||||
call.enqueue(new Callback<List<YesStatesPojo>>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<YesStatesPojo>> call, Response<List<YesStatesPojo>> response) {
|
||||
//Toast.makeText(MainActivity.this,response.body().toString(),Toast.LENGTH_SHORT).show();
|
||||
Log.e("Info", "got yes states data");
|
||||
//ArrayList<States> foo = new ArrayList<States>();
|
||||
List<YesStatesPojo> data = response.body();
|
||||
setYesStatesList(NetworkUtils.convertToYesStatesList(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<List<YesStatesPojo>> call, Throwable t) {
|
||||
Log.d(LOG_TAG, "yes states error");
|
||||
Log.d("Error",t.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception ex) {
|
||||
Log.e(LOG_TAG, "Getting states data process has been failed.", ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void fetchCountriesData(ServiceRequest serviceRequest) {
|
||||
mAppExecutors.networkIO().execute(() -> {
|
||||
try {
|
||||
Call<List<CountriesPojo>> call = NetworkUtils.getCountriesDataFromService();
|
||||
call.enqueue(new Callback<List<CountriesPojo>>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<CountriesPojo>> call, Response<List<CountriesPojo>> response) {
|
||||
//Toast.makeText(MainActivity.this,response.body().toString(),Toast.LENGTH_SHORT).show();
|
||||
Log.e("Info", "got countries data");
|
||||
//ArrayList<States> foo = new ArrayList<States>();
|
||||
List<CountriesPojo> data = response.body();
|
||||
setCountriesList(NetworkUtils.convertToCountriesList(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<List<CountriesPojo>> call, Throwable t) {
|
||||
Log.d(LOG_TAG, "countries error");
|
||||
Log.d("Error",t.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception ex) {
|
||||
Log.e(LOG_TAG, "Getting data process has been failed.", ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void fetchYesCountriesData(ServiceRequest serviceRequest) {
|
||||
mAppExecutors.networkIO().execute(() -> {
|
||||
try {
|
||||
Call<List<YesCountriesPojo>> call = NetworkUtils.getYesCountriesDataFromService();
|
||||
call.enqueue(new Callback<List<YesCountriesPojo>>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<YesCountriesPojo>> call, Response<List<YesCountriesPojo>> response) {
|
||||
//Toast.makeText(MainActivity.this,response.body().toString(),Toast.LENGTH_SHORT).show();
|
||||
Log.e("Info", "got yesterdays countries data");
|
||||
//ArrayList<States> foo = new ArrayList<States>();
|
||||
List<YesCountriesPojo> data = response.body();
|
||||
setYesCountriesList(NetworkUtils.convertToYesCountriesList(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<List<YesCountriesPojo>> call, Throwable t) {
|
||||
Log.d(LOG_TAG, "yes countries error");
|
||||
Log.d("Error",t.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception ex) {
|
||||
Log.e(LOG_TAG, "Getting data process has been failed.", ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void fetchWorldData(ServiceRequest serviceRequest) {
|
||||
mAppExecutors.networkIO().execute(() -> {
|
||||
try {
|
||||
Call<World> call = NetworkUtils.getWorldDataFromService();
|
||||
call.enqueue(new Callback<World>() {
|
||||
@Override
|
||||
public void onResponse(Call<World> call, Response<World> response) {
|
||||
//Toast.makeText(MainActivity.this,response.body().toString(),Toast.LENGTH_SHORT).show();
|
||||
Log.e("Info", "got world data");
|
||||
//ArrayList<States> foo = new ArrayList<States>();
|
||||
World data = response.body();
|
||||
//setWorld(NetworkUtils.convertToStatesList(data));
|
||||
setWorld(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<World> call, Throwable t) {
|
||||
Log.d(LOG_TAG, "fofofofofofof");
|
||||
Log.d("Error", t.getMessage());
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
Log.e(LOG_TAG, "Getting data process has been failed.", ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void fetchYesWorldData(ServiceRequest serviceRequest) {
|
||||
mAppExecutors.networkIO().execute(() -> {
|
||||
try {
|
||||
Call<YesWorld> call1 = NetworkUtils.getYesWorldDataFromService();
|
||||
call1.enqueue(new Callback<YesWorld>() {
|
||||
@Override
|
||||
public void onResponse(Call<YesWorld> call, Response<YesWorld> response) {
|
||||
//Toast.makeText(MainActivity.this,response.body().toString(),Toast.LENGTH_SHORT).show();
|
||||
Log.e("Info", "got yesterday's world data");
|
||||
//ArrayList<States> foo = new ArrayList<States>();
|
||||
YesWorld data = response.body();
|
||||
//setWorld(NetworkUtils.convertToStatesList(data));
|
||||
setYesWorld(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<YesWorld> call, Throwable t) {
|
||||
Log.d(LOG_TAG, "fofofofofofof");
|
||||
Log.d("Error", t.getMessage());
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
Log.e(LOG_TAG, "Getting data process has been failed.", ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// private void setStatesList(List<States> statesList){
|
||||
// mDownloadedData.postValue(statesList);
|
||||
// }
|
||||
private void setWorld(World world) {
|
||||
mDownloadedWorldData.postValue(world);
|
||||
}
|
||||
|
||||
public LiveData<World> getWorld(){
|
||||
return mDownloadedWorldData;
|
||||
}
|
||||
|
||||
private void setYesWorld(YesWorld yesworld) {
|
||||
mDownloadedYesWorldData.postValue(yesworld);
|
||||
}
|
||||
|
||||
public LiveData<YesWorld> getYesWorld(){
|
||||
return mDownloadedYesWorldData;
|
||||
}
|
||||
|
||||
private void setStatesList(List<States> statesList){
|
||||
mDownloadedStatesData.postValue(statesList);
|
||||
}
|
||||
public LiveData<List<States>> getStatesList(){
|
||||
return mDownloadedStatesData;
|
||||
}
|
||||
|
||||
private void setYesStatesList(List<YesStates> yesstatesList){
|
||||
mDownloadedYesStatesData.postValue(yesstatesList);
|
||||
}
|
||||
public LiveData<List<YesStates>> getYesStatesList(){
|
||||
return mDownloadedYesStatesData;
|
||||
}
|
||||
|
||||
private void setCountriesList(List<Countries> countriesList){
|
||||
mDownloadedCountriesData.postValue(countriesList);
|
||||
}
|
||||
|
||||
public LiveData<List<Countries>> getCountriesList(){
|
||||
return mDownloadedCountriesData;
|
||||
}
|
||||
|
||||
private void setYesCountriesList(List<YesCountries> yescountriesList){
|
||||
mDownloadedYesCountriesData.postValue(yescountriesList);
|
||||
}
|
||||
public LiveData<List<YesCountries>> getYesCountriesList(){
|
||||
return mDownloadedYesCountriesData;
|
||||
}
|
||||
|
||||
|
||||
}
|
166
app/src/main/java/com/josh/trackcovid19v2/data/network/pojo/CountriesPojo.java
Executable file
166
app/src/main/java/com/josh/trackcovid19v2/data/network/pojo/CountriesPojo.java
Executable file
@@ -0,0 +1,166 @@
|
||||
package com.josh.trackcovid19v2.data.network.pojo;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class CountriesPojo {
|
||||
|
||||
@SerializedName("country")
|
||||
@Expose
|
||||
private String country;
|
||||
@SerializedName("updated")
|
||||
@Expose
|
||||
private String updated;
|
||||
@SerializedName("cases")
|
||||
@Expose
|
||||
private String cases;
|
||||
@SerializedName("todayCases")
|
||||
@Expose
|
||||
private String todayCases;
|
||||
@SerializedName("deaths")
|
||||
@Expose
|
||||
private String deaths;
|
||||
@SerializedName("todayDeaths")
|
||||
@Expose
|
||||
private String todayDeaths;
|
||||
@SerializedName("recovered")
|
||||
@Expose
|
||||
private String recovered;
|
||||
@SerializedName("active")
|
||||
@Expose
|
||||
private String active;
|
||||
@SerializedName("critical")
|
||||
@Expose
|
||||
private String critical;
|
||||
@SerializedName("casesPerOneMillion")
|
||||
@Expose
|
||||
private String casesPerOneMillion;
|
||||
@SerializedName("deathsPerOneMillion")
|
||||
@Expose
|
||||
private String deathsPerOneMillion;
|
||||
@SerializedName("tests")
|
||||
@Expose
|
||||
private String tests;
|
||||
@SerializedName("testsPerOneMillion")
|
||||
@Expose
|
||||
private String testsPerOneMillion;
|
||||
@SerializedName("countryInfo")
|
||||
@Expose
|
||||
private CountryInfoPojo countryInfoPojo = null;
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void setUpdated(String updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
|
||||
public String getCases() {
|
||||
return cases;
|
||||
}
|
||||
|
||||
public void setCases(String cases) {
|
||||
this.cases = cases;
|
||||
}
|
||||
|
||||
public String getTodayCases() {
|
||||
return todayCases;
|
||||
}
|
||||
|
||||
public void setTodayCases(String todayCases) {
|
||||
this.todayCases = todayCases;
|
||||
}
|
||||
|
||||
public String getDeaths() {
|
||||
return deaths;
|
||||
}
|
||||
|
||||
public void setDeaths(String deaths) {
|
||||
this.deaths = deaths;
|
||||
}
|
||||
|
||||
public String getTodayDeaths() {
|
||||
return todayDeaths;
|
||||
}
|
||||
|
||||
public void setTodayDeaths(String todayDeaths) {
|
||||
this.todayDeaths = todayDeaths;
|
||||
}
|
||||
|
||||
public String getRecovered() {
|
||||
return recovered;
|
||||
}
|
||||
|
||||
public void setRecovered(String recovered) {
|
||||
this.recovered = recovered;
|
||||
}
|
||||
|
||||
public String getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(String active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public String getCritical() {
|
||||
return critical;
|
||||
}
|
||||
|
||||
public void setCritical(String critical) {
|
||||
this.critical = critical;
|
||||
}
|
||||
|
||||
public String getCasesPerOneMillion() {
|
||||
return casesPerOneMillion;
|
||||
}
|
||||
|
||||
public void setCasesPerOneMillion(String casesPerOneMillion) {
|
||||
this.casesPerOneMillion = casesPerOneMillion;
|
||||
}
|
||||
|
||||
public String getDeathsPerOneMillion() {
|
||||
return deathsPerOneMillion;
|
||||
}
|
||||
|
||||
public void setDeathsPerOneMillion(String deathsPerOneMillion) {
|
||||
this.deathsPerOneMillion = deathsPerOneMillion;
|
||||
}
|
||||
|
||||
public String getTests() {
|
||||
return tests;
|
||||
}
|
||||
|
||||
public void setTests(String tests) {
|
||||
this.tests = tests;
|
||||
}
|
||||
|
||||
public String getTestsPerOneMillion() {
|
||||
return testsPerOneMillion;
|
||||
}
|
||||
|
||||
public void setTestsPerOneMillion(String testsPerOneMillion) {
|
||||
this.testsPerOneMillion = testsPerOneMillion;
|
||||
}
|
||||
|
||||
public CountryInfoPojo getCountryInfoPojo() {
|
||||
return countryInfoPojo;
|
||||
}
|
||||
|
||||
public void setCountryInfoPojo(CountryInfoPojo countryInfoPojo) {
|
||||
this.countryInfoPojo = countryInfoPojo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -0,0 +1,74 @@
|
||||
package com.josh.trackcovid19v2.data.network.pojo;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class CountryInfoPojo {
|
||||
|
||||
@SerializedName("_id")
|
||||
@Expose
|
||||
private String _id;
|
||||
@SerializedName("iso2")
|
||||
@Expose
|
||||
private String iso2;
|
||||
@SerializedName("iso3")
|
||||
@Expose
|
||||
private String iso3;
|
||||
@SerializedName("lat")
|
||||
@Expose
|
||||
private String lat;
|
||||
@SerializedName("llong")
|
||||
@Expose
|
||||
private String llong;
|
||||
@SerializedName("flag")
|
||||
@Expose
|
||||
private String flag;
|
||||
|
||||
public String get_id() {
|
||||
return _id;
|
||||
}
|
||||
|
||||
public void set_id(String _id) {
|
||||
this._id = _id;
|
||||
}
|
||||
|
||||
public String getIso2() {
|
||||
return iso2;
|
||||
}
|
||||
|
||||
public void setIso2(String iso2) {
|
||||
this.iso2 = iso2;
|
||||
}
|
||||
|
||||
public String getIso3() {
|
||||
return iso3;
|
||||
}
|
||||
|
||||
public void setIso3(String iso3) {
|
||||
this.iso3 = iso3;
|
||||
}
|
||||
|
||||
public String getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(String lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public String getLlong() {
|
||||
return llong;
|
||||
}
|
||||
|
||||
public void setLlong(String llong) {
|
||||
this.llong = llong;
|
||||
}
|
||||
|
||||
public String getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(String flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
}
|
104
app/src/main/java/com/josh/trackcovid19v2/data/network/pojo/StatesPojo.java
Executable file
104
app/src/main/java/com/josh/trackcovid19v2/data/network/pojo/StatesPojo.java
Executable file
@@ -0,0 +1,104 @@
|
||||
package com.josh.trackcovid19v2.data.network.pojo;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class StatesPojo {
|
||||
@SerializedName("state")
|
||||
@Expose
|
||||
public String state;
|
||||
@SerializedName("cases")
|
||||
@Expose
|
||||
public String cases;
|
||||
@SerializedName("todayCases")
|
||||
@Expose
|
||||
public String todayCases;
|
||||
@SerializedName("deaths")
|
||||
@Expose
|
||||
public String deaths;
|
||||
@SerializedName("todayDeaths")
|
||||
@Expose
|
||||
public String todayDeaths;
|
||||
@SerializedName("active")
|
||||
@Expose
|
||||
public String active;
|
||||
@SerializedName("tests")
|
||||
private String tests;
|
||||
@SerializedName("testsPerOneMillion")
|
||||
@Expose
|
||||
private String testsPerOneMillion;
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getCases() {
|
||||
return cases;
|
||||
}
|
||||
|
||||
public void setCases(String cases) {
|
||||
this.cases = cases;
|
||||
}
|
||||
|
||||
public String getTodayCases() {
|
||||
return todayCases;
|
||||
}
|
||||
|
||||
public void setTodayCases(String todayCases) {
|
||||
this.todayCases = todayCases;
|
||||
}
|
||||
|
||||
public String getDeaths() {
|
||||
return deaths;
|
||||
}
|
||||
|
||||
public void setDeaths(String deaths) {
|
||||
this.deaths = deaths;
|
||||
}
|
||||
|
||||
public String getTodayDeaths() {
|
||||
return todayDeaths;
|
||||
}
|
||||
|
||||
public void setTodayDeaths(String todayDeaths) {
|
||||
this.todayDeaths = todayDeaths;
|
||||
}
|
||||
|
||||
|
||||
public String getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(String active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
|
||||
public String getTests() {
|
||||
return tests;
|
||||
}
|
||||
|
||||
public void setTests(String tests) {
|
||||
this.tests = tests;
|
||||
}
|
||||
|
||||
public String getTestsPerOneMillion() {
|
||||
return testsPerOneMillion;
|
||||
}
|
||||
|
||||
public void setTestsPerOneMillion(String testsPerOneMillion) {
|
||||
this.testsPerOneMillion = testsPerOneMillion;
|
||||
}
|
||||
//@SerializedName("group")
|
||||
// @Expose
|
||||
//public Group group;
|
||||
//@SerializedName("address")
|
||||
//@Expose
|
||||
//public Address address;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,166 @@
|
||||
package com.josh.trackcovid19v2.data.network.pojo;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class YesCountriesPojo {
|
||||
|
||||
@SerializedName("country")
|
||||
@Expose
|
||||
private String country;
|
||||
@SerializedName("updated")
|
||||
@Expose
|
||||
private String updated;
|
||||
@SerializedName("cases")
|
||||
@Expose
|
||||
private String cases;
|
||||
@SerializedName("todayCases")
|
||||
@Expose
|
||||
private String todayCases;
|
||||
@SerializedName("deaths")
|
||||
@Expose
|
||||
private String deaths;
|
||||
@SerializedName("todayDeaths")
|
||||
@Expose
|
||||
private String todayDeaths;
|
||||
@SerializedName("recovered")
|
||||
@Expose
|
||||
private String recovered;
|
||||
@SerializedName("active")
|
||||
@Expose
|
||||
private String active;
|
||||
@SerializedName("critical")
|
||||
@Expose
|
||||
private String critical;
|
||||
@SerializedName("casesPerOneMillion")
|
||||
@Expose
|
||||
private String casesPerOneMillion;
|
||||
@SerializedName("deathsPerOneMillion")
|
||||
@Expose
|
||||
private String deathsPerOneMillion;
|
||||
@SerializedName("tests")
|
||||
@Expose
|
||||
private String tests;
|
||||
@SerializedName("testsPerOneMillion")
|
||||
@Expose
|
||||
private String testsPerOneMillion;
|
||||
@SerializedName("countryInfo")
|
||||
@Expose
|
||||
private CountryInfoPojo countryInfoPojo = null;
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void setUpdated(String updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
|
||||
public String getCases() {
|
||||
return cases;
|
||||
}
|
||||
|
||||
public void setCases(String cases) {
|
||||
this.cases = cases;
|
||||
}
|
||||
|
||||
public String getTodayCases() {
|
||||
return todayCases;
|
||||
}
|
||||
|
||||
public void setTodayCases(String todayCases) {
|
||||
this.todayCases = todayCases;
|
||||
}
|
||||
|
||||
public String getDeaths() {
|
||||
return deaths;
|
||||
}
|
||||
|
||||
public void setDeaths(String deaths) {
|
||||
this.deaths = deaths;
|
||||
}
|
||||
|
||||
public String getTodayDeaths() {
|
||||
return todayDeaths;
|
||||
}
|
||||
|
||||
public void setTodayDeaths(String todayDeaths) {
|
||||
this.todayDeaths = todayDeaths;
|
||||
}
|
||||
|
||||
public String getRecovered() {
|
||||
return recovered;
|
||||
}
|
||||
|
||||
public void setRecovered(String recovered) {
|
||||
this.recovered = recovered;
|
||||
}
|
||||
|
||||
public String getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(String active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public String getCritical() {
|
||||
return critical;
|
||||
}
|
||||
|
||||
public void setCritical(String critical) {
|
||||
this.critical = critical;
|
||||
}
|
||||
|
||||
public String getCasesPerOneMillion() {
|
||||
return casesPerOneMillion;
|
||||
}
|
||||
|
||||
public void setCasesPerOneMillion(String casesPerOneMillion) {
|
||||
this.casesPerOneMillion = casesPerOneMillion;
|
||||
}
|
||||
|
||||
public String getDeathsPerOneMillion() {
|
||||
return deathsPerOneMillion;
|
||||
}
|
||||
|
||||
public void setDeathsPerOneMillion(String deathsPerOneMillion) {
|
||||
this.deathsPerOneMillion = deathsPerOneMillion;
|
||||
}
|
||||
|
||||
public String getTests() {
|
||||
return tests;
|
||||
}
|
||||
|
||||
public void setTests(String tests) {
|
||||
this.tests = tests;
|
||||
}
|
||||
|
||||
public String getTestsPerOneMillion() {
|
||||
return testsPerOneMillion;
|
||||
}
|
||||
|
||||
public void setTestsPerOneMillion(String testsPerOneMillion) {
|
||||
this.testsPerOneMillion = testsPerOneMillion;
|
||||
}
|
||||
|
||||
public CountryInfoPojo getCountryInfoPojo() {
|
||||
return countryInfoPojo;
|
||||
}
|
||||
|
||||
public void setCountryInfoPojo(CountryInfoPojo countryInfoPojo) {
|
||||
this.countryInfoPojo = countryInfoPojo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -0,0 +1,74 @@
|
||||
package com.josh.trackcovid19v2.data.network.pojo;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class YesCountryInfoPojo {
|
||||
|
||||
@SerializedName("_id")
|
||||
@Expose
|
||||
private String _id;
|
||||
@SerializedName("iso2")
|
||||
@Expose
|
||||
private String iso2;
|
||||
@SerializedName("iso3")
|
||||
@Expose
|
||||
private String iso3;
|
||||
@SerializedName("lat")
|
||||
@Expose
|
||||
private String lat;
|
||||
@SerializedName("llong")
|
||||
@Expose
|
||||
private String llong;
|
||||
@SerializedName("flag")
|
||||
@Expose
|
||||
private String flag;
|
||||
|
||||
public String get_id() {
|
||||
return _id;
|
||||
}
|
||||
|
||||
public void set_id(String _id) {
|
||||
this._id = _id;
|
||||
}
|
||||
|
||||
public String getIso2() {
|
||||
return iso2;
|
||||
}
|
||||
|
||||
public void setIso2(String iso2) {
|
||||
this.iso2 = iso2;
|
||||
}
|
||||
|
||||
public String getIso3() {
|
||||
return iso3;
|
||||
}
|
||||
|
||||
public void setIso3(String iso3) {
|
||||
this.iso3 = iso3;
|
||||
}
|
||||
|
||||
public String getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(String lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public String getLlong() {
|
||||
return llong;
|
||||
}
|
||||
|
||||
public void setLlong(String llong) {
|
||||
this.llong = llong;
|
||||
}
|
||||
|
||||
public String getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(String flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
package com.josh.trackcovid19v2.data.network.pojo;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class YesStatesPojo {
|
||||
@SerializedName("state")
|
||||
@Expose
|
||||
public String state;
|
||||
@SerializedName("cases")
|
||||
@Expose
|
||||
public String cases;
|
||||
@SerializedName("todayCases")
|
||||
@Expose
|
||||
public String todayCases;
|
||||
@SerializedName("deaths")
|
||||
@Expose
|
||||
public String deaths;
|
||||
@SerializedName("todayDeaths")
|
||||
@Expose
|
||||
public String todayDeaths;
|
||||
@SerializedName("active")
|
||||
@Expose
|
||||
public String active;
|
||||
@SerializedName("tests")
|
||||
private String tests;
|
||||
@SerializedName("testsPerOneMillion")
|
||||
@Expose
|
||||
private String testsPerOneMillion;
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getCases() {
|
||||
return cases;
|
||||
}
|
||||
|
||||
public void setCases(String cases) {
|
||||
this.cases = cases;
|
||||
}
|
||||
|
||||
public String getTodayCases() {
|
||||
return todayCases;
|
||||
}
|
||||
|
||||
public void setTodayCases(String todayCases) {
|
||||
this.todayCases = todayCases;
|
||||
}
|
||||
|
||||
public String getDeaths() {
|
||||
return deaths;
|
||||
}
|
||||
|
||||
public void setDeaths(String deaths) {
|
||||
this.deaths = deaths;
|
||||
}
|
||||
|
||||
public String getTodayDeaths() {
|
||||
return todayDeaths;
|
||||
}
|
||||
|
||||
public void setTodayDeaths(String todayDeaths) {
|
||||
this.todayDeaths = todayDeaths;
|
||||
}
|
||||
|
||||
|
||||
public String getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(String active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
|
||||
public String getTests() {
|
||||
return tests;
|
||||
}
|
||||
|
||||
public void setTests(String tests) {
|
||||
this.tests = tests;
|
||||
}
|
||||
|
||||
public String getTestsPerOneMillion() {
|
||||
return testsPerOneMillion;
|
||||
}
|
||||
|
||||
public void setTestsPerOneMillion(String testsPerOneMillion) {
|
||||
this.testsPerOneMillion = testsPerOneMillion;
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user