minor code updates

This commit is contained in:
tibbi 2018-10-25 20:20:48 +02:00
parent 9df81953d1
commit 47092293b8
3 changed files with 5 additions and 8 deletions

View file

@ -1,8 +1,8 @@
package com.simplemobiletools.musicplayer.dialogs
import android.app.Activity
import androidx.appcompat.app.AlertDialog
import android.view.View
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.musicplayer.R
@ -16,7 +16,7 @@ class ChangeSortingDialog(val activity: Activity, val callback: () -> Unit) {
init {
AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, { dialog, which -> dialogConfirmed() })
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null)
.create().apply {
activity.setupDialogStuff(view, this, R.string.sort_by)

View file

@ -1,11 +1,9 @@
package com.simplemobiletools.musicplayer.inlines
public inline fun <T> List<T>.indexOfFirstOrNull(predicate: (T) -> Boolean): Int? {
var index = 0
for (item in this) {
inline fun <T> List<T>.indexOfFirstOrNull(predicate: (T) -> Boolean): Int? {
for ((index, item) in this.withIndex()) {
if (predicate(item))
return index
index++
}
return null
}

View file

@ -359,8 +359,7 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
private fun setPreset(id: Int) {
try {
mEqualizer?.usePreset(id.toShort())
} catch (e: IllegalArgumentException) {
Log.e(TAG, "setPreset $e")
} catch (ignored: IllegalArgumentException) {
}
}