updating SimpleActivity
This commit is contained in:
parent
26c444c9f8
commit
1cc6df5e42
3 changed files with 18 additions and 29 deletions
|
@ -59,7 +59,7 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mIsNumericProgressShown = mConfig.isNumericProgressEnabled
|
||||
mIsNumericProgressShown = config.isNumericProgressEnabled
|
||||
setupIconColors()
|
||||
song_progress.visibility = if (mIsNumericProgressShown) View.VISIBLE else View.GONE
|
||||
markCurrentSong()
|
||||
|
@ -69,10 +69,10 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
|
|||
menuInflater.inflate(R.menu.menu, menu)
|
||||
|
||||
val songRepetition = menu.findItem(R.id.toggle_song_repetition)
|
||||
songRepetition.title = getString(if (mConfig.repeatSong) R.string.disable_song_repetition else R.string.enable_song_repetition)
|
||||
songRepetition.title = getString(if (config.repeatSong) R.string.disable_song_repetition else R.string.enable_song_repetition)
|
||||
|
||||
val shuffle = menu.findItem(R.id.toggle_shuffle)
|
||||
shuffle.title = getString(if (mConfig.isShuffleEnabled) R.string.disable_shuffle else R.string.enable_shuffle)
|
||||
shuffle.title = getString(if (config.isShuffleEnabled) R.string.disable_shuffle else R.string.enable_shuffle)
|
||||
|
||||
return true
|
||||
}
|
||||
|
@ -122,15 +122,15 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
|
|||
}
|
||||
|
||||
private fun toggleShuffle() {
|
||||
mConfig.isShuffleEnabled = !mConfig.isShuffleEnabled
|
||||
config.isShuffleEnabled = !config.isShuffleEnabled
|
||||
invalidateOptionsMenu()
|
||||
toast(if (mConfig.isShuffleEnabled) R.string.shuffle_enabled else R.string.shuffle_disabled)
|
||||
toast(if (config.isShuffleEnabled) R.string.shuffle_enabled else R.string.shuffle_disabled)
|
||||
}
|
||||
|
||||
private fun toggleSongRepetition() {
|
||||
mConfig.repeatSong = !mConfig.repeatSong
|
||||
config.repeatSong = !config.repeatSong
|
||||
invalidateOptionsMenu()
|
||||
toast(if (mConfig.repeatSong) R.string.song_repetition_enabled else R.string.song_repetition_disabled)
|
||||
toast(if (config.repeatSong) R.string.song_repetition_enabled else R.string.song_repetition_disabled)
|
||||
}
|
||||
|
||||
private fun initializePlayer() {
|
||||
|
@ -188,7 +188,7 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
|
|||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mConfig.isFirstRun = false
|
||||
config.isFirstRun = false
|
||||
mBus.unregister(this)
|
||||
}
|
||||
|
||||
|
|
|
@ -23,19 +23,19 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun setupDarkTheme() {
|
||||
settings_dark_theme.isChecked = mConfig.isDarkTheme
|
||||
settings_dark_theme.isChecked = config.isDarkTheme
|
||||
settings_dark_theme_holder.setOnClickListener {
|
||||
settings_dark_theme.toggle()
|
||||
mConfig.isDarkTheme = settings_dark_theme.isChecked
|
||||
config.isDarkTheme = settings_dark_theme.isChecked
|
||||
restartActivity()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupNumericProgress() {
|
||||
settings_numeric_progress.isChecked = mConfig.isNumericProgressEnabled
|
||||
settings_numeric_progress.isChecked = config.isNumericProgressEnabled
|
||||
settings_numeric_progress_holder.setOnClickListener {
|
||||
settings_numeric_progress.toggle()
|
||||
mConfig.isNumericProgressEnabled = settings_numeric_progress.isChecked
|
||||
config.isNumericProgressEnabled = settings_numeric_progress.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,10 +51,10 @@ class SettingsActivity : SimpleActivity() {
|
|||
|
||||
settings_equalizer.apply {
|
||||
adapter = arrayAdapter
|
||||
setSelection(mConfig.equalizer)
|
||||
setSelection(config.equalizer)
|
||||
onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
mConfig.equalizer = selectedItemPosition
|
||||
config.equalizer = selectedItemPosition
|
||||
|
||||
Intent(applicationContext, MusicService::class.java).apply {
|
||||
putExtra(EQUALIZER, selectedItemPosition)
|
||||
|
|
|
@ -1,25 +1,14 @@
|
|||
package com.simplemobiletools.musicplayer.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.view.MenuItem
|
||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||
import com.simplemobiletools.musicplayer.helpers.Config
|
||||
|
||||
open class SimpleActivity : AppCompatActivity() {
|
||||
lateinit var mConfig: Config
|
||||
open class SimpleActivity : BaseSimpleActivity() {
|
||||
lateinit var config: Config
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
mConfig = Config.newInstance(applicationContext)
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
finish()
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
config = Config.newInstance(applicationContext)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue