A bunch of small bug fixes for things that showed up in Fabric.

This commit is contained in:
casey langen 2018-05-31 08:24:21 -07:00
parent 1d4544d399
commit 8c408ffed1
6 changed files with 38 additions and 6 deletions

View File

@ -16,14 +16,19 @@ import java.util.concurrent.atomic.AtomicLong
val id: Long = nextId.incrementAndGet()
private val publisher by lazy { createSubject() }
var paused = false
private set
interface Provider {
fun <T: ViewModel<*>> createViewModel(): T?
}
open fun onPause() {
paused = true
}
open fun onResume() {
paused = false
}
open fun onDestroy() {

View File

@ -475,7 +475,7 @@ class StreamingPlaybackService(context: Context) : IPlaybackService {
/* failed! reset by loading as if the user selected the next track
manually (this will automatically load the current and next tracks */
val next = resolveNextIndex(index, playContext.queueCount, userInitiated)
if (next >= 0) {
if (next >= 0 && queryContext != null) {
loadQueueAndPlay(queryContext!!, next)
}
else {

View File

@ -25,8 +25,15 @@ class PlayQueueAdapter(val tracks: DefaultSlidingWindow,
val inflater = LayoutInflater.from(parent.context)
val view = inflater.inflate(R.layout.playlist_track_row, parent, false)
val action = view.findViewById<View>(R.id.action)
view.setOnClickListener{ v -> listener.onItemClicked(v.tag as Int) }
action.setOnClickListener{ v -> listener.onActionClicked(v, v.tag as ITrack) }
view.setOnClickListener{ v ->
v.tag?.let { listener.onItemClicked(it as Int) }
}
action.setOnClickListener { v ->
v.tag?.let { listener.onActionClicked(v, it as ITrack) }
}
return ViewHolder(view)
}

View File

@ -226,3 +226,18 @@ fun fallback(input: String?, fallback: Int): String =
fun AppCompatActivity.slideNextUp() = overridePendingTransition(R.anim.slide_up, R.anim.stay_put)
fun AppCompatActivity.slideThisDown() = overridePendingTransition(R.anim.stay_put, R.anim.slide_down)
fun <T1: Any, T2: Any, R: Any> letMany(p1: T1?, p2: T2?, block: (T1, T2) -> R?): R? {
return if (p1 != null && p2 != null) block(p1, p2) else null
}
fun <T1: Any, T2: Any, T3: Any, R: Any> letMany(p1: T1?, p2: T2?, p3: T3?, block: (T1, T2, T3) -> R?): R? {
return if (p1 != null && p2 != null && p3 != null) block(p1, p2, p3) else null
}
fun <T1: Any, T2: Any, T3: Any, T4: Any, R: Any> letMany(p1: T1?, p2: T2?, p3: T3?, p4: T4?, block: (T1, T2, T3, T4)->R?): R? {
return if (p1 != null && p2 != null && p3 != null && p4 != null) block(p1, p2, p3, p4) else null
}
fun <T1: Any, T2: Any, T3: Any, T4: Any, T5: Any, R: Any> letMany(p1: T1?, p2: T2?, p3: T3?, p4: T4?, p5: T5?, block: (T1, T2, T3, T4, T5)->R?): R? {
return if (p1 != null && p2 != null && p3 != null && p4 != null && p5 != null) block(p1, p2, p3, p4, p5) else null
}

View File

@ -9,6 +9,7 @@ import io.casey.musikcube.remote.R
import io.casey.musikcube.remote.service.websocket.model.ITrack
import io.casey.musikcube.remote.ui.shared.extension.fallback
import io.casey.musikcube.remote.ui.shared.extension.getColorCompat
import io.casey.musikcube.remote.ui.shared.extension.letMany
import io.casey.musikcube.remote.ui.shared.mixin.PlaybackMixin
import io.casey.musikcube.remote.ui.shared.model.DefaultSlidingWindow
@ -30,12 +31,16 @@ class TrackListAdapter(private val tracks: DefaultSlidingWindow,
view.setOnClickListener({ v ->
val tag = v.tag as Tag
listener?.onItemClick(v, tag.track!!, tag.position!!)
letMany(listener, tag.track, tag.position) { listener, track, pos ->
listener.onItemClick(v, track, pos)
}
})
view.findViewById<View>(R.id.action).setOnClickListener({ v ->
val tag = v.tag as Tag
listener?.onActionItemClick(v, tag.track!!, tag.position!!)
letMany(listener, tag.track, tag.position) { listener, track, position ->
listener.onActionItemClick(v, track, position)
}
})
return ViewHolder(view, playback)

View File

@ -46,7 +46,7 @@ class EditPlaylistViewModel(private val playlistId: Long): ViewModel<EditPlaylis
val count: Int
get() {
if (externalIds.isEmpty() && status != Status.Loading) {
if (!paused && externalIds.isEmpty() && status != Status.Loading) {
if (!modified) {
refreshTrackIds()
}