[Android] Fix crash when changing video display in SecondaryActivity
Nicolas Pomepuy
git at videolan.org
Wed Sep 25 09:37:40 CEST 2019
vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Wed Sep 25 07:07:59 2019 +0200| [11fd6f1022411febdeb80a7e701251e6dfc80dc1] | committer: Nicolas Pomepuy
Fix crash when changing video display in SecondaryActivity
> https://code.videolan.org/videolan/vlc-android/commit/11fd6f1022411febdeb80a7e701251e6dfc80dc1
---
vlc-android/src/org/videolan/vlc/gui/ContentActivity.kt | 4 ++++
vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt | 12 ++++++++++++
.../src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt | 6 +++---
.../src/org/videolan/vlc/gui/video/VideoGridFragment.kt | 3 ++-
4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/ContentActivity.kt b/vlc-android/src/org/videolan/vlc/gui/ContentActivity.kt
index 3b1eeb033..e5005ccb6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/ContentActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/ContentActivity.kt
@@ -160,6 +160,10 @@ open class ContentActivity : AudioPlayerContainerActivity(), SearchView.OnQueryT
override fun onQueryTextSubmit(query: String) = false
+ open fun forceLoadVideoFragment() {
+ throw NotImplementedError("forceLoadVideoFragment not implemented")
+ }
+
private fun openSearchActivity() {
startActivity(Intent(Intent.ACTION_SEARCH, null, this, SearchActivity::class.java)
.putExtra(SearchManager.QUERY, searchView.query.toString()))
diff --git a/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt b/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
index 79d627364..250e601de 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.kt
@@ -83,6 +83,18 @@ class SecondaryActivity : ContentActivity() {
}
}
+ override fun forceLoadVideoFragment() {
+ val fragmentId = intent.getStringExtra(KEY_FRAGMENT)
+ fetchSecondaryFragment(fragmentId)
+ if (fragment == null) {
+ finish()
+ return
+ }
+ supportFragmentManager.beginTransaction()
+ .replace(R.id.fragment_placeholder, fragment!!)
+ .commit()
+ }
+
override fun onResume() {
overridePendingTransition(0, 0)
super.onResume()
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
index 300fb5564..684e8b015 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/MediaBrowserFragment.kt
@@ -287,17 +287,17 @@ abstract class MediaBrowserFragment<T : SortableModel> : Fragment(), ActionMode.
}
R.id.video_min_group_length_disable -> {
Settings.getInstance(requireActivity()).edit().putString("video_min_group_length", "-1").apply()
- (activity as MainActivity).forceLoadVideoFragment()
+ (activity as ContentActivity).forceLoadVideoFragment()
return true
}
R.id.video_min_group_length_folder -> {
Settings.getInstance(requireActivity()).edit().putString("video_min_group_length", "0").apply()
- (activity as MainActivity).forceLoadVideoFragment()
+ (activity as ContentActivity).forceLoadVideoFragment()
return true
}
R.id.video_min_group_length_name -> {
Settings.getInstance(requireActivity()).edit().putString("video_min_group_length", "6").apply()
- (activity as MainActivity).forceLoadVideoFragment()
+ (activity as ContentActivity).forceLoadVideoFragment()
return true
}
else -> return super.onOptionsItemSelected(item)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
index b1244b081..f59cea7cb 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
@@ -45,6 +45,7 @@ import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.tools.MultiSelectHelper
import org.videolan.vlc.R
import org.videolan.vlc.databinding.VideoGridBinding
+import org.videolan.vlc.gui.ContentActivity
import org.videolan.vlc.gui.MainActivity
import org.videolan.vlc.gui.SecondaryActivity
import org.videolan.vlc.gui.browser.MediaBrowserFragment
@@ -137,7 +138,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
R.id.ml_menu_display_list, R.id.ml_menu_display_grid -> {
val displayInCards = Settings.getInstance(requireActivity()).getBoolean("video_display_in_cards", true)
Settings.getInstance(requireActivity()).edit().putBoolean("video_display_in_cards", !displayInCards).apply()
- (activity as MainActivity).forceLoadVideoFragment()
+ (activity as ContentActivity).forceLoadVideoFragment()
true
}
else -> super.onOptionsItemSelected(item)
More information about the Android
mailing list