[Android] Remove useless conditions

Nicolas Pomepuy git at videolan.org
Mon Nov 14 09:54:17 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Nov  4 09:48:10 2022 +0100| [5d76588656fc7cbc463ab097d67337cec2e50f17] | committer: Nicolas Pomepuy

Remove useless conditions

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

 .../java/org/videolan/television/ui/browser/BaseBrowserTvFragment.kt  | 2 +-
 .../vlc-android/src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.kt  | 2 --
 .../vlc-android/src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.kt  | 4 +---
 .../vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 2 +-
 .../src/org/videolan/vlc/gui/view/VLCDividerItemDecoration.kt         | 2 +-
 application/vlc-android/src/org/videolan/vlc/util/FileUtils.kt        | 2 +-
 .../vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.kt    | 2 +-
 7 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/application/television/src/main/java/org/videolan/television/ui/browser/BaseBrowserTvFragment.kt b/application/television/src/main/java/org/videolan/television/ui/browser/BaseBrowserTvFragment.kt
index 1f7b82cfa..a4fe1fce8 100644
--- a/application/television/src/main/java/org/videolan/television/ui/browser/BaseBrowserTvFragment.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/browser/BaseBrowserTvFragment.kt
@@ -411,7 +411,7 @@ abstract class BaseBrowserTvFragment<T> : Fragment(), BrowserFragmentInterface,
             true
         }
         KEYCODE_BACK -> {
-            if (binding.headerListContainer != null && binding.headerListContainer.visibility == View.VISIBLE) {
+            if (binding.headerListContainer.visibility == View.VISIBLE) {
                 hideHeaderSelectionScreen()
                 true
             } else false
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.kt
index 3f59e05df..163e91339 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.kt
@@ -28,8 +28,6 @@ import org.videolan.vlc.R
 class JumpToTimeDialog : PickTimeFragment() {
 
     override fun executeAction() {
-        if (playbackService == null)
-            return
         val newTime = getTimeInMillis() //Time in ms
         playbackService.setTime(newTime)
         playbackService.playlistManager.player.updateProgress(newTime)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.kt
index 095abb436..cd8388dbd 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.kt
@@ -55,9 +55,7 @@ class SleepTimerDialog : PickTimeFragment() {
         dismiss()
     }
 
-    override fun showDeleteCurrent(): Boolean {
-        return PlaybackService.playerSleepTime != null
-    }
+    override fun showDeleteCurrent() = true
 
     override fun onClick(v: View) {
         if (v.id == R.id.tim_pic_delete_current) {
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index e15cb34db..b0c2a472c 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -1503,7 +1503,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
                 if (currentTracks?.first == media.uri.toString()) return currentTracks!!.second
                 for (i in 0..media.getAllTracks().size) {
                     val track = media.getAllTracks()[i]
-                    if (track != null) allTracks.add(track)
+                    allTracks.add(track)
                 }
                 currentTracks = Pair(media.uri.toString(), allTracks)
             }
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/view/VLCDividerItemDecoration.kt b/application/vlc-android/src/org/videolan/vlc/gui/view/VLCDividerItemDecoration.kt
index ef249715b..8c5837f57 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/view/VLCDividerItemDecoration.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/view/VLCDividerItemDecoration.kt
@@ -17,7 +17,7 @@ open class VLCDividerItemDecoration(private val context: Context, private val or
     }
 
     override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
-        if (parent.layoutManager == null || dividerDrawable == null) {
+        if (parent.layoutManager == null) {
             return
         }
         if (orientation == VERTICAL) {
diff --git a/application/vlc-android/src/org/videolan/vlc/util/FileUtils.kt b/application/vlc-android/src/org/videolan/vlc/util/FileUtils.kt
index 388867d66..6d99164f1 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/FileUtils.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/FileUtils.kt
@@ -339,7 +339,7 @@ object FileUtils {
     fun getUri(data: Uri?): Uri? {
         var uri = data
         val ctx = AppContextProvider.appContext
-        if (data != null && ctx != null && data.scheme == "content") {
+        if (data != null && data.scheme == "content") {
             // Mail-based apps - download the stream to a temporary file and play it
             if ("com.fsck.k9.attachmentprovider" == data.host || "gmail-ls" == data.host) {
                 var inputStream: InputStream? = null
diff --git a/application/vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.kt b/application/vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.kt
index c63e56063..452b6b104 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.kt
@@ -17,7 +17,7 @@ class MediaItemDiffCallback<T : MediaLibraryItem> : DiffUtilAdapter.DiffCallback
     override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {
         val oldItem = oldList[oldItemPosition]
         val newItem = newList[newItemPosition]
-        return oldItem === newItem || oldItem == null == (newItem == null) && oldItem.equals(newItem)
+        return oldItem === newItem && oldItem.equals(newItem)
     }
 
     override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean {



More information about the Android mailing list