mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-29 19:20:28 +00:00
More lint and warning cleanup. There's more code in here than I
remember.
This commit is contained in:
parent
9e4be0ff80
commit
fff7d83338
@ -1,48 +1,49 @@
|
||||
package io.casey.musikcube.remote.service.playback.impl.remote
|
||||
|
||||
object Metadata {
|
||||
interface Track {
|
||||
companion object {
|
||||
val ID = "id"
|
||||
val EXTERNAL_ID = "external_id"
|
||||
val URI = "uri"
|
||||
val TITLE = "title"
|
||||
val ALBUM = "album"
|
||||
val ALBUM_ID = "album_id"
|
||||
val ALBUM_ARTIST = "album_artist"
|
||||
val ALBUM_ARTIST_ID = "album_artist_id"
|
||||
val GENRE = "genre"
|
||||
val TRACK_NUM = "track_num"
|
||||
val GENRE_ID = "genre_id"
|
||||
val ARTIST = "artist"
|
||||
val ARTIST_ID = "artist_id"
|
||||
val THUMBNAIL_ID = "thumbnail_id"
|
||||
}
|
||||
object Track {
|
||||
const val ID = "id"
|
||||
const val EXTERNAL_ID = "external_id"
|
||||
const val URI = "uri"
|
||||
const val TITLE = "title"
|
||||
const val ALBUM = "album"
|
||||
const val ALBUM_ID = "album_id"
|
||||
const val ALBUM_ARTIST = "album_artist"
|
||||
const val ALBUM_ARTIST_ID = "album_artist_id"
|
||||
const val GENRE = "genre"
|
||||
const val TRACK_NUM = "track_num"
|
||||
const val GENRE_ID = "genre_id"
|
||||
const val ARTIST = "artist"
|
||||
const val ARTIST_ID = "artist_id"
|
||||
const val THUMBNAIL_ID = "thumbnail_id"
|
||||
}
|
||||
|
||||
interface Album {
|
||||
companion object {
|
||||
val ID = "id"
|
||||
val TITLE = "title"
|
||||
val ALBUM_ARTIST = "album_artist"
|
||||
val ALBUM_ARTIST_ID = "album_artist_id"
|
||||
val ARTIST = "artist"
|
||||
val ARTIST_ID = "artist_id"
|
||||
val THUMBNAIL_ID = "thumbnail_id"
|
||||
}
|
||||
object Album {
|
||||
const val ID = "id"
|
||||
const val TITLE = "title"
|
||||
const val ALBUM_ARTIST = "album_artist"
|
||||
const val ALBUM_ARTIST_ID = "album_artist_id"
|
||||
const val ARTIST = "artist"
|
||||
const val ARTIST_ID = "artist_id"
|
||||
const val THUMBNAIL_ID = "thumbnail_id"
|
||||
}
|
||||
|
||||
interface Output {
|
||||
companion object {
|
||||
val DRIVER_NAME = "driver_name"
|
||||
val DEVICES = "devices"
|
||||
}
|
||||
object Category {
|
||||
const val OFFLINE = "offline"
|
||||
const val ALBUM = "album"
|
||||
const val ARTIST = "artist"
|
||||
const val ALBUM_ARTIST = "album_artist"
|
||||
const val GENRE = "genre"
|
||||
const val PLAYLISTS = "playlists"
|
||||
}
|
||||
|
||||
interface Device {
|
||||
companion object {
|
||||
val DEVICE_NAME = "device_name"
|
||||
val DEVICE_ID = "device_id"
|
||||
}
|
||||
object Output {
|
||||
const val DRIVER_NAME = "driver_name"
|
||||
const val DEVICES = "devices"
|
||||
}
|
||||
|
||||
object Device {
|
||||
const val DEVICE_NAME = "device_name"
|
||||
const val DEVICE_ID = "device_id"
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import io.casey.musikcube.remote.Application
|
||||
import io.casey.musikcube.remote.R
|
||||
import io.casey.musikcube.remote.injection.DaggerServiceComponent
|
||||
import io.casey.musikcube.remote.service.playback.*
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
import io.casey.musikcube.remote.service.system.SystemService
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.websocket.model.IDataProvider
|
||||
@ -813,7 +814,7 @@ class StreamingPlaybackService(context: Context) : IPlaybackService {
|
||||
}
|
||||
|
||||
override fun offline(): Boolean {
|
||||
return queryContext?.category == Messages.Category.OFFLINE
|
||||
return queryContext?.category == Metadata.Category.OFFLINE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import android.arch.persistence.room.Database
|
||||
import android.arch.persistence.room.RoomDatabase
|
||||
import io.casey.musikcube.remote.Application
|
||||
import io.casey.musikcube.remote.injection.DaggerDataComponent
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
import io.casey.musikcube.remote.service.playback.impl.streaming.StreamProxy
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.websocket.SocketMessage
|
||||
@ -27,17 +28,17 @@ abstract class OfflineDb : RoomDatabase() {
|
||||
.appComponent(Application.appComponent)
|
||||
.build().inject(this)
|
||||
|
||||
wss.addInterceptor({ message, responder ->
|
||||
wss.addInterceptor{ message, responder ->
|
||||
var result = false
|
||||
if (Messages.Request.QueryTracksByCategory.matches(message.name)) {
|
||||
val category = message.getStringOption(Messages.Key.CATEGORY)
|
||||
if (Messages.Category.OFFLINE == category) {
|
||||
if (Metadata.Category.OFFLINE == category) {
|
||||
queryTracks(message, responder)
|
||||
result = true
|
||||
}
|
||||
}
|
||||
result
|
||||
})
|
||||
}
|
||||
|
||||
prune()
|
||||
}
|
||||
@ -45,6 +46,7 @@ abstract class OfflineDb : RoomDatabase() {
|
||||
abstract fun trackDao(): OfflineTrackDao
|
||||
|
||||
fun prune() {
|
||||
@Suppress("unused")
|
||||
Single.fromCallable {
|
||||
val uris = trackDao().queryUris()
|
||||
val toDelete = ArrayList<String>()
|
||||
@ -63,7 +65,7 @@ abstract class OfflineDb : RoomDatabase() {
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ _ -> }, { })
|
||||
.subscribe({ }, { })
|
||||
}
|
||||
|
||||
private fun queryTracks(message: SocketMessage, responder: WebSocketService.Responder) {
|
||||
|
@ -127,15 +127,4 @@ class Messages {
|
||||
const val REBUILD = "rebuild"
|
||||
}
|
||||
}
|
||||
|
||||
interface Category {
|
||||
companion object {
|
||||
const val OFFLINE = "offline"
|
||||
const val ALBUM = "album"
|
||||
const val ARTIST = "artist"
|
||||
const val ALBUM_ARTIST = "album_artist"
|
||||
const val GENRE = "genre"
|
||||
const val PLAYLISTS = "playlists"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.casey.musikcube.remote.service.websocket.model.impl.remote
|
||||
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.websocket.model.IAlbum
|
||||
import org.json.JSONObject
|
||||
|
||||
@ -14,5 +13,5 @@ class RemoteAlbum(val json: JSONObject) : IAlbum {
|
||||
override val albumArtist: String get() = json.optString(Metadata.Album.ALBUM_ARTIST, "")
|
||||
override val albumArtistId: Long get() = json.optLong(Metadata.Album.ALBUM_ARTIST_ID, -1)
|
||||
override val thumbnailId: Long get() = json.optLong(Metadata.Album.THUMBNAIL_ID, -1)
|
||||
override val type: String get() = Messages.Category.ALBUM
|
||||
override val type: String get() = Metadata.Category.ALBUM
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package io.casey.musikcube.remote.service.websocket.model.impl.remote
|
||||
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.websocket.model.IAlbumArtist
|
||||
import org.json.JSONObject
|
||||
@ -10,5 +11,5 @@ class RemoteAlbumArtist(private val json: JSONObject) : IAlbumArtist {
|
||||
override val value: String
|
||||
get() = json.optString(Messages.Key.VALUE, "")
|
||||
override val type: String
|
||||
get() = Messages.Category.ALBUM_ARTIST
|
||||
get() = Metadata.Category.ALBUM_ARTIST
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package io.casey.musikcube.remote.service.websocket.model.impl.remote
|
||||
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.websocket.SocketMessage
|
||||
import io.casey.musikcube.remote.service.websocket.WebSocketService
|
||||
@ -94,7 +95,7 @@ class RemoteDataProvider(private val service: WebSocketService) : IDataProvider
|
||||
.flatMap<Map<String, ITrack>> { socketMessage ->
|
||||
val tracks = HashMap<String, ITrack>()
|
||||
val json = socketMessage.getJsonObjectOption(Messages.Key.DATA, JSONObject())!!
|
||||
json.keys().forEach { tracks.put(it, RemoteTrack(json.getJSONObject(it))) }
|
||||
json.keys().forEach { tracks[it] = RemoteTrack(json.getJSONObject(it)) }
|
||||
Observable.just(tracks)
|
||||
}
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -213,6 +214,7 @@ class RemoteDataProvider(private val service: WebSocketService) : IDataProvider
|
||||
.request(Messages.Request.InvalidatePlayQueueSnapshot)
|
||||
.build()
|
||||
|
||||
@Suppress("unused")
|
||||
service.observe(message, client)
|
||||
.flatMap<Boolean> { socketMessage -> isSuccessful(socketMessage) }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@ -239,13 +241,13 @@ class RemoteDataProvider(private val service: WebSocketService) : IDataProvider
|
||||
override fun getPlaylists(): Observable<List<IPlaylist>> {
|
||||
val message = SocketMessage.Builder
|
||||
.request(Messages.Request.QueryCategory)
|
||||
.addOption(Messages.Key.CATEGORY, Messages.Category.PLAYLISTS)
|
||||
.addOption(Messages.Key.CATEGORY, Metadata.Category.PLAYLISTS)
|
||||
.build()
|
||||
|
||||
return service.observe(message, client)
|
||||
.observeOn(Schedulers.computation())
|
||||
.flatMap<List<ICategoryValue>> { socketMessage ->
|
||||
toCategoryList(socketMessage, Messages.Category.PLAYLISTS)
|
||||
toCategoryList(socketMessage, Metadata.Category.PLAYLISTS)
|
||||
}
|
||||
.flatMap { values ->
|
||||
Observable.just(values.filterIsInstance<IPlaylist>())
|
||||
@ -634,8 +636,8 @@ class RemoteDataProvider(private val service: WebSocketService) : IDataProvider
|
||||
|
||||
private fun toCategoryList(socketMessage: SocketMessage, type: String): Observable<List<ICategoryValue>> {
|
||||
val converter: (JSONObject, String) -> ICategoryValue = when (type) {
|
||||
Messages.Category.ALBUM_ARTIST -> toAlbumArtist
|
||||
Messages.Category.PLAYLISTS -> toPlaylist
|
||||
Metadata.Category.ALBUM_ARTIST -> toAlbumArtist
|
||||
Metadata.Category.PLAYLISTS -> toPlaylist
|
||||
else -> toCategoryValue
|
||||
}
|
||||
val values = ArrayList<ICategoryValue>()
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.casey.musikcube.remote.service.websocket.model.impl.remote
|
||||
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.websocket.model.IPlaylist
|
||||
import org.json.JSONObject
|
||||
@ -10,5 +11,5 @@ class RemotePlaylist(private val json: JSONObject) : IPlaylist {
|
||||
override val value: String
|
||||
get() = json.optString(Messages.Key.VALUE, "")
|
||||
override val type: String
|
||||
get() = Messages.Category.PLAYLISTS
|
||||
get() = Metadata.Category.PLAYLISTS
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package io.casey.musikcube.remote.service.websocket.model.impl.remote
|
||||
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.websocket.model.ITrack
|
||||
import org.json.JSONObject
|
||||
|
||||
@ -47,10 +46,10 @@ class RemoteTrack(val json: JSONObject) : ITrack {
|
||||
|
||||
companion object {
|
||||
private val CATEGORY_NAME_TO_ID: Map<String, String> = mapOf(
|
||||
Messages.Category.ALBUM_ARTIST to Metadata.Track.ALBUM_ARTIST_ID,
|
||||
Messages.Category.GENRE to Metadata.Track.GENRE_ID,
|
||||
Messages.Category.ARTIST to Metadata.Track.ARTIST_ID,
|
||||
Messages.Category.ALBUM to Metadata.Track.ALBUM_ID,
|
||||
Messages.Category.PLAYLISTS to Metadata.Track.ALBUM_ID)
|
||||
Metadata.Category.ALBUM_ARTIST to Metadata.Track.ALBUM_ARTIST_ID,
|
||||
Metadata.Category.GENRE to Metadata.Track.GENRE_ID,
|
||||
Metadata.Category.ARTIST to Metadata.Track.ARTIST_ID,
|
||||
Metadata.Category.ALBUM to Metadata.Track.ALBUM_ID,
|
||||
Metadata.Category.PLAYLISTS to Metadata.Track.ALBUM_ID)
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ 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.titleEllipsizeMode
|
||||
import io.casey.musikcube.remote.ui.shared.mixin.PlaybackMixin
|
||||
import io.casey.musikcube.remote.ui.shared.util.Size
|
||||
import io.casey.musikcube.remote.ui.shared.util.AlbumArtLookup.getUrl
|
||||
import io.casey.musikcube.remote.ui.shared.util.Size
|
||||
|
||||
class AlbumBrowseAdapter(private val listener: EventListener,
|
||||
private val playback: PlaybackMixin,
|
||||
|
@ -7,7 +7,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import io.casey.musikcube.remote.R
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
import io.casey.musikcube.remote.service.websocket.model.IAlbum
|
||||
import io.casey.musikcube.remote.service.websocket.model.IDataProvider
|
||||
import io.casey.musikcube.remote.ui.albums.adapter.AlbumBrowseAdapter
|
||||
@ -114,7 +114,7 @@ class AlbumBrowseFragment: BaseFragment(), Filterable, TitleProvider {
|
||||
private val eventListener = object: AlbumBrowseAdapter.EventListener {
|
||||
override fun onItemClicked(album: IAlbum) =
|
||||
startActivity(TrackListActivity.getStartIntent(
|
||||
appCompatActivity, Messages.Category.ALBUM, album.id, album.value))
|
||||
appCompatActivity, Metadata.Category.ALBUM, album.id, album.value))
|
||||
|
||||
override fun onActionClicked(view: View, album: IAlbum) {
|
||||
mixin(ItemContextMenuMixin::class.java)?.showForCategory(album, view)
|
||||
|
@ -2,7 +2,7 @@ package io.casey.musikcube.remote.ui.category.constant
|
||||
|
||||
import android.content.Context
|
||||
import io.casey.musikcube.remote.R
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
|
||||
private val categoryToStringIdMap = mapOf(
|
||||
"album" to R.string.category_artist,
|
||||
@ -19,24 +19,24 @@ private val categoryToStringIdMap = mapOf(
|
||||
|
||||
object Category {
|
||||
val NAME_TO_TITLE: Map<String, Int> = mapOf(
|
||||
Messages.Category.ALBUM_ARTIST to R.string.artists_title,
|
||||
Messages.Category.GENRE to R.string.genres_title,
|
||||
Messages.Category.ARTIST to R.string.artists_title,
|
||||
Messages.Category.ALBUM to R.string.albums_title,
|
||||
Messages.Category.PLAYLISTS to R.string.playlists_title)
|
||||
Metadata.Category.ALBUM_ARTIST to R.string.artists_title,
|
||||
Metadata.Category.GENRE to R.string.genres_title,
|
||||
Metadata.Category.ARTIST to R.string.artists_title,
|
||||
Metadata.Category.ALBUM to R.string.albums_title,
|
||||
Metadata.Category.PLAYLISTS to R.string.playlists_title)
|
||||
|
||||
val NAME_TO_RELATED_TITLE: Map<String, Int> = mapOf(
|
||||
Messages.Category.ALBUM_ARTIST to R.string.artists_from_category,
|
||||
Messages.Category.GENRE to R.string.genres_from_category,
|
||||
Messages.Category.ARTIST to R.string.artists_from_category,
|
||||
Messages.Category.ALBUM to R.string.albums_by_title)
|
||||
Metadata.Category.ALBUM_ARTIST to R.string.artists_from_category,
|
||||
Metadata.Category.GENRE to R.string.genres_from_category,
|
||||
Metadata.Category.ARTIST to R.string.artists_from_category,
|
||||
Metadata.Category.ALBUM to R.string.albums_by_title)
|
||||
|
||||
val NAME_TO_EMPTY_TYPE: Map<String, Int> = mapOf(
|
||||
Messages.Category.ALBUM_ARTIST to R.string.browse_type_artists,
|
||||
Messages.Category.GENRE to R.string.browse_type_genres,
|
||||
Messages.Category.ARTIST to R.string.browse_type_artists,
|
||||
Messages.Category.ALBUM to R.string.browse_type_albums,
|
||||
Messages.Category.PLAYLISTS to R.string.browse_type_playlists)
|
||||
Metadata.Category.ALBUM_ARTIST to R.string.browse_type_artists,
|
||||
Metadata.Category.GENRE to R.string.browse_type_genres,
|
||||
Metadata.Category.ARTIST to R.string.browse_type_artists,
|
||||
Metadata.Category.ALBUM to R.string.browse_type_albums,
|
||||
Metadata.Category.PLAYLISTS to R.string.browse_type_playlists)
|
||||
|
||||
fun toDisplayString(context: Context, category: String): String {
|
||||
categoryToStringIdMap[category]?.let {
|
||||
|
@ -10,7 +10,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import io.casey.musikcube.remote.R
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
import io.casey.musikcube.remote.service.websocket.model.ICategoryValue
|
||||
import io.casey.musikcube.remote.service.websocket.model.IDataProvider
|
||||
import io.casey.musikcube.remote.ui.albums.activity.AlbumBrowseActivity
|
||||
@ -76,7 +76,7 @@ class CategoryBrowseFragment: BaseFragment(), Filterable, TitleProvider {
|
||||
|
||||
val recyclerView = findViewById<FastScrollRecyclerView>(R.id.recycler_view)
|
||||
val fab = findViewById<View>(R.id.fab)
|
||||
val fabVisible = (category == Messages.Category.PLAYLISTS)
|
||||
val fabVisible = (category == Metadata.Category.PLAYLISTS)
|
||||
|
||||
emptyView = findViewById(R.id.empty_list_view)
|
||||
emptyView.capability = EmptyListView.Capability.OnlineOnly
|
||||
@ -84,7 +84,7 @@ class CategoryBrowseFragment: BaseFragment(), Filterable, TitleProvider {
|
||||
emptyView.alternateView = recyclerView
|
||||
|
||||
findViewById<View>(R.id.fab).setOnClickListener {
|
||||
if (category == Messages.Category.PLAYLISTS) {
|
||||
if (category == Metadata.Category.PLAYLISTS) {
|
||||
mixin(ItemContextMenuMixin::class.java)?.createPlaylist()
|
||||
}
|
||||
}
|
||||
@ -104,7 +104,7 @@ class CategoryBrowseFragment: BaseFragment(), Filterable, TitleProvider {
|
||||
}
|
||||
|
||||
fun createOptionsMenu(menu: Menu): Boolean {
|
||||
when (Messages.Category.PLAYLISTS == category) {
|
||||
when (Metadata.Category.PLAYLISTS == category) {
|
||||
true -> menu.clear()
|
||||
else -> initSearchMenu(menu, this)
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import io.casey.musikcube.remote.R
|
||||
import io.casey.musikcube.remote.service.playback.Playback
|
||||
import io.casey.musikcube.remote.service.playback.PlaybackState
|
||||
import io.casey.musikcube.remote.service.playback.RepeatMode
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
import io.casey.musikcube.remote.service.websocket.WebSocketService
|
||||
import io.casey.musikcube.remote.service.websocket.model.IDataProvider
|
||||
import io.casey.musikcube.remote.ui.albums.activity.AlbumBrowseActivity
|
||||
@ -141,7 +141,7 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
popup.inflate(menuId)
|
||||
|
||||
popup.setOnMenuItemClickListener { it ->
|
||||
popup.setOnMenuItemClickListener {
|
||||
when(it.itemId) {
|
||||
R.id.menu_switch_seamless -> togglePlaybackService(Playback.SwitchMode.Transfer)
|
||||
R.id.menu_switch_copy -> togglePlaybackService(Playback.SwitchMode.Copy)
|
||||
@ -285,9 +285,11 @@ class MainActivity : BaseActivity() {
|
||||
totalTime = findViewById(R.id.total_time)
|
||||
seekbar = findViewById(R.id.seekbar)
|
||||
|
||||
findViewById<View>(R.id.button_prev).setOnClickListener { _: View -> playback.service.prev() }
|
||||
findViewById<View>(R.id.button_prev).setOnClickListener {
|
||||
playback.service.prev()
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.button_play_pause).setOnClickListener { _: View ->
|
||||
findViewById<View>(R.id.button_play_pause).setOnClickListener {
|
||||
if (playback.service.state === PlaybackState.Stopped) {
|
||||
playback.service.playAll()
|
||||
}
|
||||
@ -296,9 +298,13 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.button_next).setOnClickListener { _: View -> playback.service.next() }
|
||||
findViewById<View>(R.id.button_next).setOnClickListener {
|
||||
playback.service.next()
|
||||
}
|
||||
|
||||
disconnectedButton.setOnClickListener { _ -> data.wss.reconnect() }
|
||||
disconnectedButton.setOnClickListener {
|
||||
data.wss.reconnect()
|
||||
}
|
||||
|
||||
seekbar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
@ -319,41 +325,45 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
})
|
||||
|
||||
findViewById<View>(R.id.button_artists).setOnClickListener { _: View ->
|
||||
findViewById<View>(R.id.button_artists).setOnClickListener {
|
||||
startActivity(CategoryBrowseActivity
|
||||
.getStartIntent(this, Messages.Category.ALBUM_ARTIST))
|
||||
.getStartIntent(this, Metadata.Category.ALBUM_ARTIST))
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.button_tracks).setOnClickListener { _: View ->
|
||||
findViewById<View>(R.id.button_tracks).setOnClickListener {
|
||||
startActivity(TrackListActivity.getStartIntent(this@MainActivity))
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.button_albums).setOnClickListener { _: View ->
|
||||
findViewById<View>(R.id.button_albums).setOnClickListener {
|
||||
startActivity(AlbumBrowseActivity.getStartIntent(this@MainActivity))
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.button_albums).setOnClickListener { _: View ->
|
||||
findViewById<View>(R.id.button_albums).setOnClickListener {
|
||||
startActivity(AlbumBrowseActivity.getStartIntent(this@MainActivity))
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.button_playlists).setOnClickListener {
|
||||
startActivity(CategoryBrowseActivity.getStartIntent(
|
||||
this, Messages.Category.PLAYLISTS, NavigationType.Tracks))
|
||||
this, Metadata.Category.PLAYLISTS, NavigationType.Tracks))
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.button_play_queue).setOnClickListener { _ -> navigateToPlayQueue() }
|
||||
findViewById<View>(R.id.button_play_queue).setOnClickListener {
|
||||
navigateToPlayQueue()
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.metadata_container).setOnClickListener { _ ->
|
||||
findViewById<View>(R.id.metadata_container).setOnClickListener {
|
||||
if (playback.service.queueCount > 0) {
|
||||
navigateToPlayQueue()
|
||||
}
|
||||
}
|
||||
|
||||
disconnectedOverlay.setOnClickListener { _ ->
|
||||
disconnectedOverlay.setOnClickListener {
|
||||
/* swallow input so user can't click on things while disconnected */
|
||||
}
|
||||
|
||||
showOfflineButton.setOnClickListener { _ -> onOfflineTracksSelected() }
|
||||
showOfflineButton.setOnClickListener {
|
||||
onOfflineTracksSelected()
|
||||
}
|
||||
}
|
||||
|
||||
private fun rebindUi() {
|
||||
|
@ -165,20 +165,21 @@ class MainMetadataView : FrameLayout {
|
||||
|
||||
private fun setMetadataDisplayMode(mode: DisplayMode) {
|
||||
lastDisplayMode = mode
|
||||
|
||||
if (mode == DisplayMode.Stopped) {
|
||||
albumArtImageView.setImageDrawable(null)
|
||||
mainTrackMetadataWithAlbumArt.visibility = View.GONE
|
||||
mainTrackMetadataNoAlbumArt.visibility = View.GONE
|
||||
}
|
||||
else if (mode == DisplayMode.Artwork) {
|
||||
mainTrackMetadataWithAlbumArt.visibility = View.VISIBLE
|
||||
mainTrackMetadataNoAlbumArt.visibility = View.GONE
|
||||
}
|
||||
else {
|
||||
albumArtImageView.setImageDrawable(null)
|
||||
mainTrackMetadataWithAlbumArt.visibility = View.GONE
|
||||
mainTrackMetadataNoAlbumArt.visibility = View.VISIBLE
|
||||
when (mode) {
|
||||
DisplayMode.Stopped -> {
|
||||
albumArtImageView.setImageDrawable(null)
|
||||
mainTrackMetadataWithAlbumArt.visibility = View.GONE
|
||||
mainTrackMetadataNoAlbumArt.visibility = View.GONE
|
||||
}
|
||||
DisplayMode.Artwork -> {
|
||||
mainTrackMetadataWithAlbumArt.visibility = View.VISIBLE
|
||||
mainTrackMetadataNoAlbumArt.visibility = View.GONE
|
||||
}
|
||||
else -> {
|
||||
albumArtImageView.setImageDrawable(null)
|
||||
mainTrackMetadataWithAlbumArt.visibility = View.GONE
|
||||
mainTrackMetadataNoAlbumArt.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,8 +314,8 @@ class MainMetadataView : FrameLayout {
|
||||
this.mainTrackMetadataNoAlbumArt = findViewById(R.id.main_track_metadata_without_art)
|
||||
this.albumArtImageView = findViewById(R.id.album_art)
|
||||
|
||||
this.album.setOnClickListener { _ -> navigateToCurrentAlbum() }
|
||||
this.artist.setOnClickListener { _ -> navigateToCurrentArtist() }
|
||||
this.album.setOnClickListener { navigateToCurrentAlbum() }
|
||||
this.artist.setOnClickListener { navigateToCurrentArtist() }
|
||||
}
|
||||
|
||||
private fun navigateToCurrentArtist() {
|
||||
@ -325,7 +326,7 @@ class MainMetadataView : FrameLayout {
|
||||
if (artistId != -1L) {
|
||||
val artistName = fallback(playing.artist, "")
|
||||
context.startActivity(AlbumBrowseActivity.getStartIntent(
|
||||
context, Messages.Category.ARTIST, artistId, artistName))
|
||||
context, Metadata.Category.ARTIST, artistId, artistName))
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,7 +338,7 @@ class MainMetadataView : FrameLayout {
|
||||
if (albumId != -1L) {
|
||||
val albumName = fallback(playing.album, "")
|
||||
context.startActivity(TrackListActivity.getStartIntent(
|
||||
context, Messages.Category.ALBUM, albumId, albumName))
|
||||
context, Metadata.Category.ALBUM, albumId, albumName))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ import io.casey.musikcube.remote.ui.settings.model.Connection
|
||||
import io.casey.musikcube.remote.ui.settings.model.ConnectionsDb
|
||||
import io.casey.musikcube.remote.ui.shared.activity.BaseActivity
|
||||
import io.casey.musikcube.remote.ui.shared.extension.*
|
||||
import java.lang.IllegalArgumentException
|
||||
import javax.inject.Inject
|
||||
|
||||
private const val EXTRA_CONNECTION = "extra_connection"
|
||||
|
@ -24,7 +24,6 @@ import io.casey.musikcube.remote.ui.shared.activity.BaseActivity
|
||||
import io.casey.musikcube.remote.ui.shared.extension.*
|
||||
import io.casey.musikcube.remote.ui.shared.mixin.DataProviderMixin
|
||||
import io.casey.musikcube.remote.ui.shared.mixin.PlaybackMixin
|
||||
import java.lang.IllegalArgumentException
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import io.casey.musikcube.remote.ui.settings.constants.Prefs.Default as Defaults
|
||||
|
@ -15,7 +15,7 @@ import io.casey.musikcube.remote.R
|
||||
import io.casey.musikcube.remote.framework.MixinBase
|
||||
import io.casey.musikcube.remote.injection.DaggerViewComponent
|
||||
import io.casey.musikcube.remote.service.playback.PlaybackServiceFactory
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
import io.casey.musikcube.remote.service.websocket.model.IAlbum
|
||||
import io.casey.musikcube.remote.service.websocket.model.ICategoryValue
|
||||
import io.casey.musikcube.remote.service.websocket.model.IDataProvider
|
||||
@ -108,6 +108,7 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
EnterPlaylistNameDialog.showForCreate(activity, this)
|
||||
|
||||
fun createPlaylist(playlistName: String) {
|
||||
@Suppress("ununsed")
|
||||
provider.createPlaylist(playlistName).subscribeBy(
|
||||
onNext = { id ->
|
||||
if (id > 0L) {
|
||||
@ -124,6 +125,7 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
}
|
||||
|
||||
fun renamePlaylist(newName: String, id: Long) {
|
||||
@Suppress("unused")
|
||||
provider.renamePlaylist(id, newName).subscribeBy(
|
||||
onNext = { success ->
|
||||
if (success) {
|
||||
@ -156,12 +158,13 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
|
||||
private fun viewPlaylist(playlistId: Long, playlistName: String): ((View) -> Unit) = { _ ->
|
||||
activity.startActivity(TrackListActivity.getStartIntent(
|
||||
activity, Messages.Category.PLAYLISTS, playlistId, playlistName))
|
||||
activity, Metadata.Category.PLAYLISTS, playlistId, playlistName))
|
||||
}
|
||||
|
||||
private fun addWithErrorHandler(playlistId: Long, playlistName: String, observable: Observable<Boolean>) {
|
||||
val error = R.string.playlist_edit_add_error
|
||||
|
||||
@Suppress("unused")
|
||||
observable.subscribeBy(
|
||||
onNext = { success ->
|
||||
if (success) {
|
||||
@ -185,7 +188,7 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
|
||||
val intent = CategoryBrowseActivity.getStartIntent(
|
||||
activity,
|
||||
Messages.Category.PLAYLISTS,
|
||||
Metadata.Category.PLAYLISTS,
|
||||
NavigationType.Select,
|
||||
activity.getString(R.string.playlist_edit_pick_playlist))
|
||||
|
||||
@ -221,11 +224,11 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
}
|
||||
R.id.menu_show_artist_albums -> {
|
||||
AlbumBrowseActivity.getStartIntent(
|
||||
activity, Messages.Category.ARTIST, track.artistId, track.artist)
|
||||
activity, Metadata.Category.ARTIST, track.artistId, track.artist)
|
||||
}
|
||||
R.id.menu_show_artist_tracks -> {
|
||||
TrackListActivity.getStartIntent(
|
||||
activity, Messages.Category.ARTIST, track.artistId, track.artist)
|
||||
activity, Metadata.Category.ARTIST, track.artistId, track.artist)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
@ -258,7 +261,7 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
}
|
||||
R.id.menu_playlist_play -> {
|
||||
val playback = PlaybackServiceFactory.instance(Application.instance)
|
||||
playback.play(Messages.Category.PLAYLISTS, playlistId)
|
||||
playback.play(Metadata.Category.PLAYLISTS, playlistId)
|
||||
}
|
||||
}
|
||||
true
|
||||
@ -268,15 +271,15 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
}
|
||||
|
||||
fun showForCategory(value: ICategoryValue, anchorView: View) {
|
||||
if (value.type == Messages.Category.PLAYLISTS) {
|
||||
if (value.type == Metadata.Category.PLAYLISTS) {
|
||||
showForPlaylist(value.value, value.id, anchorView)
|
||||
}
|
||||
else {
|
||||
val menuId = when (value.type) {
|
||||
Messages.Category.ARTIST -> R.menu.artist_item_context_menu
|
||||
Messages.Category.ALBUM_ARTIST -> R.menu.artist_item_context_menu
|
||||
Messages.Category.ALBUM -> R.menu.album_item_context_menu
|
||||
Messages.Category.GENRE -> R.menu.genre_item_context_menu
|
||||
Metadata.Category.ARTIST -> R.menu.artist_item_context_menu
|
||||
Metadata.Category.ALBUM_ARTIST -> R.menu.artist_item_context_menu
|
||||
Metadata.Category.ALBUM -> R.menu.album_item_context_menu
|
||||
Metadata.Category.GENRE -> R.menu.genre_item_context_menu
|
||||
else -> -1
|
||||
}
|
||||
|
||||
@ -295,7 +298,7 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
if (value is IAlbum) {
|
||||
AlbumBrowseActivity.getStartIntent(
|
||||
activity,
|
||||
Messages.Category.ALBUM_ARTIST,
|
||||
Metadata.Category.ALBUM_ARTIST,
|
||||
value.albumArtistId,
|
||||
value.albumArtist)
|
||||
}
|
||||
@ -309,7 +312,7 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
if (value is IAlbum) {
|
||||
TrackListActivity.getStartIntent(
|
||||
activity,
|
||||
Messages.Category.ALBUM_ARTIST,
|
||||
Metadata.Category.ALBUM_ARTIST,
|
||||
value.albumArtistId,
|
||||
value.albumArtist)
|
||||
}
|
||||
@ -320,11 +323,11 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
}
|
||||
R.id.menu_show_artist_genres -> {
|
||||
CategoryBrowseActivity.getStartIntent(
|
||||
activity, Messages.Category.GENRE, value.type, value.id, value.value)
|
||||
activity, Metadata.Category.GENRE, value.type, value.id, value.value)
|
||||
}
|
||||
R.id.menu_show_genre_artists -> {
|
||||
CategoryBrowseActivity.getStartIntent(
|
||||
activity, Messages.Category.ARTIST, value.type, value.id, value.value)
|
||||
activity, Metadata.Category.ARTIST, value.type, value.id, value.value)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
@ -342,6 +345,7 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
}
|
||||
|
||||
private fun deletePlaylistConfirmed(playlistId: Long, playlistName: String) {
|
||||
@Suppress("unused")
|
||||
if (playlistId != -1L) {
|
||||
provider.deletePlaylist(playlistId).subscribeBy(
|
||||
onNext = { success ->
|
||||
@ -360,14 +364,16 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
}
|
||||
|
||||
private fun removeFromPlaylistConfirmed(playlistId: Long, playlistName: String, externalId: String, position: Int) {
|
||||
provider.removeTracksFromPlaylist(playlistId, listOf(externalId), listOf(position)).subscribeBy(
|
||||
onNext = { _ ->
|
||||
listener?.onPlaylistUpdated(playlistId, playlistName)
|
||||
},
|
||||
onError = {
|
||||
@Suppress("unused")
|
||||
provider
|
||||
.removeTracksFromPlaylist(playlistId, listOf(externalId), listOf(position))
|
||||
.subscribeBy(
|
||||
onNext = {
|
||||
listener?.onPlaylistUpdated(playlistId, playlistName)
|
||||
},
|
||||
onError = {
|
||||
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
private fun showSuccess(message: String, button: String? = null, cb: ((View) -> Unit)? = null) =
|
||||
@ -390,17 +396,17 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
val trackExternalId = args.getString(EXTRA_TRACK_EXTERNAL_ID, "")
|
||||
val trackPosition = args.getInt(EXTRA_TRACK_POSITION, -1)
|
||||
|
||||
val dlg = AlertDialog.Builder(activity!!)
|
||||
return AlertDialog.Builder(activity!!)
|
||||
.setTitle(R.string.playlist_confirm_delete_title)
|
||||
.setMessage(getString(R.string.playlist_confirm_delete_message, trackTitle))
|
||||
.setNegativeButton(R.string.button_no, null)
|
||||
.setPositiveButton(R.string.button_yes, { _: DialogInterface, _: Int ->
|
||||
.setPositiveButton(R.string.button_yes) { _: DialogInterface, _: Int ->
|
||||
mixin.removeFromPlaylistConfirmed(playlistId, playlistName, trackExternalId, trackPosition)
|
||||
})
|
||||
}
|
||||
.create()
|
||||
|
||||
dlg.setCancelable(false)
|
||||
return dlg
|
||||
.apply {
|
||||
setCancelable(false)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@ -442,10 +448,10 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
.setTitle(R.string.playlist_confirm_delete_title)
|
||||
.setMessage(getString(R.string.playlist_confirm_delete_message, playlistName))
|
||||
.setNegativeButton(R.string.button_no, null)
|
||||
.setPositiveButton(R.string.button_yes, { _: DialogInterface, _: Int ->
|
||||
.setPositiveButton(R.string.button_yes) { _: DialogInterface, _: Int ->
|
||||
val playlistId = args.getLong(EXTRA_PLAYLIST_ID, -1)
|
||||
mixin.deletePlaylistConfirmed(playlistId, playlistName)
|
||||
})
|
||||
}
|
||||
.create()
|
||||
|
||||
dlg.setCancelable(false)
|
||||
@ -500,7 +506,7 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
val dlg = AlertDialog.Builder(activity)
|
||||
.setTitle(R.string.playlist_name_title)
|
||||
.setNegativeButton(R.string.button_cancel, null)
|
||||
.setPositiveButton(buttonId, { _: DialogInterface, _: Int ->
|
||||
.setPositiveButton(buttonId) { _: DialogInterface, _: Int ->
|
||||
val playlistName = editText.text.toString()
|
||||
if (playlistName.isNotBlank()) {
|
||||
when (action) {
|
||||
@ -511,7 +517,7 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
else {
|
||||
mixin.showError(R.string.playlist_name_error_empty)
|
||||
}
|
||||
})
|
||||
}
|
||||
.create()
|
||||
|
||||
val paddingX = activity.resources.getDimensionPixelSize(R.dimen.edit_text_dialog_padding_x)
|
||||
@ -569,7 +575,7 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity,
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val REQUEST_ADD_TO_PLAYLIST = 32
|
||||
private val REQUEST_EDIT_PLAYLIST = 33
|
||||
private const val REQUEST_ADD_TO_PLAYLIST = 32
|
||||
private const val REQUEST_EDIT_PLAYLIST = 33
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ import android.content.Intent
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import io.casey.musikcube.remote.R
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
import io.casey.musikcube.remote.ui.shared.activity.Filterable
|
||||
import io.casey.musikcube.remote.ui.shared.activity.FragmentActivityWithTransport
|
||||
import io.casey.musikcube.remote.ui.shared.fragment.BaseFragment
|
||||
@ -36,7 +36,7 @@ class TrackListActivity : FragmentActivityWithTransport(), Filterable {
|
||||
|
||||
companion object {
|
||||
fun getOfflineStartIntent(context: Context): Intent =
|
||||
getStartIntent(context, Messages.Category.OFFLINE, 0).apply {
|
||||
getStartIntent(context, Metadata.Category.OFFLINE, 0).apply {
|
||||
putExtra(Track.Extra.TITLE_ID, R.string.offline_tracks_title)
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import android.support.v7.app.AppCompatActivity
|
||||
import android.view.*
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import io.casey.musikcube.remote.R
|
||||
import io.casey.musikcube.remote.service.websocket.Messages
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata
|
||||
import io.casey.musikcube.remote.service.websocket.model.IDataProvider
|
||||
import io.casey.musikcube.remote.service.websocket.model.ITrack
|
||||
import io.casey.musikcube.remote.service.websocket.model.ITrackListQueryFactory
|
||||
@ -127,7 +127,7 @@ class TrackListFragment: BaseFragment(), Filterable, TitleProvider {
|
||||
}
|
||||
|
||||
fun createOptionsMenu(menu: Menu): Boolean {
|
||||
when (Messages.Category.PLAYLISTS == categoryType) {
|
||||
when (Metadata.Category.PLAYLISTS == categoryType) {
|
||||
true -> appCompatActivity.menuInflater.inflate(R.menu.view_playlist_menu, menu)
|
||||
false -> initSearchMenu(menu, this)
|
||||
}
|
||||
@ -153,14 +153,14 @@ class TrackListFragment: BaseFragment(), Filterable, TitleProvider {
|
||||
val playlistName = data.getStringExtra(EditPlaylistActivity.EXTRA_PLAYLIST_NAME) ?: ""
|
||||
val playlistId = data.getLongExtra(EditPlaylistActivity.EXTRA_PLAYLIST_ID, -1L)
|
||||
|
||||
if (categoryType != Messages.Category.PLAYLISTS || playlistId != this.categoryId) {
|
||||
if (categoryType != Metadata.Category.PLAYLISTS || playlistId != this.categoryId) {
|
||||
showSnackbar(
|
||||
appCompatActivity.findViewById(android.R.id.content),
|
||||
getString(R.string.playlist_edit_save_success, playlistName),
|
||||
buttonText = getString(R.string.button_view),
|
||||
buttonCb = {
|
||||
startActivity(TrackListActivity.getStartIntent(
|
||||
appCompatActivity, Messages.Category.PLAYLISTS, playlistId, playlistName))
|
||||
appCompatActivity, Metadata.Category.PLAYLISTS, playlistId, playlistName))
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -188,7 +188,7 @@ class TrackListFragment: BaseFragment(), Filterable, TitleProvider {
|
||||
}
|
||||
|
||||
private val isOfflineTracks: Boolean
|
||||
get() = Messages.Category.OFFLINE == categoryType
|
||||
get() = Metadata.Category.OFFLINE == categoryType
|
||||
|
||||
private fun requeryIfViewingOfflineCache() {
|
||||
if (isOfflineTracks) {
|
||||
@ -207,7 +207,7 @@ class TrackListFragment: BaseFragment(), Filterable, TitleProvider {
|
||||
data.provider.getTracksByCategory(categoryType ?: "", categoryId, limit, offset, lastFilter)
|
||||
|
||||
override fun offline(): Boolean =
|
||||
Messages.Category.OFFLINE == categoryType
|
||||
Metadata.Category.OFFLINE == categoryType
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -220,7 +220,7 @@ class TrackListFragment: BaseFragment(), Filterable, TitleProvider {
|
||||
data.provider.getTracks(limit, offset, lastFilter)
|
||||
|
||||
override fun offline(): Boolean =
|
||||
Messages.Category.OFFLINE == categoryType
|
||||
Metadata.Category.OFFLINE == categoryType
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -234,7 +234,7 @@ class TrackListFragment: BaseFragment(), Filterable, TitleProvider {
|
||||
|
||||
private val menuListener: ItemContextMenuMixin.EventListener?
|
||||
get() {
|
||||
if (categoryType == Messages.Category.PLAYLISTS) {
|
||||
if (categoryType == Metadata.Category.PLAYLISTS) {
|
||||
return object: ItemContextMenuMixin.EventListener () {
|
||||
override fun onPlaylistUpdated(id: Long, name: String) {
|
||||
tracks.requery()
|
||||
@ -260,7 +260,7 @@ class TrackListFragment: BaseFragment(), Filterable, TitleProvider {
|
||||
|
||||
override fun onActionItemClick(view: View, track: ITrack, position: Int) {
|
||||
val mixin = mixin(ItemContextMenuMixin::class.java)!!
|
||||
if (categoryType == Messages.Category.PLAYLISTS) {
|
||||
if (categoryType == Metadata.Category.PLAYLISTS) {
|
||||
mixin.showForPlaylistTrack(track, position, categoryId, categoryValue, view)
|
||||
}
|
||||
else {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.casey.musikcube.remote.ui.tracks.model
|
||||
|
||||
import io.casey.musikcube.remote.framework.ViewModel
|
||||
import io.casey.musikcube.remote.service.websocket.Messages.Category.Companion.PLAYLISTS
|
||||
import io.casey.musikcube.remote.service.playback.impl.remote.Metadata.Category.PLAYLISTS
|
||||
import io.casey.musikcube.remote.service.websocket.model.IDataProvider
|
||||
import io.casey.musikcube.remote.service.websocket.model.ITrack
|
||||
import io.casey.musikcube.remote.service.websocket.model.impl.remote.RemoteTrack
|
||||
@ -38,7 +38,7 @@ class EditPlaylistViewModel(private val playlistId: Long): ViewModel<EditPlaylis
|
||||
this.dataProvider = null
|
||||
}
|
||||
|
||||
var status: Status = Status.NotLoaded
|
||||
private var status: Status = Status.NotLoaded
|
||||
private set(value) {
|
||||
field = value
|
||||
publish(value)
|
||||
@ -125,7 +125,7 @@ class EditPlaylistViewModel(private val playlistId: Long): ViewModel<EditPlaylis
|
||||
.flatMapIterable { list: Map<String, ITrack> -> list.asIterable() }
|
||||
.subscribeBy(
|
||||
onNext = { entry: Map.Entry<String, ITrack> ->
|
||||
cache.put(entry.key, CacheEntry(entry.value))
|
||||
cache[entry.key] = CacheEntry(entry.value)
|
||||
},
|
||||
onError = {
|
||||
status = Status.Error
|
||||
@ -141,7 +141,7 @@ class EditPlaylistViewModel(private val playlistId: Long): ViewModel<EditPlaylis
|
||||
|
||||
companion object {
|
||||
private val DEFAULT_TRACK = RemoteTrack(JSONObject())
|
||||
private val PAGE_SIZE = 40
|
||||
private val MAX_SIZE = 150
|
||||
private const val PAGE_SIZE = 40
|
||||
private const val MAX_SIZE = 150
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user