mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 04:52:32 +00:00
A bunch of small bug fixes for things that showed up in Fabric.
This commit is contained in:
parent
1d4544d399
commit
8c408ffed1
@ -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() {
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
@ -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)
|
||||
|
@ -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()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user