Skip to content

Commit

Permalink
Update minSDK to 26 (android 8) and tweaks to fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
premnirmal committed Jul 21, 2023
1 parent 25ea965 commit 7358e9c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 65 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ android {

defaultConfig {
applicationId appIdBase
minSdkVersion 28
minSdkVersion 26
targetSdkVersion 33

versionCode = code
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class StocksProvider @Inject constructor(
FetchResult.success(quoteMap.values.filter { tickerSet.contains(it.symbol) }.toList())
}
} catch(ex: CancellationException) {
_fetchState.emit(FetchState.Failure(ex))
FetchResult.failure<List<Quote>>(FetchException("Failed to fetch", ex))
} catch (ex: Throwable) {
Timber.w(ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class StocksApi @Inject constructor(
withContext(Dispatchers.IO) {
try {
val quoteNets = getStocksYahoo(tickerList)
?: return@withContext FetchResult.failure(FetchException("Failed to fetch"))
return@withContext FetchResult.success(quoteNets.toQuoteMap().toOrderedList(tickerList))
} catch (ex: Exception) {
Timber.e(ex)
Expand All @@ -100,6 +101,7 @@ class StocksApi @Inject constructor(
withContext(Dispatchers.IO) {
try {
val quoteNets = getStocksYahoo(listOf(ticker))
?: return@withContext FetchResult.failure(FetchException("Failed to fetch $ticker"))
return@withContext FetchResult.success(quoteNets.first().toQuote())
} catch (ex: Exception) {
Timber.e(ex)
Expand Down Expand Up @@ -130,12 +132,15 @@ class StocksApi @Inject constructor(
private suspend fun getStocksYahoo(
tickerList: List<String>,
invocationCount: Int = 1
): List<YahooQuoteNet> =
): List<YahooQuoteNet>? =
withContext(Dispatchers.IO) {
val query = tickerList.joinToString(",")
var quotesResponse: retrofit2.Response<YahooResponse>? = null
try {
quotesResponse = yahooFinance.getStocks(query)
if (!quotesResponse.isSuccessful) {
Timber.e("Yahoo quote fetch failed with code ${quotesResponse.code()}")
}
if (quotesResponse.code() == 401) {
appPreferences.setCrumb(null)
loadCrumb()
Expand All @@ -147,7 +152,7 @@ class StocksApi @Inject constructor(
Timber.e(ex)
throw ex
}
val quoteNets = quotesResponse.body()?.quoteResponse?.result ?: emptyList()
val quoteNets = quotesResponse.body()?.quoteResponse?.result
quoteNets
}

Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions app/version.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# this file is purely for f-droid because it cannot infer the version name/code from the git tag
versionName=3.9.827
versionCode=300900827
versionName=3.9.828
versionCode=300900828

0 comments on commit 7358e9c

Please sign in to comment.