diff --git a/.gitignore b/.gitignore
index b0c9a07..32768b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -204,4 +204,5 @@ fabric.properties
# CUSTOM IGNORES
gradle.properties
-notes.txt
\ No newline at end of file
+notes.txt
+app/release
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 510a8df..6b1d701 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -19,6 +19,7 @@ android {
vectorDrawables {
useSupportLibrary true
}
+ resConfigs "en"
}
buildTypes {
@@ -26,8 +27,11 @@ android {
applicationIdSuffix ".debug"
}
release {
- minifyEnabled false
+ minifyEnabled true
+ shrinkResources true
+ debuggable false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ signingConfig signingConfigs.debug
}
}
compileOptions {
@@ -48,7 +52,7 @@ android {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
- namespace 'com.ryankoech.krypto '
+ namespace 'com.ryankoech.krypto'
}
dependencies {
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e5c10b1..bf0a632 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -5,7 +5,7 @@
diff --git a/feature_coin_details/src/main/java/com/ryankoech/krypto/feature_coin_details/domain/usecase/GetCoinMarketChartUseCase.kt b/feature_coin_details/src/main/java/com/ryankoech/krypto/feature_coin_details/domain/usecase/GetCoinMarketChartUseCase.kt
index ab0b83b..7bc0de6 100644
--- a/feature_coin_details/src/main/java/com/ryankoech/krypto/feature_coin_details/domain/usecase/GetCoinMarketChartUseCase.kt
+++ b/feature_coin_details/src/main/java/com/ryankoech/krypto/feature_coin_details/domain/usecase/GetCoinMarketChartUseCase.kt
@@ -1,6 +1,5 @@
package com.ryankoech.krypto.feature_coin_details.domain.usecase
-import com.ryankoech.krypto.common.core.ktx.isNotNull
import com.ryankoech.krypto.common.core.util.Resource
import com.ryankoech.krypto.feature_coin_details.core.di.HILT_NAME_REPO_FOR_ALL
import com.ryankoech.krypto.feature_coin_details.data.dto.market_chart_dto.toMarketChartEntityList
@@ -17,46 +16,20 @@ import javax.inject.Named
class GetCoinMarketChartUseCase @Inject constructor(
@Named(HILT_NAME_REPO_FOR_ALL) private val repository: CoinDetailsRepository
) {
- private var cacheCoinId : String? = null
- private var cacheChartEntities : List>? = null
-
operator fun invoke(coinId : String) = flow>>> {
- if(cacheCoinId.isNotNull() && cacheCoinId == coinId && !cacheChartEntities.isNullOrEmpty()){
- emit(Resource.Success(
- cacheChartEntities!!
- ))
- return@flow
- }
-
val dayMarketChartResponse = repository.getDayMarketChart(coinId)
val threeMonthMarketChartResponse = repository.getThreeMonthsMarketChart(coinId)
val yearMarketChartResponse = repository.getYearMarketChart(coinId)
if(dayMarketChartResponse.isSuccessful && threeMonthMarketChartResponse.isSuccessful && yearMarketChartResponse.isSuccessful) {
- val dayMarketChartEntity = dayMarketChartResponse.body()!!.toMarketChartEntityList()
- val threeMonthMarketChartEntity = threeMonthMarketChartResponse.body()!!.toMarketChartEntityList()
- val yearMarketChartEntity = yearMarketChartResponse.body()!!.toMarketChartEntityList()
-
- // Clear cache after 1 minute
- Timer().schedule(object : TimerTask() {
- override fun run() {
- cacheChartEntities = null
- cacheCoinId = null
- }
- }, 60_000)
-
- cacheChartEntities = listOf(
- dayMarketChartEntity,
- threeMonthMarketChartEntity,
- yearMarketChartEntity
- )
- cacheCoinId = coinId
+ emit(Resource.Success(listOf(
+ dayMarketChartResponse.body()!!.toMarketChartEntityList(),
+ threeMonthMarketChartResponse.body()!!.toMarketChartEntityList(),
+ yearMarketChartResponse.body()!!.toMarketChartEntityList(),
+ )))
- emit(Resource.Success(
- cacheChartEntities!!
- ))
} else {
throw Exception("Response not Successful.")
}
diff --git a/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/data_source/local/sharedl_pref/CoinsLocalPref.kt b/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/data_source/local/sharedl_pref/CoinsLocalPref.kt
index 9688d23..8bb99c6 100644
--- a/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/data_source/local/sharedl_pref/CoinsLocalPref.kt
+++ b/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/data_source/local/sharedl_pref/CoinsLocalPref.kt
@@ -2,6 +2,8 @@ package com.ryankoech.krypto.feature_coin_list.data.data_source.local.sharedl_pr
import android.content.Context
import android.content.SharedPreferences
+import android.widget.Toast
+import androidx.annotation.Keep
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.ryankoech.krypto.common.presentation.util.DisplayCurrency
@@ -16,7 +18,7 @@ class CoinsLocalPref @Inject constructor(
@ApplicationContext private val context : Context
) {
- companion object {
+ @Keep companion object {
private const val PREF_NAME = "feature_coin_local_pref"
private const val DISPLAY_CURRENCY_KEY = "display_currency_data"
}
@@ -46,9 +48,13 @@ class CoinsLocalPref @Inject constructor(
prefs = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
val json = prefs?.getString(DISPLAY_CURRENCY_KEY, "")
- val displayCurrencyData: List =
- gson.fromJson(json, object : TypeToken>() {}.type)
- displayCurrencyData
+ if (json.isNullOrEmpty()) {
+ listOf()
+ } else {
+ val displayCurrencyData: List =
+ gson.fromJson(json, object : TypeToken>() {}.type)
+ displayCurrencyData
+ }
}catch (e : Exception) {
Timber.w(e)
null
diff --git a/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/dto/CoinDto.kt b/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/dto/CoinDto.kt
index 131ef83..28f2244 100644
--- a/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/dto/CoinDto.kt
+++ b/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/dto/CoinDto.kt
@@ -1,33 +1,60 @@
package com.ryankoech.krypto.feature_coin_list.data.dto
+import com.google.gson.annotations.SerializedName
import com.ryankoech.krypto.feature_coin_list.domain.entity.Coin
data class CoinDto(
+ @SerializedName("ath")
val ath: Double,
+ @SerializedName("ath_change_percentage")
val ath_change_percentage: Double,
+ @SerializedName("ath_date")
val ath_date: String,
+ @SerializedName("atl")
val atl: Double,
+ @SerializedName("atl_change_percentage")
val atl_change_percentage: Double,
+ @SerializedName("atl_date")
val atl_date: String,
+ @SerializedName("circulating_supply")
val circulating_supply: Double,
+ @SerializedName("current_price")
val current_price: Double,
+ @SerializedName("fully_diluted_valuation")
val fully_diluted_valuation: Long,
+ @SerializedName("high_24h")
val high_24h: Double,
+ @SerializedName("id")
val id: String,
+ @SerializedName("image")
val image: String,
+ @SerializedName("last_updated")
val last_updated: String,
+ @SerializedName("low_24h")
val low_24h: Double,
+ @SerializedName("market_cap")
val market_cap: Long,
+ @SerializedName("market_cap_change_24h")
val market_cap_change_24h: Double,
+ @SerializedName("market_cap_change_percentage_24h")
val market_cap_change_percentage_24h: Double,
+ @SerializedName("market_cap_rank")
val market_cap_rank: Int,
+ @SerializedName("max_supply")
val max_supply: Double?,
+ @SerializedName("name")
val name: String,
+ @SerializedName("price_change_24h")
val price_change_24h: Double,
+ @SerializedName("price_change_percentage_24h")
val price_change_percentage_24h: Double,
+ @SerializedName("roi")
val roi: Roi?,
+ @SerializedName("symbol")
val symbol: String,
+ @SerializedName("total_supply")
val total_supply: Double,
+ @SerializedName("total_volume")
val total_volume: Double
)
diff --git a/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/dto/Roi.kt b/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/dto/Roi.kt
index a163758..b0f0684 100644
--- a/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/dto/Roi.kt
+++ b/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/dto/Roi.kt
@@ -1,7 +1,12 @@
package com.ryankoech.krypto.feature_coin_list.data.dto
+import com.google.gson.annotations.SerializedName
+
data class Roi(
+ @SerializedName("currency")
val currency: String,
+ @SerializedName("percentage")
val percentage: Double,
+ @SerializedName("times")
val times: Double
)
\ No newline at end of file
diff --git a/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/dto/display_currency/DisplayCurrencyDto.kt b/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/dto/display_currency/DisplayCurrencyDto.kt
index 16c92b2..23852af 100644
--- a/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/dto/display_currency/DisplayCurrencyDto.kt
+++ b/feature_coin_list/src/main/java/com/ryankoech/krypto/feature_coin_list/data/dto/display_currency/DisplayCurrencyDto.kt
@@ -1,8 +1,11 @@
package com.ryankoech.krypto.feature_coin_list.data.dto.display_currency
+import com.google.gson.annotations.SerializedName
import com.ryankoech.krypto.common.presentation.util.DisplayCurrency
data class DisplayCurrencyDto(
+ @SerializedName("currency")
val currency : DisplayCurrency,
+ @SerializedName("value")
val value : Double
)