[Android] Fix history clean menu appearance

Nicolas Pomepuy git at videolan.org
Mon Jul 29 14:08:43 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Fri Jul 26 13:03:26 2019 +0200| [99c33ae0a7c944d0823bfe5a5fc4109710bbe4cd] | committer: Nicolas Pomepuy

Fix history clean menu appearance

> https://code.videolan.org/videolan/vlc-android/commit/99c33ae0a7c944d0823bfe5a5fc4109710bbe4cd
---

 vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
index 075d0550c..2e4896017 100644
--- a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
@@ -52,6 +52,7 @@ private const val TAG = "VLC/HistoryFragment"
 @ExperimentalCoroutinesApi
 class HistoryFragment : MediaBrowserFragment<HistoryModel>(), IRefreshable, IHistory, SwipeRefreshLayout.OnRefreshListener, IEventsHandler {
 
+    private lateinit var cleanMenuItem: MenuItem
     private lateinit var multiSelectHelper: MultiSelectHelper<AbstractMediaWrapper>
     private val historyAdapter: HistoryAdapter = HistoryAdapter(this)
 
@@ -67,6 +68,9 @@ class HistoryFragment : MediaBrowserFragment<HistoryModel>(), IRefreshable, IHis
             list?.let {
                 historyAdapter.update(it)
                 updateEmptyView()
+                if (::cleanMenuItem.isInitialized) {
+                    cleanMenuItem.isVisible = !isEmpty()
+                }
             }
         })
         viewModel.loading.observe(this, Observer {
@@ -100,7 +104,8 @@ class HistoryFragment : MediaBrowserFragment<HistoryModel>(), IRefreshable, IHis
     }
 
     override fun onPrepareOptionsMenu(menu: Menu) {
-        menu.findItem(R.id.ml_menu_clean).isVisible = !isEmpty()
+        cleanMenuItem = menu.findItem(R.id.ml_menu_clean)
+        cleanMenuItem.isVisible = !isEmpty()
         super.onPrepareOptionsMenu(menu)
     }
 



More information about the Android mailing list