|
|
@ -53,7 +53,7 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int
|
|
|
|
AppWidgetManager.INVALID_APPWIDGET_ID
|
|
|
|
AppWidgetManager.INVALID_APPWIDGET_ID
|
|
|
|
)
|
|
|
|
)
|
|
|
|
private val habitIds: LongArray
|
|
|
|
private val habitIds: LongArray
|
|
|
|
private val widgetType: StackWidgetType?
|
|
|
|
private val widgetType: StackWidgetType
|
|
|
|
private var remoteViews = ArrayList<RemoteViews>()
|
|
|
|
private var remoteViews = ArrayList<RemoteViews>()
|
|
|
|
override fun onCreate() {}
|
|
|
|
override fun onCreate() {}
|
|
|
|
override fun onDestroy() {}
|
|
|
|
override fun onDestroy() {}
|
|
|
@ -86,7 +86,7 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int
|
|
|
|
|
|
|
|
|
|
|
|
override fun getViewAt(position: Int): RemoteViews? {
|
|
|
|
override fun getViewAt(position: Int): RemoteViews? {
|
|
|
|
Log.i("StackRemoteViewsFactory", "getViewAt $position")
|
|
|
|
Log.i("StackRemoteViewsFactory", "getViewAt $position")
|
|
|
|
return if (position < 0 || position > remoteViews.size) null else remoteViews[position]
|
|
|
|
return if (0 <= position && position < remoteViews.size) remoteViews[position] else null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun constructWidget(
|
|
|
|
private fun constructWidget(
|
|
|
@ -105,7 +105,7 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int
|
|
|
|
StackWidgetType.SCORE -> ScoreWidget(context, widgetId, habit, true)
|
|
|
|
StackWidgetType.SCORE -> ScoreWidget(context, widgetId, habit, true)
|
|
|
|
StackWidgetType.HISTORY -> HistoryWidget(context, widgetId, habit, true)
|
|
|
|
StackWidgetType.HISTORY -> HistoryWidget(context, widgetId, habit, true)
|
|
|
|
StackWidgetType.STREAKS -> StreakWidget(context, widgetId, habit, true)
|
|
|
|
StackWidgetType.STREAKS -> StreakWidget(context, widgetId, habit, true)
|
|
|
|
else -> throw IllegalStateException()
|
|
|
|
StackWidgetType.TARGET -> TargetWidget(context, widgetId, habit, true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -157,6 +157,7 @@ internal class StackRemoteViewsFactory(private val context: Context, intent: Int
|
|
|
|
if (widgetTypeValue < 0) throw RuntimeException("invalid widget type")
|
|
|
|
if (widgetTypeValue < 0) throw RuntimeException("invalid widget type")
|
|
|
|
if (habitIdsStr == null) throw RuntimeException("habitIdsStr is null")
|
|
|
|
if (habitIdsStr == null) throw RuntimeException("habitIdsStr is null")
|
|
|
|
widgetType = StackWidgetType.getWidgetTypeFromValue(widgetTypeValue)
|
|
|
|
widgetType = StackWidgetType.getWidgetTypeFromValue(widgetTypeValue)
|
|
|
|
|
|
|
|
?: throw RuntimeException("unknown widget type value: $widgetTypeValue")
|
|
|
|
habitIds = splitLongs(habitIdsStr)
|
|
|
|
habitIds = splitLongs(habitIdsStr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|