couple tweaks here and there

This commit is contained in:
tibbi 2017-01-07 21:50:16 +01:00
parent 219cb6fcdc
commit 662660de0a
7 changed files with 25 additions and 52 deletions

View file

@ -83,29 +83,15 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
R.id.sort -> {
showSortingDialog()
true
}
R.id.toggle_shuffle -> {
toggleShuffle()
true
}
R.id.toggle_song_repetition -> {
toggleSongRepetition()
true
}
R.id.settings -> {
launchSettings()
true
}
R.id.about -> {
launchAbout()
true
}
else -> super.onOptionsItemSelected(item)
when (item.itemId) {
R.id.sort -> showSortingDialog()
R.id.toggle_shuffle -> toggleShuffle()
R.id.toggle_song_repetition -> toggleSongRepetition()
R.id.settings -> launchSettings()
R.id.about -> launchAbout()
else -> return super.onOptionsItemSelected(item)
}
return true
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {

View file

@ -91,7 +91,7 @@ class WidgetConfigureActivity : AppCompatActivity() {
}
fun pickBackgroundColor() {
val dialog = AmbilWarnaDialog(this, mBgColorWithoutTransparency, object : AmbilWarnaDialog.OnAmbilWarnaListener {
AmbilWarnaDialog(this, mBgColorWithoutTransparency, object : AmbilWarnaDialog.OnAmbilWarnaListener {
override fun onCancel(dialog: AmbilWarnaDialog) {
}
@ -99,13 +99,11 @@ class WidgetConfigureActivity : AppCompatActivity() {
mBgColorWithoutTransparency = color
updateBackgroundColor()
}
})
dialog.show()
}).show()
}
fun pickTextColor() {
val dialog = AmbilWarnaDialog(this, mTextColor, object : AmbilWarnaDialog.OnAmbilWarnaListener {
AmbilWarnaDialog(this, mTextColor, object : AmbilWarnaDialog.OnAmbilWarnaListener {
override fun onCancel(dialog: AmbilWarnaDialog) {
}
@ -113,9 +111,7 @@ class WidgetConfigureActivity : AppCompatActivity() {
mTextColor = color
updateTextColor()
}
})
dialog.show()
}).show()
}
private fun storeWidgetColors() {

View file

@ -48,21 +48,13 @@ class SongAdapter(val activity: SimpleActivity, var songs: ArrayList<Song>, val
val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
return when (item.itemId) {
R.id.cab_properties -> {
showProperties()
true
}
R.id.cab_rename -> {
displayEditDialog()
true
}
R.id.cab_delete -> {
askConfirmDelete()
true
}
else -> false
when (item.itemId) {
R.id.cab_properties -> showProperties()
R.id.cab_rename -> displayEditDialog()
R.id.cab_delete -> askConfirmDelete()
else -> return false
}
return true
}
override fun onCreateActionMode(actionMode: ActionMode?, menu: Menu?): Boolean {

View file

@ -22,8 +22,6 @@ val SET_EQUALIZER = PATH + "SET_EQUALIZER"
// shared preferences
val PREFS_KEY = "Music Player"
val IS_FIRST_RUN = "is_first_run"
val IS_DARK_THEME = "is_dark_theme"
val SHUFFLE = "shuffle"
val NUMERIC_PROGRESS = "numeric_progress"
val SORTING = "track_sorting"

View file

@ -215,7 +215,6 @@ class MyWidgetProvider : AppWidgetProvider() {
mBus!!.register(this)
} catch (e: Exception) {
}
}
private fun unregisterBus() {
@ -223,6 +222,5 @@ class MyWidgetProvider : AppWidgetProvider() {
mBus!!.unregister(this)
} catch (e: Exception) {
}
}
}

View file

@ -6,7 +6,7 @@ import com.simplemobiletools.musicplayer.helpers.SORT_BY_TITLE
import com.simplemobiletools.musicplayer.helpers.SORT_DESCENDING
import java.io.Serializable
class Song(val id: Long, var title: String, var artist: String, var path: String, val duration: Int) : Serializable, Comparable<Song> {
data class Song(val id: Long, var title: String, var artist: String, var path: String, val duration: Int) : Serializable, Comparable<Song> {
companion object {
private const val serialVersionUID = 6717978793256842245L
var sorting: Int = 0
@ -35,8 +35,6 @@ class Song(val id: Long, var title: String, var artist: String, var path: String
return res
}
override fun toString() = "Song {id=$id, title=$title, artist=$artist, path=$path, duration=$duration}"
override fun equals(o: Any?): Boolean {
return if (this === o)
true

View file

@ -269,7 +269,12 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
val rawArt = mediaMetadataRetriever.embeddedPicture
if (rawArt != null) {
val options = BitmapFactory.Options()
return BitmapFactory.decodeByteArray(rawArt, 0, rawArt.size, options)
try {
val bitmap = BitmapFactory.decodeByteArray(rawArt, 0, rawArt.size, options)
if (bitmap != null)
return bitmap
} catch (e: Exception) {
}
}
}