Browse Source

QueueNavigator now returns queue index.

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
e7cb5e4c6e
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 1
      app/src/main/java/com/github/apognu/otter/activities/SearchActivity.kt
  2. 2
      app/src/main/java/com/github/apognu/otter/playback/MediaSession.kt
  3. 25
      app/src/main/java/com/github/apognu/otter/utils/Util.kt

1
app/src/main/java/com/github/apognu/otter/activities/SearchActivity.kt

@ -129,7 +129,6 @@ class SearchActivity : AppCompatActivity() { @@ -129,7 +129,6 @@ class SearchActivity : AppCompatActivity() {
if (download.state == Download.STATE_COMPLETED) {
download.getMetadata()?.let { info ->
adapter.tracks.withIndex().associate { it.value to it.index }.filter { it.key.id == info.id }.toList().getOrNull(0)?.let { match ->
log(match)
withContext(Dispatchers.Main) {
adapter.tracks[match.second].downloaded = true
adapter.notifyItemChanged(adapter.getPositionOf(SearchAdapter.ResultType.Track, match.second))

2
app/src/main/java/com/github/apognu/otter/playback/MediaSession.kt

@ -93,7 +93,7 @@ class OtterQueueNavigator : MediaSessionConnector.QueueNavigator { @@ -93,7 +93,7 @@ class OtterQueueNavigator : MediaSessionConnector.QueueNavigator {
CommandBus.send(Command.NextTrack)
}
override fun getActiveQueueItemId(player: Player?) = 0L
override fun getActiveQueueItemId(player: Player?) = player?.currentWindowIndex?.toLong() ?: 0
override fun onSkipToPrevious(player: Player, controlDispatcher: ControlDispatcher) {
CommandBus.send(Command.PreviousTrack)

25
app/src/main/java/com/github/apognu/otter/utils/Util.kt

@ -12,8 +12,29 @@ fun Context?.toast(message: String, length: Int = Toast.LENGTH_SHORT) { @@ -12,8 +12,29 @@ fun Context?.toast(message: String, length: Int = Toast.LENGTH_SHORT) {
}
}
fun Any.log(message: Any) {
Log.d("OTTER", "${javaClass.simpleName}: $message")
private fun logClassName(): String {
val known = setOf(
"dalvik.system.VMStack",
"java.lang.Thread",
"com.github.apognu.otter.utils.UtilKt"
)
Thread.currentThread().stackTrace.forEach {
if (!known.contains(it.className)) {
val className = it.className.split('.').last()
val line = it.lineNumber
return "$className:$line"
}
}
return "UNKNOWN"
}
fun Any?.log(prefix: String? = null) {
prefix?.let {
Log.d("OTTER", "${logClassName()} - $prefix: $this")
} ?: Log.d("OTTER", "${logClassName()} - $this")
}
fun maybeNormalizeUrl(rawUrl: String?): String? {

Loading…
Cancel
Save