mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-29 14:47:21 +02:00
Update:Android auto reset saved data if server config id changes
This commit is contained in:
@@ -21,6 +21,7 @@ class MediaManager(var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
var serverPodcastEpisodes = listOf<PodcastEpisode>()
|
var serverPodcastEpisodes = listOf<PodcastEpisode>()
|
||||||
var serverLibraryCategories = listOf<LibraryCategory>()
|
var serverLibraryCategories = listOf<LibraryCategory>()
|
||||||
var serverLibraries = listOf<Library>()
|
var serverLibraries = listOf<Library>()
|
||||||
|
var serverConfigIdUsed:String? = null
|
||||||
|
|
||||||
fun initializeAndroidAuto() {
|
fun initializeAndroidAuto() {
|
||||||
Log.d(tag, "Android Auto started when MainActivity was never started - initializing Paper")
|
Log.d(tag, "Android Auto started when MainActivity was never started - initializing Paper")
|
||||||
@@ -34,7 +35,9 @@ class MediaManager(var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
fun checkResetServerItems() {
|
fun checkResetServerItems() {
|
||||||
// When opening android auto need to check if still connected to server
|
// When opening android auto need to check if still connected to server
|
||||||
// and reset any server data already set
|
// and reset any server data already set
|
||||||
if (!DeviceManager.isConnectedToServer) {
|
val serverConnConfig = if (DeviceManager.isConnectedToServer) DeviceManager.serverConnectionConfig else DeviceManager.deviceData.getLastServerConnectionConfig()
|
||||||
|
|
||||||
|
if (!DeviceManager.isConnectedToServer || !apiHandler.isOnline() || serverConnConfig == null || serverConnConfig.id !== serverConfigIdUsed) {
|
||||||
serverPodcastEpisodes = listOf()
|
serverPodcastEpisodes = listOf()
|
||||||
serverLibraryCategories = listOf()
|
serverLibraryCategories = listOf()
|
||||||
serverLibraries = listOf()
|
serverLibraries = listOf()
|
||||||
@@ -162,6 +165,8 @@ class MediaManager(var apiHandler: ApiHandler, var ctx: Context) {
|
|||||||
Log.d(tag, "Not connected to server, set last server \"${DeviceManager.serverAddress}\"")
|
Log.d(tag, "Not connected to server, set last server \"${DeviceManager.serverAddress}\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
serverConfigIdUsed = DeviceManager.serverConnectionConfigId
|
||||||
|
|
||||||
loadLibraries { libraries ->
|
loadLibraries { libraries ->
|
||||||
val library = libraries[0]
|
val library = libraries[0]
|
||||||
Log.d(tag, "Loading categories for library ${library.name} - ${library.id} - ${library.mediaType}")
|
Log.d(tag, "Loading categories for library ${library.name} - ${library.id} - ${library.mediaType}")
|
||||||
|
|||||||
@@ -97,6 +97,10 @@ class MediaSessionCallback(var playerNotificationService:PlayerNotificationServi
|
|||||||
podcastEpisode = libraryItemWithEpisode?.episode
|
podcastEpisode = libraryItemWithEpisode?.episode
|
||||||
} else {
|
} else {
|
||||||
libraryItemWrapper = playerNotificationService.mediaManager.getById(mediaId)
|
libraryItemWrapper = playerNotificationService.mediaManager.getById(mediaId)
|
||||||
|
|
||||||
|
if (libraryItemWrapper == null) {
|
||||||
|
Log.e(tag, "onPlayFromMediaId: Media item not found $mediaId")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
libraryItemWrapper?.let { li ->
|
libraryItemWrapper?.let { li ->
|
||||||
|
|||||||
Reference in New Issue
Block a user