Skip to content

Commit

Permalink
Minor bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
hwki committed Oct 22, 2022
1 parent dd3ba21 commit 044030c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
4 changes: 2 additions & 2 deletions bitcoin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.brentpanther.bitcoinwidget"
minSdk 23
targetSdk 33
versionCode 310
versionName "8.3"
versionCode 311
versionName "8.3.1"

javaCompileOptions {
annotationProcessorOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ object WidgetUpdater {

// update display immediately to avoid looking bad
for (strategy in dataStrategies) {
val widgetPresenter = RemoteWidgetPresenter(context, strategy.widget)
val displayStrategy = WidgetDisplayStrategy.getStrategy(context, strategy.widget, widgetPresenter)
val widget = strategy.widget ?: continue
val widgetPresenter = RemoteWidgetPresenter(context, widget)
val displayStrategy = WidgetDisplayStrategy.getStrategy(context, widget, widgetPresenter)
displayStrategy.refresh()
}

Expand All @@ -27,8 +28,9 @@ object WidgetUpdater {

// data may cause display to need refreshed
for (strategy in dataStrategies) {
val widgetPresenter = RemoteWidgetPresenter(context, strategy.widget)
val displayStrategy = WidgetDisplayStrategy.getStrategy(context, strategy.widget, widgetPresenter)
val widget = strategy.widget ?: continue
val widgetPresenter = RemoteWidgetPresenter(context, widget)
val displayStrategy = WidgetDisplayStrategy.getStrategy(context, widget, widgetPresenter)
displayStrategy.refresh()
displayStrategy.save()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import java.io.IOException
open class PriceWidgetDataStrategy(widgetId: Int) : WidgetDataStrategy(widgetId) {

override suspend fun loadData(manual: Boolean): Unit = withContext(Dispatchers.IO) {
val widget = widget ?: return@withContext
val config = getConfig()
if (manual) {
delay(750)
Expand Down Expand Up @@ -41,8 +42,10 @@ open class PriceWidgetDataStrategy(widgetId: Int) : WidgetDataStrategy(widgetId)
}

open fun setData(value: String) {
widget.lastValue = value
widget.lastUpdated = System.currentTimeMillis()
widget?.apply {
lastValue = value
lastUpdated = System.currentTimeMillis()
}
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ package com.brentpanther.bitcoinwidget.strategy.data
class ValueWidgetDataStrategy(widgetId: Int) : PriceWidgetDataStrategy(widgetId) {

override fun setData(value: String) {
val valueDouble = value.toDoubleOrNull() ?: 0.0
val amountHeld = widget.amountHeld ?: 0.0
widget.lastValue = (valueDouble * amountHeld).toString()
widget.lastUpdated = System.currentTimeMillis()
widget?.apply {
val valueDouble = value.toDoubleOrNull() ?: 0.0
val amountHeld = amountHeld ?: 0.0
lastValue = (valueDouble * amountHeld).toString()
lastUpdated = System.currentTimeMillis()
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ abstract class WidgetDataStrategy(val widgetId: Int) {

private var _widget : Widget? = null

var widget : Widget
var widget : Widget?
get() {
_widget = _widget ?: dao.getByWidgetId(widgetId) ?: throw IllegalArgumentException()
return _widget!!
return _widget ?: dao.getByWidgetId(widgetId)
}
set(value) {
_widget = value
Expand All @@ -25,7 +24,7 @@ abstract class WidgetDataStrategy(val widgetId: Int) {
abstract suspend fun loadData(manual: Boolean)

suspend fun save() {
dao.update(widget)
widget?.let { dao.update(it) }
}

companion object {
Expand Down
4 changes: 4 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/311.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
New create screen with search powered by CoinGecko. Search and create a widget for any cryptocurrency.
Added themed app icon for Android 13.
New widgets will default settings to match the last created widget.
Major overhaul of UI behind the screens.

0 comments on commit 044030c

Please sign in to comment.