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

View file

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

View file

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