[Android] Replace calls to Java's libraries with calls to the Kotlin standard library functions.
Isira Seneviratne
git at videolan.org
Mon Apr 27 16:05:40 CEST 2020
vlc-android | branch: master | Isira Seneviratne <isirasen96 at gmail.com> | Mon Apr 27 18:46:43 2020 +0530| [bdeafbd9dec4836e761f2f8d964951bd197d5688] | committer: Isira Seneviratne
Replace calls to Java's libraries with calls to the Kotlin standard library functions.
> https://code.videolan.org/videolan/vlc-android/commit/bdeafbd9dec4836e761f2f8d964951bd197d5688
---
.../television/ui/audioplayer/AudioPlayerActivity.kt | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/application/television/src/main/java/org/videolan/television/ui/audioplayer/AudioPlayerActivity.kt b/application/television/src/main/java/org/videolan/television/ui/audioplayer/AudioPlayerActivity.kt
index 6e978a444..84b9e02aa 100644
--- a/application/television/src/main/java/org/videolan/television/ui/audioplayer/AudioPlayerActivity.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/audioplayer/AudioPlayerActivity.kt
@@ -41,20 +41,20 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
import kotlinx.coroutines.*
import org.videolan.medialibrary.interfaces.media.MediaWrapper
+import org.videolan.resources.AndroidDevices
import org.videolan.television.R
+import org.videolan.television.databinding.TvAudioPlayerBinding
+import org.videolan.television.ui.browser.BaseTvActivity
+import org.videolan.tools.Settings
import org.videolan.vlc.gui.helpers.AudioUtil
import org.videolan.vlc.gui.helpers.MediaComparators
import org.videolan.vlc.gui.helpers.UiTools
-import org.videolan.television.ui.browser.BaseTvActivity
import org.videolan.vlc.media.MediaUtils
-import org.videolan.resources.AndroidDevices
-import org.videolan.television.databinding.TvAudioPlayerBinding
-import org.videolan.tools.Settings
import org.videolan.vlc.util.getScreenWidth
import org.videolan.vlc.viewmodels.PlayerState
import org.videolan.vlc.viewmodels.PlaylistModel
import java.lang.Runnable
-import java.util.*
+import kotlin.math.abs
@ObsoleteCoroutinesApi
@ExperimentalCoroutinesApi
@@ -202,12 +202,12 @@ class AudioPlayerActivity : BaseTvActivity() {
val dpadx = event.getAxisValue(MotionEvent.AXIS_HAT_X)
val dpady = event.getAxisValue(MotionEvent.AXIS_HAT_Y)
- if (inputDevice == null || Math.abs(dpadx) == 1.0f || Math.abs(dpady) == 1.0f) return false
+ if (inputDevice == null || abs(dpadx) == 1.0f || abs(dpady) == 1.0f) return false
val x = AndroidDevices.getCenteredAxis(event, inputDevice,
MotionEvent.AXIS_X)
- if (Math.abs(x) > 0.3 && System.currentTimeMillis() - lastMove > JOYSTICK_INPUT_DELAY) {
+ if (abs(x) > 0.3 && System.currentTimeMillis() - lastMove > JOYSTICK_INPUT_DELAY) {
seek(if (x > 0.0f) 10000 else -10000)
lastMove = System.currentTimeMillis()
return true
@@ -233,11 +233,11 @@ class AudioPlayerActivity : BaseTvActivity() {
private fun setShuffleMode(shuffle: Boolean) {
shuffling = shuffle
- val medias = model.medias ?: return
+ val medias = model.medias?.toMutableList() ?: return
if (shuffle)
- Collections.shuffle(medias)
+ medias.shuffle()
else
- Collections.sort(medias, MediaComparators.BY_TRACK_NUMBER)
+ medias.sortWith(MediaComparators.BY_TRACK_NUMBER)
model.load(medias, 0)
}
More information about the Android
mailing list