This commit is contained in:
Antoine POPINEAU 2020-06-11 00:01:39 +02:00
parent a4b2907c07
commit e50a43a812
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
3 changed files with 9 additions and 10 deletions

View File

@ -2,13 +2,15 @@ package com.github.apognu.otter
import android.app.Application import android.app.Application
import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.app.AppCompatDelegate
import com.github.apognu.otter.utils.* import com.github.apognu.otter.utils.Cache
import com.github.apognu.otter.utils.Command
import com.github.apognu.otter.utils.Event
import com.github.apognu.otter.utils.Request
import com.preference.PowerPreference import com.preference.PowerPreference
import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ConflatedBroadcastChannel import kotlinx.coroutines.channels.ConflatedBroadcastChannel
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.time.format.DateTimeFormatter
import java.util.* import java.util.*
class Otter : Application() { class Otter : Application() {

View File

@ -52,8 +52,7 @@ class MediaControlsManager(val context: Service, private val mediaSession: Media
putLong(MediaMetadata.METADATA_KEY_DURATION, (track.bestUpload()?.duration?.toLong() ?: 0L) * 1000) putLong(MediaMetadata.METADATA_KEY_DURATION, (track.bestUpload()?.duration?.toLong() ?: 0L) * 1000)
cover?.let { cover?.let {
try { putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, it.get()) } try { putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, it.get()) } catch (_: Exception) {}
catch (_: Exception) {}
} }
}.build()) }.build())
@ -71,12 +70,10 @@ class MediaControlsManager(val context: Service, private val mediaSession: Media
.setSmallIcon(R.drawable.ottericon) .setSmallIcon(R.drawable.ottericon)
.run { .run {
if (cover != null) { if (cover != null) {
try { setLargeIcon(cover.get()) } try { setLargeIcon(cover.get()) } catch (_: Exception) {}
catch (_: Exception) {}
this this
} } else this
else this
} }
.setContentTitle(track.title) .setContentTitle(track.title)
.setContentText(track.artist.name) .setContentText(track.artist.name)

View File

@ -10,8 +10,8 @@ import com.google.gson.reflect.TypeToken
import java.io.BufferedReader import java.io.BufferedReader
class ArtistTracksRepository(override val context: Context?, private val artistId: Int) : Repository<Track, TracksCache>() { class ArtistTracksRepository(override val context: Context?, private val artistId: Int) : Repository<Track, TracksCache>() {
override val cacheId = "tracks-artist-${artistId}" override val cacheId = "tracks-artist-$artistId"
override val upstream = HttpUpstream<Track, FunkwhaleResponse<Track>>(HttpUpstream.Behavior.AtOnce, "/api/v1/tracks/?playable=true&artist=${artistId}", object : TypeToken<TracksResponse>() {}.type) override val upstream = HttpUpstream<Track, FunkwhaleResponse<Track>>(HttpUpstream.Behavior.AtOnce, "/api/v1/tracks/?playable=true&artist=$artistId", object : TypeToken<TracksResponse>() {}.type)
override fun cache(data: List<Track>) = TracksCache(data) override fun cache(data: List<Track>) = TracksCache(data)
override fun uncache(reader: BufferedReader) = gsonDeserializerOf(TracksCache::class.java).deserialize(reader) override fun uncache(reader: BufferedReader) = gsonDeserializerOf(TracksCache::class.java).deserialize(reader)