Fix the wrong error on the subscriptions page

This commit is contained in:
Bnyro 2022-10-21 18:35:35 +02:00
parent b499eb0358
commit 3b13cc4efb
2 changed files with 12 additions and 6 deletions

View File

@ -100,18 +100,21 @@ class BackgroundMode : Service() {
*/ */
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
if (Build.VERSION.SDK_INT >= 26) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channelId = BACKGROUND_CHANNEL_ID
val channel = NotificationChannel( val channel = NotificationChannel(
channelId, BACKGROUND_CHANNEL_ID,
"Background Service", "Background Service",
NotificationManager.IMPORTANCE_DEFAULT NotificationManager.IMPORTANCE_DEFAULT
) )
val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel) notificationManager.createNotificationChannel(channel)
val notification: Notification = Notification.Builder(this, channelId)
// see https://developer.android.com/reference/android/app/Service#startForeground(int,%20android.app.Notification)
val notification: Notification = Notification.Builder(this, BACKGROUND_CHANNEL_ID)
.setContentTitle(getString(R.string.app_name)) .setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.playingOnBackground)).build() .setContentText(getString(R.string.playingOnBackground))
.build()
startForeground(PLAYER_NOTIFICATION_ID, notification) startForeground(PLAYER_NOTIFICATION_ID, notification)
} }
} }

View File

@ -62,7 +62,10 @@ class SubscriptionsFragment : BaseFragment() {
// listen for error responses // listen for error responses
viewModel.errorResponse.observe(viewLifecycleOwner) { viewModel.errorResponse.observe(viewLifecycleOwner) {
if (it) Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show() if (it) {
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
viewModel.errorResponse.value = false
}
} }
viewModel.videoFeed.observe(viewLifecycleOwner) { viewModel.videoFeed.observe(viewLifecycleOwner) {