|
|
|
@ -34,7 +34,8 @@ class StackWidget(
|
|
|
|
|
widgetId: Int,
|
|
|
|
|
private val widgetType: StackWidgetType,
|
|
|
|
|
private val habits: List<Habit>,
|
|
|
|
|
) : BaseWidget(context, widgetId) {
|
|
|
|
|
stacked: Boolean = true,
|
|
|
|
|
) : BaseWidget(context, widgetId, stacked) {
|
|
|
|
|
override val defaultHeight: Int = 0
|
|
|
|
|
override val defaultWidth: Int = 0
|
|
|
|
|
|
|
|
|
@ -51,7 +52,8 @@ class StackWidget(
|
|
|
|
|
|
|
|
|
|
override fun getRemoteViews(width: Int, height: Int): RemoteViews {
|
|
|
|
|
val manager = AppWidgetManager.getInstance(context)
|
|
|
|
|
val remoteViews = RemoteViews(context.packageName, StackWidgetType.getStackWidgetLayoutId(widgetType))
|
|
|
|
|
val remoteViews =
|
|
|
|
|
RemoteViews(context.packageName, StackWidgetType.getStackWidgetLayoutId(widgetType))
|
|
|
|
|
val serviceIntent = Intent(context, StackWidgetService::class.java)
|
|
|
|
|
val habitIds = StringUtils.joinLongs(habits.map { it.id!! }.toLongArray())
|
|
|
|
|
|
|
|
|
@ -59,8 +61,14 @@ class StackWidget(
|
|
|
|
|
serviceIntent.putExtra(StackWidgetService.WIDGET_TYPE, widgetType.value)
|
|
|
|
|
serviceIntent.putExtra(StackWidgetService.HABIT_IDS, habitIds)
|
|
|
|
|
serviceIntent.data = Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME))
|
|
|
|
|
remoteViews.setRemoteAdapter(StackWidgetType.getStackWidgetAdapterViewId(widgetType), serviceIntent)
|
|
|
|
|
manager.notifyAppWidgetViewDataChanged(id, StackWidgetType.getStackWidgetAdapterViewId(widgetType))
|
|
|
|
|
remoteViews.setRemoteAdapter(
|
|
|
|
|
StackWidgetType.getStackWidgetAdapterViewId(widgetType),
|
|
|
|
|
serviceIntent
|
|
|
|
|
)
|
|
|
|
|
manager.notifyAppWidgetViewDataChanged(
|
|
|
|
|
id,
|
|
|
|
|
StackWidgetType.getStackWidgetAdapterViewId(widgetType)
|
|
|
|
|
)
|
|
|
|
|
remoteViews.setEmptyView(
|
|
|
|
|
StackWidgetType.getStackWidgetAdapterViewId(widgetType),
|
|
|
|
|
StackWidgetType.getStackWidgetEmptyViewId(widgetType)
|
|
|
|
|