Browse Source

Fix issue #124 - empty queue on restart.

The Gson deserializer required parameter is a reader object.  It
silently fails when passed a string.
technical/upgrade-exoplayer
Hugh Daschbach 2 years ago committed by Ryan Harg
parent
commit
79e27578e5
  1. 2
      app/src/main/java/audio/funkwhale/ffa/playback/QueueManager.kt
  2. 2
      app/src/main/java/audio/funkwhale/ffa/repositories/AlbumsRepository.kt
  3. 2
      app/src/main/java/audio/funkwhale/ffa/repositories/ArtistTracksRepository.kt
  4. 2
      app/src/main/java/audio/funkwhale/ffa/repositories/ArtistsRepository.kt
  5. 4
      app/src/main/java/audio/funkwhale/ffa/repositories/FavoritesRepository.kt
  6. 2
      app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistTracksRepository.kt
  7. 4
      app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt
  8. 2
      app/src/main/java/audio/funkwhale/ffa/repositories/RadiosRepository.kt
  9. 6
      app/src/main/java/audio/funkwhale/ffa/repositories/SearchRepository.kt
  10. 2
      app/src/main/java/audio/funkwhale/ffa/repositories/TracksRepository.kt

2
app/src/main/java/audio/funkwhale/ffa/playback/QueueManager.kt

@ -29,7 +29,7 @@ class QueueManager(val context: Context) {
init { init {
FFACache.getLine(context, "queue")?.let { json -> FFACache.getLine(context, "queue")?.let { json ->
gsonDeserializerOf(QueueCache::class.java).deserialize(json)?.let { cache -> gsonDeserializerOf(QueueCache::class.java).deserialize(json.reader())?.let { cache ->
metadata = cache.data.toMutableList() metadata = cache.data.toMutableList()
val factory = cacheDataSourceFactoryProvider.create(context) val factory = cacheDataSourceFactoryProvider.create(context)

2
app/src/main/java/audio/funkwhale/ffa/repositories/AlbumsRepository.kt

@ -35,5 +35,5 @@ class AlbumsRepository(override val context: Context?, artistId: Int? = null) :
override fun cache(data: List<Album>) = AlbumsCache(data) override fun cache(data: List<Album>) = AlbumsCache(data)
override fun uncache(json: String) = override fun uncache(json: String) =
gsonDeserializerOf(AlbumsCache::class.java).deserialize(json) gsonDeserializerOf(AlbumsCache::class.java).deserialize(json.reader())
} }

2
app/src/main/java/audio/funkwhale/ffa/repositories/ArtistTracksRepository.kt

@ -27,5 +27,5 @@ class ArtistTracksRepository(override val context: Context?, private val artistI
override fun cache(data: List<Track>) = TracksCache(data) override fun cache(data: List<Track>) = TracksCache(data)
override fun uncache(json: String) = override fun uncache(json: String) =
gsonDeserializerOf(TracksCache::class.java).deserialize(json) gsonDeserializerOf(TracksCache::class.java).deserialize(json.reader())
} }

2
app/src/main/java/audio/funkwhale/ffa/repositories/ArtistsRepository.kt

@ -26,5 +26,5 @@ class ArtistsRepository(override val context: Context?) : Repository<Artist, Art
override fun cache(data: List<Artist>) = ArtistsCache(data) override fun cache(data: List<Artist>) = ArtistsCache(data)
override fun uncache(json: String) = override fun uncache(json: String) =
gsonDeserializerOf(ArtistsCache::class.java).deserialize(json) gsonDeserializerOf(ArtistsCache::class.java).deserialize(json.reader())
} }

4
app/src/main/java/audio/funkwhale/ffa/repositories/FavoritesRepository.kt

@ -34,7 +34,7 @@ class FavoritesRepository(override val context: Context?) : Repository<Track, Tr
override fun cache(data: List<Track>) = TracksCache(data) override fun cache(data: List<Track>) = TracksCache(data)
override fun uncache(json: String) = override fun uncache(json: String) =
gsonDeserializerOf(TracksCache::class.java).deserialize(json) gsonDeserializerOf(TracksCache::class.java).deserialize(json.reader())
private val favoritedRepository = FavoritedRepository(context!!) private val favoritedRepository = FavoritedRepository(context!!)
@ -115,7 +115,7 @@ class FavoritedRepository(override val context: Context?) : Repository<Int, Favo
override fun cache(data: List<Int>) = FavoritedCache(data) override fun cache(data: List<Int>) = FavoritedCache(data)
override fun uncache(json: String) = override fun uncache(json: String) =
gsonDeserializerOf(FavoritedCache::class.java).deserialize(json) gsonDeserializerOf(FavoritedCache::class.java).deserialize(json.reader())
fun update(context: Context?, scope: CoroutineScope) { fun update(context: Context?, scope: CoroutineScope) {
fetch(Origin.Network.origin).untilNetwork(scope, IO) { favorites, _, _, _ -> fetch(Origin.Network.origin).untilNetwork(scope, IO) { favorites, _, _, _ ->

2
app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistTracksRepository.kt

@ -30,7 +30,7 @@ class PlaylistTracksRepository(override val context: Context?, playlistId: Int)
override fun cache(data: List<PlaylistTrack>) = PlaylistTracksCache(data) override fun cache(data: List<PlaylistTrack>) = PlaylistTracksCache(data)
override fun uncache(json: String) = override fun uncache(json: String) =
gsonDeserializerOf(PlaylistTracksCache::class.java).deserialize(json) gsonDeserializerOf(PlaylistTracksCache::class.java).deserialize(json.reader())
override fun onDataFetched(data: List<PlaylistTrack>): List<PlaylistTrack> = runBlocking { override fun onDataFetched(data: List<PlaylistTrack>): List<PlaylistTrack> = runBlocking {
val favorites = FavoritedRepository(context).fetch(Origin.Network.origin) val favorites = FavoritedRepository(context).fetch(Origin.Network.origin)

4
app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt

@ -30,7 +30,7 @@ class PlaylistsRepository(override val context: Context?) : Repository<Playlist,
override fun cache(data: List<Playlist>) = PlaylistsCache(data) override fun cache(data: List<Playlist>) = PlaylistsCache(data)
override fun uncache(json: String) = override fun uncache(json: String) =
gsonDeserializerOf(PlaylistsCache::class.java).deserialize(json) gsonDeserializerOf(PlaylistsCache::class.java).deserialize(json.reader())
} }
class ManagementPlaylistsRepository(override val context: Context?) : class ManagementPlaylistsRepository(override val context: Context?) :
@ -50,7 +50,7 @@ class ManagementPlaylistsRepository(override val context: Context?) :
override fun cache(data: List<Playlist>) = PlaylistsCache(data) override fun cache(data: List<Playlist>) = PlaylistsCache(data)
override fun uncache(json: String) = override fun uncache(json: String) =
gsonDeserializerOf(PlaylistsCache::class.java).deserialize(json) gsonDeserializerOf(PlaylistsCache::class.java).deserialize(json.reader())
suspend fun new(name: String): Int? { suspend fun new(name: String): Int? {
context?.let { context?.let {

2
app/src/main/java/audio/funkwhale/ffa/repositories/RadiosRepository.kt

@ -26,7 +26,7 @@ class RadiosRepository(override val context: Context?) : Repository<Radio, Radio
override fun cache(data: List<Radio>) = RadiosCache(data) override fun cache(data: List<Radio>) = RadiosCache(data)
override fun uncache(json: String) = override fun uncache(json: String) =
gsonDeserializerOf(RadiosCache::class.java).deserialize(json) gsonDeserializerOf(RadiosCache::class.java).deserialize(json.reader())
override fun onDataFetched(data: List<Radio>): List<Radio> { override fun onDataFetched(data: List<Radio>): List<Radio> {
return data return data

6
app/src/main/java/audio/funkwhale/ffa/repositories/SearchRepository.kt

@ -34,7 +34,7 @@ class TracksSearchRepository(override val context: Context?, var query: String)
override fun cache(data: List<Track>) = TracksCache(data) override fun cache(data: List<Track>) = TracksCache(data)
override fun uncache(json: String) = override fun uncache(json: String) =
gsonDeserializerOf(TracksCache::class.java).deserialize(json) gsonDeserializerOf(TracksCache::class.java).deserialize(json.reader())
override fun onDataFetched(data: List<Track>): List<Track> = runBlocking { override fun onDataFetched(data: List<Track>): List<Track> = runBlocking {
val favorites = FavoritedRepository(context).fetch(Origin.Cache.origin) val favorites = FavoritedRepository(context).fetch(Origin.Cache.origin)
@ -76,7 +76,7 @@ class ArtistsSearchRepository(override val context: Context?, var query: String)
override fun cache(data: List<Artist>) = ArtistsCache(data) override fun cache(data: List<Artist>) = ArtistsCache(data)
override fun uncache(json: String) = override fun uncache(json: String) =
gsonDeserializerOf(ArtistsCache::class.java).deserialize(json) gsonDeserializerOf(ArtistsCache::class.java).deserialize(json.reader())
} }
class AlbumsSearchRepository(override val context: Context?, var query: String) : class AlbumsSearchRepository(override val context: Context?, var query: String) :
@ -96,5 +96,5 @@ class AlbumsSearchRepository(override val context: Context?, var query: String)
override fun cache(data: List<Album>) = AlbumsCache(data) override fun cache(data: List<Album>) = AlbumsCache(data)
override fun uncache(json: String) = override fun uncache(json: String) =
gsonDeserializerOf(AlbumsCache::class.java).deserialize(json) gsonDeserializerOf(AlbumsCache::class.java).deserialize(json.reader())
} }

2
app/src/main/java/audio/funkwhale/ffa/repositories/TracksRepository.kt

@ -38,7 +38,7 @@ class TracksRepository(override val context: Context?, albumId: Int) :
override fun cache(data: List<Track>) = TracksCache(data) override fun cache(data: List<Track>) = TracksCache(data)
override fun uncache(json: String) = override fun uncache(json: String) =
gsonDeserializerOf(TracksCache::class.java).deserialize(json) gsonDeserializerOf(TracksCache::class.java).deserialize(json.reader())
companion object { companion object {
fun getDownloadedIds(exoDownloadManager: DownloadManager): List<Int>? { fun getDownloadedIds(exoDownloadManager: DownloadManager): List<Int>? {

Loading…
Cancel
Save