Fix:Android auto library items mixing with other libraries #309

This commit is contained in:
advplyr 2022-08-09 18:50:59 -05:00
parent 34d4a0b61b
commit c1b8f8519f
2 changed files with 5 additions and 15 deletions

View file

@ -95,12 +95,13 @@ class MediaManager(var apiHandler: ApiHandler, var ctx: Context) {
} else {
apiHandler.getLibraryItems(libraryId) { libraryItems ->
val libraryItemsWithAudio = libraryItems.filter { li -> li.checkHasTracks() }
if (libraryItemsWithAudio.isNotEmpty()) selectedLibraryId = libraryId
if (libraryItemsWithAudio.isNotEmpty()) {
selectedLibraryId = libraryId
}
serverLibraryItems = mutableListOf()
libraryItemsWithAudio.forEach { libraryItem ->
if (serverLibraryItems.find { li -> li.id == libraryItem.id } == null) {
serverLibraryItems.add(libraryItem)
}
}
cb(libraryItemsWithAudio)
}
@ -307,17 +308,6 @@ class MediaManager(var apiHandler: ApiHandler, var ctx: Context) {
// Only using book or podcast library categories for now
libraryCategories.forEach {
// Add items in continue listening to serverLibraryItems
if (it.id == "continue-listening") {
it.entities.forEach { libraryItemWrapper ->
val libraryItem = libraryItemWrapper as LibraryItem
if (serverLibraryItems.find { li -> li.id == libraryItem.id } == null) {
serverLibraryItems.add(libraryItem)
}
}
}
// Log.d(tag, "Found library category ${it.label} with type ${it.type}")
if (it.type == library.mediaType) {
// Log.d(tag, "Using library category ${it.id}")

View file

@ -863,7 +863,7 @@ class PlayerNotificationService : MediaBrowserServiceCompat() {
result.sendResult(localBrowseItems)
} else { // Load categories
mediaManager.loadAndroidAutoItems() { libraryCategories ->
mediaManager.loadAndroidAutoItems { libraryCategories ->
browseTree = BrowseTree(this, libraryCategories, mediaManager.serverLibraries)
val children = browseTree[parentMediaId]?.map { item ->