Kotlin refactoring
This commit is contained in:
parent
e9bd24872f
commit
4056a0c1c5
56 changed files with 317 additions and 308 deletions
|
@ -20,7 +20,7 @@ class AlbumViewModel(application: Application) : AndroidViewModel(application) {
|
|||
val result = RepositoryImpl(getApplication()).allAlbums()
|
||||
if (result is Result.Success) {
|
||||
albums.value = result.data
|
||||
}else {
|
||||
} else {
|
||||
albums.value = listOf()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,9 +64,11 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(),
|
|||
|
||||
private fun hideVolumeIfAvailable() {
|
||||
if (PreferenceUtilKT.isVolumeVisibilityMode) {
|
||||
childFragmentManager.beginTransaction().replace(R.id.volumeFragmentContainer, VolumeFragment()).commit()
|
||||
childFragmentManager.beginTransaction()
|
||||
.replace(R.id.volumeFragmentContainer, VolumeFragment()).commit()
|
||||
childFragmentManager.executePendingTransactions()
|
||||
volumeFragment = childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?
|
||||
volumeFragment =
|
||||
childFragmentManager.findFragmentById(R.id.volumeFragmentContainer) as VolumeFragment?
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class GenreViewModel(application: Application) : AndroidViewModel(application) {
|
|||
val result = RepositoryImpl(getApplication()).allGenres()
|
||||
if (result is Success) {
|
||||
genres.value = result.data
|
||||
}else {
|
||||
} else {
|
||||
genres.value = listOf()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,22 +25,9 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
|
|||
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
|
||||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
|
||||
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.*
|
||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.nextButton
|
||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.playPauseButton
|
||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.previousButton
|
||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.progressSlider
|
||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.repeatButton
|
||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.shuffleButton
|
||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.songCurrentProgress
|
||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.songInfo
|
||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.songTotalTime
|
||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.text
|
||||
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.title
|
||||
import kotlinx.android.synthetic.main.fragment_player_playback_controls.*
|
||||
|
||||
class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
||||
|
||||
|
|
|
@ -19,11 +19,10 @@ import android.graphics.drawable.ColorDrawable
|
|||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceFragmentCompat
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.preferences.*
|
||||
|
@ -33,7 +32,7 @@ import code.name.monkey.retromusic.util.NavigationUtil
|
|||
* @author Hemanth S (h4h13).
|
||||
*/
|
||||
|
||||
abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() {
|
||||
abstract class AbsSettingsFragment : PreferenceFragmentCompat() {
|
||||
|
||||
internal fun showProToastAndNavigate(message: String) {
|
||||
Toast.makeText(requireContext(), "$message is Pro version feature.", Toast.LENGTH_SHORT)
|
||||
|
@ -73,16 +72,25 @@ abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() {
|
|||
invalidateSettings()
|
||||
}
|
||||
|
||||
override fun onCreatePreferenceDialog(preference: Preference): DialogFragment? {
|
||||
return when (preference) {
|
||||
is LibraryPreference -> LibraryPreferenceDialog.newInstance()
|
||||
is NowPlayingScreenPreference -> NowPlayingScreenPreferenceDialog.newInstance(preference.key)
|
||||
is AlbumCoverStylePreference -> AlbumCoverStylePreferenceDialog.newInstance(preference.key)
|
||||
is MaterialListPreference -> {
|
||||
MaterialListPreferenceDialog.newInstance(preference)
|
||||
override fun onDisplayPreferenceDialog(preference: Preference?) {
|
||||
when (preference) {
|
||||
is LibraryPreference -> {
|
||||
val fragment = LibraryPreferenceDialog.newInstance()
|
||||
fragment.show(childFragmentManager, preference.key)
|
||||
}
|
||||
is BlacklistPreference -> BlacklistPreferenceDialog.newInstance()
|
||||
else -> super.onCreatePreferenceDialog(preference)
|
||||
is NowPlayingScreenPreference -> {
|
||||
val fragment = NowPlayingScreenPreferenceDialog.newInstance()
|
||||
fragment.show(childFragmentManager, preference.key)
|
||||
}
|
||||
is AlbumCoverStylePreference -> {
|
||||
val fragment = AlbumCoverStylePreferenceDialog.newInstance()
|
||||
fragment.show(childFragmentManager, preference.key)
|
||||
}
|
||||
is BlacklistPreference -> {
|
||||
val fragment = BlacklistPreferenceDialog.newInstance()
|
||||
fragment.show(childFragmentManager, preference.key)
|
||||
}
|
||||
else -> super.onDisplayPreferenceDialog(preference)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import code.name.monkey.retromusic.util.NavigationUtil
|
|||
class AudioSettings : AbsSettingsFragment() {
|
||||
override fun invalidateSettings() {
|
||||
val findPreference: Preference = findPreference("equalizer")!!
|
||||
if (!hasEqualizer() ) {
|
||||
if (!hasEqualizer()) {
|
||||
findPreference.isEnabled = false
|
||||
findPreference.summary = resources.getString(R.string.no_equalizer)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue