[Android] Force Activity restart when changing medialib folders from empty view

Nicolas Pomepuy git at videolan.org
Wed Oct 16 17:43:54 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Tue Oct 15 14:53:11 2019 +0200| [5983d0ada3faf5e1087fe35850b9b8d6efb0204e] | committer: Geoffrey Métais

Force Activity restart when changing medialib folders from empty view

Fixes #1051

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

 vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt      | 10 +++++-----
 .../src/org/videolan/vlc/gui/view/EmptyLoadingStateView.kt     |  4 +++-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt b/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
index a79353363..1824cc060 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
@@ -42,10 +42,7 @@ import org.videolan.vlc.gui.helpers.UiTools
 import org.videolan.vlc.gui.tv.TvUtil
 import org.videolan.vlc.gui.video.VideoGridFragment
 import org.videolan.vlc.reloadLibrary
-import org.videolan.vlc.util.AndroidDevices
-import org.videolan.vlc.util.KEY_FOLDER
-import org.videolan.vlc.util.KEY_GROUP
-import org.videolan.vlc.util.RESULT_RESCAN
+import org.videolan.vlc.util.*
 
 @ExperimentalCoroutinesApi
 @ObsoleteCoroutinesApi
@@ -143,7 +140,10 @@ class SecondaryActivity : ContentActivity() {
                     }
                 }
             }
-            STORAGE_BROWSER -> fragment = StorageBrowserFragment()
+            STORAGE_BROWSER -> {
+                fragment = StorageBrowserFragment()
+                setResult(RESULT_RESTART)
+            }
             else -> throw IllegalArgumentException("Wrong fragment id.")
         }
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/view/EmptyLoadingStateView.kt b/vlc-android/src/org/videolan/vlc/gui/view/EmptyLoadingStateView.kt
index ea8a75684..b48ddab56 100644
--- a/vlc-android/src/org/videolan/vlc/gui/view/EmptyLoadingStateView.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/view/EmptyLoadingStateView.kt
@@ -24,6 +24,7 @@
 
 package org.videolan.vlc.gui.view
 
+import android.app.Activity
 import android.content.Context
 import android.content.Intent
 import android.util.AttributeSet
@@ -35,6 +36,7 @@ import androidx.annotation.StringRes
 import kotlinx.android.synthetic.main.view_empty_loading.view.*
 import org.videolan.vlc.R
 import org.videolan.vlc.gui.SecondaryActivity
+import org.videolan.vlc.util.ACTIVITY_RESULT_PREFERENCES
 
 class EmptyLoadingStateView : FrameLayout {
 
@@ -101,7 +103,7 @@ class EmptyLoadingStateView : FrameLayout {
         noMediaButton.setOnClickListener {
             val intent = Intent(context.applicationContext, SecondaryActivity::class.java)
             intent.putExtra("fragment", SecondaryActivity.STORAGE_BROWSER)
-            context.startActivity(intent)
+            (context as Activity).startActivityForResult(intent, ACTIVITY_RESULT_PREFERENCES)
             noMediaClickListener?.invoke()
         }
     }



More information about the Android mailing list