Commit 11fd6f10 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Fix crash when changing video display in SecondaryActivity

parent 221e235e
......@@ -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()))
......
......@@ -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()
......
......@@ -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)
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment