mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 11:10:52 +00:00
Modernized some calls and coding style.
This commit is contained in:
parent
a5330ee911
commit
ca8e935724
@ -395,7 +395,7 @@ class RemoteMetadataProxy(private val service: WebSocketService) : IMetadataProx
|
||||
.build()
|
||||
|
||||
return service.observe(message, client)
|
||||
.map<Boolean> { socketMessage -> isSuccessful(socketMessage) }
|
||||
.map { socketMessage -> isSuccessful(socketMessage) }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
@ -414,7 +414,7 @@ class RemoteMetadataProxy(private val service: WebSocketService) : IMetadataProx
|
||||
.build()
|
||||
|
||||
return service.observe(message, client)
|
||||
.map<Int> { socketMessage -> toCount(socketMessage) }
|
||||
.map { socketMessage -> toCount(socketMessage) }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
@ -430,7 +430,7 @@ class RemoteMetadataProxy(private val service: WebSocketService) : IMetadataProx
|
||||
.build()
|
||||
|
||||
return service.observe(message, client)
|
||||
.map<Boolean> { socketMessage -> isSuccessful(socketMessage) }
|
||||
.map { socketMessage -> isSuccessful(socketMessage) }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
|
@ -131,12 +131,12 @@ class MainMetadataView : FrameLayout {
|
||||
this.volumeWithArt.text = volume
|
||||
}
|
||||
|
||||
this.title.text = if (title.isEmpty()) getString(if (buffering) R.string.buffering else R.string.unknown_title) else title
|
||||
this.artist.text = if (artist.isEmpty()) getString(if (buffering) R.string.buffering else R.string.unknown_artist) else artist
|
||||
this.album.text = if (album.isEmpty()) getString(if (buffering) R.string.buffering else R.string.unknown_album) else album
|
||||
this.title.text = title.ifEmpty { getString(if (buffering) R.string.buffering else R.string.unknown_title) }
|
||||
this.artist.text = artist.ifEmpty { getString(if (buffering) R.string.buffering else R.string.unknown_artist) }
|
||||
this.album.text = album.ifEmpty { getString(if (buffering) R.string.buffering else R.string.unknown_album) }
|
||||
|
||||
this.rebindAlbumArtistWithArtTextView(playback)
|
||||
this.titleWithArt.text = if (title.isEmpty()) getString(if (buffering) R.string.buffering else R.string.unknown_title) else title
|
||||
this.titleWithArt.text = title.ifEmpty { getString(if (buffering) R.string.buffering else R.string.unknown_title) }
|
||||
this.buffering.visibility = if (buffering) View.VISIBLE else View.GONE
|
||||
|
||||
if (artist.isEmpty() || album.isEmpty()) {
|
||||
|
@ -95,8 +95,8 @@ class RemoteSettingsViewModel(private val environment: IEnvironment): BaseRemote
|
||||
val transportQuery = proxy.setTransportType(transport)
|
||||
Observable.zip<Boolean, Boolean, Boolean>(
|
||||
gainQuery,
|
||||
transportQuery,
|
||||
{ b1, b2 -> b1 && b2 })
|
||||
transportQuery
|
||||
) { b1, b2 -> b1 && b2 }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeBy(
|
||||
onNext = { success ->
|
||||
@ -126,9 +126,9 @@ class RemoteSettingsViewModel(private val environment: IEnvironment): BaseRemote
|
||||
Observable.zip<Boolean, Boolean, Boolean, Boolean>(
|
||||
gainQuery,
|
||||
outputQuery,
|
||||
transportQuery,
|
||||
{ b1, b2, b3 -> b1 && b2 && b3 })
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
transportQuery
|
||||
) { b1, b2, b3 -> b1 && b2 && b3 }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeBy(
|
||||
onNext = { success ->
|
||||
if (success) { state = State.Saved }
|
||||
@ -153,13 +153,13 @@ class RemoteSettingsViewModel(private val environment: IEnvironment): BaseRemote
|
||||
Observable.zip<IGainSettings, IOutputs, TransportType, Boolean>(
|
||||
gainQuery,
|
||||
outputsQuery,
|
||||
transportQuery,
|
||||
{ gainSettings, outputs, transportType ->
|
||||
this.gain = gainSettings
|
||||
this.outputs = outputs
|
||||
this.transportType = transportType
|
||||
true
|
||||
})
|
||||
transportQuery
|
||||
) { gainSettings, outputs, transportType ->
|
||||
this.gain = gainSettings
|
||||
this.outputs = outputs
|
||||
this.transportType = transportType
|
||||
true
|
||||
}
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeBy(
|
||||
onNext = { state = State.Ready },
|
||||
|
@ -163,12 +163,11 @@ abstract class BaseActivity : AppCompatActivity(), ViewModel.Provider, Runner.Ta
|
||||
|
||||
private val top: Fragment?
|
||||
get() {
|
||||
return when {
|
||||
fm.backStackEntryCount == 0 ->
|
||||
return when (fm.backStackEntryCount) {
|
||||
0 ->
|
||||
fm.findFragmentByTag(BrowseFragment.TAG)
|
||||
else -> fm.findFragmentByTag(
|
||||
fm.getBackStackEntryAt(fm.backStackEntryCount - 1).name)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ fun SharedPreferences.getString(key: String): String? =
|
||||
fun Toolbar.setTitleFromIntent(defaultTitle: String) {
|
||||
val extras = (context as? AppCompatActivity)?.intent?.extras ?: Bundle()
|
||||
val title = extras.getString(Shared.Extra.TITLE_OVERRIDE) ?: ""
|
||||
this.title = if (title.isNotEmpty()) title else defaultTitle
|
||||
this.title = title.ifEmpty { defaultTitle }
|
||||
}
|
||||
|
||||
fun Toolbar.collapseActionViewIfExpanded(): Boolean {
|
||||
@ -106,7 +106,7 @@ fun AppCompatActivity.enableUpNavigation() {
|
||||
|
||||
fun AppCompatActivity.setTitleFromIntent(defaultTitle: String) {
|
||||
val title = this.intent.getStringExtra(Shared.Extra.TITLE_OVERRIDE) ?: ""
|
||||
this.title = if (title.isNotEmpty()) title else defaultTitle
|
||||
this.title = title.ifEmpty { defaultTitle }
|
||||
}
|
||||
|
||||
fun BaseFragment.addFilterAction(menu: Menu, filterable: IFilterable?): Boolean {
|
||||
@ -311,7 +311,7 @@ fun BaseFragment.setupDefaultRecyclerView(
|
||||
|
||||
fun BaseFragment.getTitleOverride(defaultTitle: String): String {
|
||||
val title = this.extras.getString(Shared.Extra.TITLE_OVERRIDE) ?: ""
|
||||
return if (title.isNotEmpty()) title else defaultTitle
|
||||
return title.ifEmpty { defaultTitle }
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user