mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-05 02:25:45 +02:00
Fix:Android auto reset server items if no longer connected to server #201
This commit is contained in:
parent
58bd0e0cee
commit
c4aca22c28
2 changed files with 13 additions and 3 deletions
|
@ -1,13 +1,10 @@
|
|||
package com.audiobookshelf.app.media
|
||||
|
||||
import android.bluetooth.BluetoothClass
|
||||
import android.content.Context
|
||||
import android.support.v4.media.MediaBrowserCompat
|
||||
import android.support.v4.media.MediaMetadataCompat
|
||||
import android.util.Log
|
||||
import com.audiobookshelf.app.data.*
|
||||
import com.audiobookshelf.app.device.DeviceManager
|
||||
import com.audiobookshelf.app.player.PlayerNotificationService
|
||||
import com.audiobookshelf.app.server.ApiHandler
|
||||
import java.util.*
|
||||
import io.paperdb.Paper
|
||||
|
@ -34,6 +31,18 @@ class MediaManager(var apiHandler: ApiHandler, var ctx: Context) {
|
|||
return serverLibraries.find { it.id == id } != null
|
||||
}
|
||||
|
||||
fun checkResetServerItems() {
|
||||
// When opening android auto need to check if still connected to server
|
||||
// and reset any server data already set
|
||||
if (!DeviceManager.isConnectedToServer) {
|
||||
serverPodcastEpisodes = listOf()
|
||||
serverLibraryCategories = listOf()
|
||||
serverLibraries = listOf()
|
||||
serverLibraryItems = listOf()
|
||||
selectedLibraryId = ""
|
||||
}
|
||||
}
|
||||
|
||||
fun loadLibraryCategories(libraryId:String, cb: (List<LibraryCategory>) -> Unit) {
|
||||
if (serverLibraryCategories.isNotEmpty()) {
|
||||
cb(serverLibraryCategories)
|
||||
|
|
|
@ -608,6 +608,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
|
|||
mediaManager.initializeAndroidAuto()
|
||||
isStarted = true
|
||||
}
|
||||
mediaManager.checkResetServerItems() // Reset any server items if no longer connected to server
|
||||
|
||||
isAndroidAuto = true
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue