From 5d4df9c26052a06123bf91fe7b0e0bd0568c9385 Mon Sep 17 00:00:00 2001 From: Ritwik Date: Fri, 1 Oct 2021 23:18:27 +0530 Subject: [PATCH 1/2] Changed base API endpoint --- .../gocoronago/base/RetrofitInstance.kt | 2 +- .../homepage/models/WorldwideData.kt | 49 +++++++++++++++++++ .../gocoronago/ui/main/MainInterface.kt | 6 +-- .../example/gocoronago/ui/main/MainRepo.kt | 4 +- 4 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/com/example/gocoronago/homepage/models/WorldwideData.kt diff --git a/app/src/main/java/com/example/gocoronago/base/RetrofitInstance.kt b/app/src/main/java/com/example/gocoronago/base/RetrofitInstance.kt index c9d2df5..3b2de27 100644 --- a/app/src/main/java/com/example/gocoronago/base/RetrofitInstance.kt +++ b/app/src/main/java/com/example/gocoronago/base/RetrofitInstance.kt @@ -7,7 +7,7 @@ object RetrofitInstance { fun createInstance(): Retrofit { return Retrofit.Builder() - .baseUrl("https://api.covid19api.com") + .baseUrl("https://disease.sh/v3/covid-19/") .addConverterFactory(GsonConverterFactory.create()) .build() } diff --git a/app/src/main/java/com/example/gocoronago/homepage/models/WorldwideData.kt b/app/src/main/java/com/example/gocoronago/homepage/models/WorldwideData.kt new file mode 100644 index 0000000..22e5980 --- /dev/null +++ b/app/src/main/java/com/example/gocoronago/homepage/models/WorldwideData.kt @@ -0,0 +1,49 @@ +package com.example.gocoronago.homepage.models + + +import com.google.gson.annotations.SerializedName +import androidx.annotation.Keep + +@Keep +data class WorldwideData( + @SerializedName("active") + var active: Int?, // 0 + @SerializedName("activePerOneMillion") + var activePerOneMillion: Int?, // 0 + @SerializedName("affectedCountries") + var affectedCountries: Int?, // 0 + @SerializedName("cases") + var cases: Int?, // 0 + @SerializedName("casesPerOneMillion") + var casesPerOneMillion: Int?, // 0 + @SerializedName("critical") + var critical: Int?, // 0 + @SerializedName("criticalPerOneMillion") + var criticalPerOneMillion: Int?, // 0 + @SerializedName("deaths") + var deaths: Int?, // 0 + @SerializedName("deathsPerOneMillion") + var deathsPerOneMillion: Int?, // 0 + @SerializedName("oneCasePerPeople") + var oneCasePerPeople: Int?, // 0 + @SerializedName("oneDeathPerPeople") + var oneDeathPerPeople: Int?, // 0 + @SerializedName("oneTestPerPeople") + var oneTestPerPeople: Int?, // 0 + @SerializedName("population") + var population: Int?, // 0 + @SerializedName("recovered") + var recovered: Int?, // 0 + @SerializedName("recoveredPerOneMillion") + var recoveredPerOneMillion: Int?, // 0 + @SerializedName("tests") + var tests: Int?, // 0 + @SerializedName("testsPerOneMillion") + var testsPerOneMillion: Int?, // 0 + @SerializedName("todayCases") + var todayCases: Int?, // 0 + @SerializedName("todayRecovered") + var todayRecovered: Int?, // 0 + @SerializedName("updated") + var updated: Int? // 0 +) \ No newline at end of file diff --git a/app/src/main/java/com/example/gocoronago/ui/main/MainInterface.kt b/app/src/main/java/com/example/gocoronago/ui/main/MainInterface.kt index 9196ecc..6f5c8e2 100644 --- a/app/src/main/java/com/example/gocoronago/ui/main/MainInterface.kt +++ b/app/src/main/java/com/example/gocoronago/ui/main/MainInterface.kt @@ -1,9 +1,9 @@ package com.example.gocoronago.ui.main -import com.example.gocoronago.homepage.Summary +import com.example.gocoronago.homepage.models.WorldwideData import retrofit2.http.GET interface MainInterface { - @GET("summary") - suspend fun getSummary(): Summary + @GET("all") + suspend fun getSummary(): WorldwideData } \ No newline at end of file diff --git a/app/src/main/java/com/example/gocoronago/ui/main/MainRepo.kt b/app/src/main/java/com/example/gocoronago/ui/main/MainRepo.kt index 6ea3524..8bbad9c 100644 --- a/app/src/main/java/com/example/gocoronago/ui/main/MainRepo.kt +++ b/app/src/main/java/com/example/gocoronago/ui/main/MainRepo.kt @@ -1,12 +1,12 @@ package com.example.gocoronago.ui.main -import com.example.gocoronago.homepage.Summary import com.example.gocoronago.base.BaseRepo +import com.example.gocoronago.homepage.models.WorldwideData class MainRepo : BaseRepo() { private val service = retrofit.create(MainInterface::class.java) - suspend fun getCovidSummary(): Summary { + suspend fun getCovidSummary(): WorldwideData { return service.getSummary() } } \ No newline at end of file From f6d34c9ea808f09daca5673980548341b99592ec Mon Sep 17 00:00:00 2001 From: ritwikshanker Date: Sun, 16 Oct 2022 19:02:47 +0200 Subject: [PATCH 2/2] Made all data types double --- .../homepage/models/WorldwideData.kt | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/example/gocoronago/homepage/models/WorldwideData.kt b/app/src/main/java/com/example/gocoronago/homepage/models/WorldwideData.kt index 22e5980..8559a81 100644 --- a/app/src/main/java/com/example/gocoronago/homepage/models/WorldwideData.kt +++ b/app/src/main/java/com/example/gocoronago/homepage/models/WorldwideData.kt @@ -7,43 +7,43 @@ import androidx.annotation.Keep @Keep data class WorldwideData( @SerializedName("active") - var active: Int?, // 0 + var active: Double?, // 0 @SerializedName("activePerOneMillion") - var activePerOneMillion: Int?, // 0 + var activePerOneMillion: Double?, // 0 @SerializedName("affectedCountries") - var affectedCountries: Int?, // 0 + var affectedCountries: Double?, // 0 @SerializedName("cases") - var cases: Int?, // 0 + var cases: Double?, // 0 @SerializedName("casesPerOneMillion") - var casesPerOneMillion: Int?, // 0 + var casesPerOneMillion: Double?, // 0 @SerializedName("critical") - var critical: Int?, // 0 + var critical: Double?, // 0 @SerializedName("criticalPerOneMillion") - var criticalPerOneMillion: Int?, // 0 + var criticalPerOneMillion: Double?, // 0 @SerializedName("deaths") - var deaths: Int?, // 0 + var deaths: Double?, // 0 @SerializedName("deathsPerOneMillion") - var deathsPerOneMillion: Int?, // 0 + var deathsPerOneMillion: Double?, // 0 @SerializedName("oneCasePerPeople") - var oneCasePerPeople: Int?, // 0 + var oneCasePerPeople: Double?, // 0 @SerializedName("oneDeathPerPeople") - var oneDeathPerPeople: Int?, // 0 + var oneDeathPerPeople: Double?, // 0 @SerializedName("oneTestPerPeople") - var oneTestPerPeople: Int?, // 0 + var oneTestPerPeople: Double?, // 0 @SerializedName("population") - var population: Int?, // 0 + var population: Double?, // 0 @SerializedName("recovered") - var recovered: Int?, // 0 + var recovered: Double?, // 0 @SerializedName("recoveredPerOneMillion") - var recoveredPerOneMillion: Int?, // 0 + var recoveredPerOneMillion: Double?, // 0 @SerializedName("tests") - var tests: Int?, // 0 + var tests: Double?, // 0 @SerializedName("testsPerOneMillion") - var testsPerOneMillion: Int?, // 0 + var testsPerOneMillion: Double?, // 0 @SerializedName("todayCases") - var todayCases: Int?, // 0 + var todayCases: Double?, // 0 @SerializedName("todayRecovered") - var todayRecovered: Int?, // 0 + var todayRecovered: Double?, // 0 @SerializedName("updated") - var updated: Int? // 0 + var updated: Double? // 0 ) \ No newline at end of file