[Android] Fix unit calculation + better audio player animation

Nicolas Pomepuy git at videolan.org
Mon Oct 14 15:35:33 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Oct 10 11:29:29 2019 +0200| [e4dbffc18ad0cf7db285de26eb900c9d86006435] | committer: Geoffrey Métais

Fix unit calculation + better audio player animation

> https://code.videolan.org/videolan/vlc-android/commit/e4dbffc18ad0cf7db285de26eb900c9d86006435
---

 tools/src/main/java/org/videolan/tools/KotlinExtensions.kt   |  4 ++--
 vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt    | 12 ++++++------
 .../src/org/videolan/vlc/gui/tv/details/MediaListActivity.kt |  1 -
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/tools/src/main/java/org/videolan/tools/KotlinExtensions.kt b/tools/src/main/java/org/videolan/tools/KotlinExtensions.kt
index 92a44f2c8..c65b3b9ba 100644
--- a/tools/src/main/java/org/videolan/tools/KotlinExtensions.kt
+++ b/tools/src/main/java/org/videolan/tools/KotlinExtensions.kt
@@ -55,8 +55,8 @@ fun View?.setVisible() = setVisibility(View.VISIBLE)
 fun View?.setInvisible() = setVisibility(View.INVISIBLE)
 fun View?.setGone() = setVisibility(View.GONE)
 
-val Int.dp: Int get() = (this / Resources.getSystem().displayMetrics.density).toInt()
-val Int.px: Int get() = (this * Resources.getSystem().displayMetrics.density).toInt()
+val Int.dp: Int get() = (this * Resources.getSystem().displayMetrics.density).toInt()
+val Int.px: Int get() = (this / Resources.getSystem().displayMetrics.density).toInt()
 
 fun CoroutineScope.conflatedActor(time: Long = 2000L, action: () -> Unit) = actor<Unit>(capacity = Channel.CONFLATED) {
     for (evt in channel) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
index c7c6a3c50..cb91f3213 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.kt
@@ -54,8 +54,8 @@ import kotlinx.coroutines.channels.Channel
 import kotlinx.coroutines.channels.actor
 import org.videolan.medialibrary.Tools
 import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper
+import org.videolan.tools.dp
 import org.videolan.tools.isStarted
-import org.videolan.tools.px
 import org.videolan.vlc.PlaybackService
 import org.videolan.vlc.R
 import org.videolan.vlc.VLCApplication
@@ -560,11 +560,11 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, CoroutineS
         binding.headerTime.alpha = 1 - slideOffset
 
         val translationOffset = min(1f, max(0f, (slideOffset * 1.4f) - 0.2f))
-        binding.playlistSearch.translationY = (1 - translationOffset) * 60.px
-        binding.playlistSwitch.translationY = (1 - translationOffset) * 60.px
-        binding.advFunction.translationY = (1 - translationOffset) * 60.px
-        binding.headerPlayPause.translationY = -translationOffset * 60.px
-        binding.headerTime.translationY = -translationOffset * 60.px
+        binding.playlistSearch.translationY = -(1 - translationOffset) * 48.dp
+        binding.playlistSwitch.translationY = -(1 - translationOffset) * 48.dp
+        binding.advFunction.translationY = -(1 - translationOffset) * 48.dp
+        binding.headerPlayPause.translationY = translationOffset * 48.dp
+        binding.headerTime.translationY = translationOffset * 48.dp
     }
 
     private var timelineListener: OnSeekBarChangeListener = object : OnSeekBarChangeListener {
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/details/MediaListActivity.kt b/vlc-android/src/org/videolan/vlc/gui/tv/details/MediaListActivity.kt
index 01c725efe..a421bb5db 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/details/MediaListActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/details/MediaListActivity.kt
@@ -15,7 +15,6 @@ import kotlinx.coroutines.*
 import org.videolan.medialibrary.Tools
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.medialibrary.media.Playlist
-import org.videolan.tools.dp
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.ActivityMediaListTvBinding
 import org.videolan.vlc.gui.dialogs.SavePlaylistDialog



More information about the Android mailing list