Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature-61 :: Set up app release variant #62

Merged
merged 1 commit into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,5 @@ fabric.properties
# CUSTOM IGNORES

gradle.properties
notes.txt
notes.txt
app/release
8 changes: 6 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@ android {
vectorDrawables {
useSupportLibrary true
}
resConfigs "en"
}

buildTypes {
debug {
applicationIdSuffix ".debug"
}
release {
minifyEnabled false
minifyEnabled true
shrinkResources true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
}
compileOptions {
Expand All @@ -48,7 +52,7 @@ android {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
namespace 'com.ryankoech.krypto '
namespace 'com.ryankoech.krypto'
}

dependencies {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:name=".core.KryptoApplication"
android:name="com.ryankoech.krypto.core.KryptoApplication"
android:usesCleartextTraffic="true"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -17,7 +17,7 @@
android:theme="@style/Theme.Krypto"
tools:targetApi="31">
<activity
android:name=".presentation.MainActivity"
android:name="com.ryankoech.krypto.presentation.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Krypto">
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<List<MarketChartEntity>>? = null

operator fun invoke(coinId : String) = flow<Resource<List<List<MarketChartEntity>>>> {

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.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
}
Expand Down Expand Up @@ -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<DisplayCurrencyDto> =
gson.fromJson(json, object : TypeToken<List<DisplayCurrencyDto>>() {}.type)
displayCurrencyData
if (json.isNullOrEmpty()) {
listOf()
} else {
val displayCurrencyData: List<DisplayCurrencyDto> =
gson.fromJson(json, object : TypeToken<List<DisplayCurrencyDto>>() {}.type)
displayCurrencyData
}
}catch (e : Exception) {
Timber.w(e)
null
Expand Down
Original file line number Diff line number Diff line change
@@ -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
)

Expand Down
Original file line number Diff line number Diff line change
@@ -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
)
Original file line number Diff line number Diff line change
@@ -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
)