1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-10 04:52:38 +01:00

Remove unnecessary id

This commit is contained in:
Allan Wang 2019-04-22 04:44:19 -04:00
parent ba0b4e70d9
commit 9df2a87822
No known key found for this signature in database
GPG Key ID: C93E3F9C679D7A56

View File

@ -34,15 +34,13 @@ import com.pitchedapps.frost.services.NOTIF_CHANNEL_GENERAL
import com.pitchedapps.frost.services.NotificationContent
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.widgets.NotificationWidget.Companion.NOTIF_WIDGET_IDS
import com.pitchedapps.frost.widgets.NotificationWidget.Companion.NOTIF_WIDGET_TYPE
import org.koin.standalone.KoinComponent
import org.koin.standalone.inject
class NotificationWidget : AppWidgetProvider() {
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
super.onUpdate(context, appWidgetManager, appWidgetIds)
val intent = NotificationWidgetService.createIntent(context, NOTIF_CHANNEL_GENERAL, appWidgetIds)
val intent = NotificationWidgetService.createIntent(context, NOTIF_CHANNEL_GENERAL)
for (id in appWidgetIds) {
val views = RemoteViews(context.packageName, R.layout.widget_notifications)
views.setBackgroundColor(R.id.widget_layout_container, Prefs.bgColor)
@ -51,13 +49,10 @@ class NotificationWidget : AppWidgetProvider() {
}
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_notification_list)
}
companion object {
const val NOTIF_WIDGET_TYPE = "notif_widget_type"
const val NOTIF_WIDGET_IDS = "notif_widget_ids"
}
}
private const val NOTIF_WIDGET_TYPE = "notif_widget_type"
private fun RemoteViews.setBackgroundColor(viewId: Int, @ColorInt color: Int) {
setInt(viewId, "setBackgroundColor", color)
}
@ -66,10 +61,9 @@ class NotificationWidgetService : RemoteViewsService() {
override fun onGetViewFactory(intent: Intent): RemoteViewsFactory = NotificationWidgetDataProvider(this, intent)
companion object {
fun createIntent(context: Context, type: String, appWidgetIds: IntArray): Intent =
fun createIntent(context: Context, type: String): Intent =
Intent(context, NotificationWidgetService::class.java)
.putExtra(NOTIF_WIDGET_TYPE, type)
.putExtra(NOTIF_WIDGET_IDS, appWidgetIds)
}
}
@ -82,8 +76,6 @@ class NotificationWidgetDataProvider(val context: Context, val intent: Intent) :
private val type = intent.getStringExtra(NOTIF_WIDGET_TYPE)
private val widgetIds = intent.getIntArrayExtra(NOTIF_WIDGET_IDS)
private val avatarSize = context.dimenPixelSize(R.dimen.avatar_image_size)
private val glide = GlideApp.with(context).asBitmap()