Skip to content

Commit

Permalink
Handle target widget type in stacked widget
Browse files Browse the repository at this point in the history
Fixes iSoron#965.
  • Loading branch information
hiqua committed Aug 3, 2021
1 parent 69f0fc6 commit 0bc2a8b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int
AppWidgetManager.INVALID_APPWIDGET_ID
)
private val habitIds: LongArray
private val widgetType: StackWidgetType?
private val widgetType: StackWidgetType
private var remoteViews = ArrayList<RemoteViews>()
override fun onCreate() {}
override fun onDestroy() {}
Expand Down Expand Up @@ -105,7 +105,7 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int
StackWidgetType.SCORE -> ScoreWidget(context, widgetId, habit, true)
StackWidgetType.HISTORY -> HistoryWidget(context, widgetId, habit, true)
StackWidgetType.STREAKS -> StreakWidget(context, widgetId, habit, true)
else -> throw IllegalStateException()
StackWidgetType.TARGET -> TargetWidget(context, widgetId, habit, true)
}
}

Expand Down Expand Up @@ -157,6 +157,7 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int
if (widgetTypeValue < 0) throw RuntimeException("invalid widget type")
if (habitIdsStr == null) throw RuntimeException("habitIdsStr is null")
widgetType = StackWidgetType.getWidgetTypeFromValue(widgetTypeValue)
?: throw RuntimeException("unknown widget type value: $widgetTypeValue")
habitIds = splitLongs(habitIdsStr)
}
}

0 comments on commit 0bc2a8b

Please sign in to comment.