[Android] Fix FAB visibility for audio and video fragments
Nicolas Pomepuy
git at videolan.org
Thu Dec 10 08:15:05 CET 2020
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Dec 10 08:02:01 2020 +0100| [88edbaabc7fe1613559a9d283c2d84277de9dab5] | committer: Nicolas Pomepuy
Fix FAB visibility for audio and video fragments
Fixes #1570
> https://code.videolan.org/videolan/vlc-android/commit/88edbaabc7fe1613559a9d283c2d84277de9dab5
---
application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt | 3 +++
.../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt | 6 +++---
.../vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt | 2 +-
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt
index 92a82caf7..301b9c824 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/BaseFragment.kt
@@ -2,6 +2,7 @@ package org.videolan.vlc.gui
import android.content.Intent
import android.os.Bundle
+import android.util.Log
import android.view.Menu
import android.view.View
import androidx.appcompat.app.AppCompatActivity
@@ -18,6 +19,7 @@ import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.resources.AndroidDevices
import org.videolan.resources.TAG_ITEM
import org.videolan.tools.retrieveParent
+import org.videolan.vlc.BuildConfig
import org.videolan.vlc.R
import org.videolan.vlc.gui.browser.KEY_MEDIA
import org.videolan.vlc.gui.helpers.FloatingActionButtonBehavior
@@ -102,6 +104,7 @@ abstract class BaseFragment : Fragment(), ActionMode.Callback {
protected open fun hasFAB() = ::swipeRefreshLayout.isInitialized
open fun setFabPlayVisibility(enable: Boolean) {
+ if (BuildConfig.DEBUG) Log.d("FAB", "setFabPlayVisibility $enable", NullPointerException())
fabPlay?.run {
if (enable) show() else hide()
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
index 863675bd2..357b53014 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
@@ -200,6 +200,7 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>() {
lists[index].scrollToPosition(it)
restorePositions.delete(index)
}
+ setFabPlayShuffleAllVisibility(items.isNotEmpty())
})
provider.loading.observe(viewLifecycleOwner, { loading ->
if (loading == null || currentTab != index) return at observe
@@ -272,8 +273,8 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>() {
MediaUtils.playAll(activity, viewModel.tracksProvider, 0, true)
}
- private fun setFabPlayShuffleAllVisibility() {
- setFabPlayVisibility(songsAdapter.itemCount > 2)
+ private fun setFabPlayShuffleAllVisibility(force: Boolean = false) {
+ setFabPlayVisibility(force || songsAdapter.itemCount > 2)
}
override fun getTitle(): String = getString(R.string.audio)
@@ -282,7 +283,6 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>() {
private fun updateEmptyView() {
empty_loading.state = if (viewModel.providers[currentTab].loading.value == true && empty) EmptyLoadingState.LOADING else if (empty) EmptyLoadingState.EMPTY else EmptyLoadingState.NONE
- setFabPlayShuffleAllVisibility()
}
override fun onPageSelected(position: Int) {
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
index cebd6458b..22e270afb 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.kt
@@ -122,12 +122,12 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
updateEmptyView()
restoreMultiSelectHelper()
if (activity?.isFinishing == false && viewModel.group != null && it.size < 2) requireActivity().finish()
+ setFabPlayVisibility(true)
})
viewModel.provider.loading.observe(this, { loading ->
setRefreshing(loading) { refresh ->
if (!refresh) {
- setFabPlayVisibility(true)
menu?.let { UiTools.updateSortTitles(it, viewModel.provider) }
restoreMultiSelectHelper()
}
More information about the Android
mailing list