[Android] Fix crash on the VideoBrowserFragment currentFragment call
Nicolas Pomepuy
git at videolan.org
Tue Oct 25 06:38:26 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Oct 21 11:37:39 2022 +0200| [9757ca2d423f179c73fec25fa04ac23aa3f01696] | committer: Nicolas Pomepuy
Fix crash on the VideoBrowserFragment currentFragment call
> https://code.videolan.org/videolan/vlc-android/commit/9757ca2d423f179c73fec25fa04ac23aa3f01696
---
.../videolan/vlc/gui/video/VideoBrowserFragment.kt | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoBrowserFragment.kt
index 9b489c0ad..14e404cef 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoBrowserFragment.kt
@@ -196,23 +196,29 @@ class VideoBrowserFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListene
*
* @return the current shown fragment
*/
- private fun getCurrentFragment() = childFragmentManager.fragments.find{ it is Filterable && it.isResumed } as Filterable
+ private fun getCurrentFragment() = childFragmentManager.fragments.find{ it.isResumed }
override fun getFilterQuery() = try {
- getCurrentFragment().getFilterQuery()
+ (getCurrentFragment() as? Filterable)?.getFilterQuery()
} catch (e: Exception) {
null
}
- override fun enableSearchOption() = getCurrentFragment().enableSearchOption()
+ override fun enableSearchOption() = (getCurrentFragment() as? Filterable)?.enableSearchOption() ?: false
- override fun filter(query: String) = getCurrentFragment().filter(query)
+ override fun filter(query: String) {
+ (getCurrentFragment() as? Filterable)?.filter(query)
+ }
- override fun restoreList() = getCurrentFragment().restoreList()
+ override fun restoreList() {
+ (getCurrentFragment() as? Filterable)?.restoreList()
+ }
- override fun setSearchVisibility(visible: Boolean) = getCurrentFragment().setSearchVisibility(visible)
+ override fun setSearchVisibility(visible: Boolean) {
+ (getCurrentFragment() as? Filterable)?.setSearchVisibility(visible)
+ }
- override fun allowedToExpand() = getCurrentFragment().allowedToExpand()
+ override fun allowedToExpand() = (getCurrentFragment() as? Filterable)?.allowedToExpand() ?: false
}
More information about the Android
mailing list