mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-05 02:25:45 +02:00
Fix:Android auto starting items from continue listening #167
This commit is contained in:
parent
25ec5b3dcb
commit
2da272c270
2 changed files with 18 additions and 4 deletions
|
@ -15,7 +15,7 @@ import kotlin.coroutines.suspendCoroutine
|
|||
class MediaManager(var apiHandler: ApiHandler, var ctx: Context) {
|
||||
val tag = "MediaManager"
|
||||
|
||||
var serverLibraryItems = listOf<LibraryItem>()
|
||||
var serverLibraryItems = mutableListOf<LibraryItem>()
|
||||
var selectedLibraryId = ""
|
||||
|
||||
var selectedLibraryItemWrapper:LibraryItemWrapper? = null
|
||||
|
@ -39,7 +39,7 @@ class MediaManager(var apiHandler: ApiHandler, var ctx: Context) {
|
|||
serverPodcastEpisodes = listOf()
|
||||
serverLibraryCategories = listOf()
|
||||
serverLibraries = listOf()
|
||||
serverLibraryItems = listOf()
|
||||
serverLibraryItems = mutableListOf()
|
||||
selectedLibraryId = ""
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,11 @@ class MediaManager(var apiHandler: ApiHandler, var ctx: Context) {
|
|||
val libraryItemsWithAudio = libraryItems.filter { li -> li.checkHasTracks() }
|
||||
if (libraryItemsWithAudio.isNotEmpty()) selectedLibraryId = libraryId
|
||||
|
||||
serverLibraryItems = libraryItemsWithAudio
|
||||
libraryItemsWithAudio.forEach { libraryItem ->
|
||||
if (serverLibraryItems.find { li -> li.id == libraryItem.id } == null) {
|
||||
serverLibraryItems.add(libraryItem)
|
||||
}
|
||||
}
|
||||
cb(libraryItemsWithAudio)
|
||||
}
|
||||
}
|
||||
|
@ -211,6 +215,17 @@ 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}")
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.content.ContentResolver
|
|||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.support.v4.media.MediaMetadataCompat
|
||||
import android.util.Log
|
||||
import androidx.annotation.AnyRes
|
||||
import com.audiobookshelf.app.R
|
||||
import com.audiobookshelf.app.data.Library
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue