mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-08 20:12:39 +01:00
Apply updates from services
This commit is contained in:
parent
27d1b98330
commit
14578e26fc
@ -104,6 +104,7 @@ import com.pitchedapps.frost.utils.setFrostColors
|
||||
import com.pitchedapps.frost.views.BadgedIcon
|
||||
import com.pitchedapps.frost.views.FrostVideoViewer
|
||||
import com.pitchedapps.frost.views.FrostViewPager
|
||||
import com.pitchedapps.frost.widgets.NotificationWidget
|
||||
import kotlinx.android.synthetic.main.activity_frame_wrapper.*
|
||||
import kotlinx.android.synthetic.main.view_main_fab.*
|
||||
import kotlinx.android.synthetic.main.view_main_toolbar.*
|
||||
@ -450,7 +451,11 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
|
||||
Runtime.getRuntime().exit(0)
|
||||
return
|
||||
}
|
||||
if (resultCode and REQUEST_RESTART > 0) return restart()
|
||||
if (resultCode and REQUEST_RESTART > 0) {
|
||||
NotificationWidget.forceUpdate(this)
|
||||
restart()
|
||||
return
|
||||
}
|
||||
/*
|
||||
* These results can be stacked
|
||||
*/
|
||||
|
@ -27,6 +27,7 @@ import com.pitchedapps.frost.db.selectAll
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import com.pitchedapps.frost.utils.frostEvent
|
||||
import com.pitchedapps.frost.widgets.NotificationWidget
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
@ -105,6 +106,9 @@ class NotificationService : BaseJobService() {
|
||||
L.i { "Sent $notifCount notifications" }
|
||||
if (notifCount == 0 && jobId == NOTIFICATION_JOB_NOW)
|
||||
generalNotification(665, R.string.no_new_notifications, BuildConfig.DEBUG)
|
||||
if (notifCount > 0) {
|
||||
NotificationWidget.forceUpdate(this@NotificationService)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,7 @@ package com.pitchedapps.frost.widgets
|
||||
import android.app.PendingIntent
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.appwidget.AppWidgetProvider
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
@ -51,6 +52,7 @@ 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 type = NotificationType.GENERAL
|
||||
@ -82,6 +84,18 @@ class NotificationWidget : AppWidgetProvider() {
|
||||
}
|
||||
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_notification_list)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun forceUpdate(context: Context) {
|
||||
val manager = AppWidgetManager.getInstance(context)
|
||||
val ids = manager.getAppWidgetIds(ComponentName(context, NotificationWidget::class.java))
|
||||
val intent = Intent().apply {
|
||||
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
|
||||
putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
|
||||
}
|
||||
context.sendBroadcast(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private const val NOTIF_WIDGET_TYPE = "notif_widget_type"
|
||||
|
Loading…
Reference in New Issue
Block a user