[Android] Browser: Don't show loading at root level
Geoffrey Métais
git at videolan.org
Mon Sep 23 18:10:49 CEST 2019
vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Sep 16 16:04:57 2019 +0200| [9e2b2361a4d3294449ce7e002615eb90433cd977] | committer: Geoffrey Métais
Browser: Don't show loading at root level
(cherry picked from commit 175c098d7be0bb6e868baf48254aa19017678bcc)
> https://code.videolan.org/videolan/vlc-android/commit/9e2b2361a4d3294449ce7e002615eb90433cd977
---
.../videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt | 15 +++++++--------
.../videolan/vlc/gui/tv/browser/VerticalGridActivity.kt | 4 +---
.../src/org/videolan/vlc/providers/BrowserProvider.kt | 6 +++---
3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
index 96f431e2f..3f584312b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
@@ -38,6 +38,7 @@ import org.videolan.vlc.viewmodels.browser.TYPE_FILE
import org.videolan.vlc.viewmodels.browser.TYPE_NETWORK
import org.videolan.vlc.viewmodels.browser.getBrowserModel
+private const val TAG = "FileBrowserTvFragment"
@UseExperimental(ObsoleteCoroutinesApi::class)
@ExperimentalCoroutinesApi
class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
@@ -89,9 +90,7 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
else arguments?.getParcelable(ITEM) as? MediaLibraryItem
viewModel = getBrowserModel(getCategory(), (item as? AbstractMediaWrapper)?.location, true, false)
- item?.let {
- mrl = (it as MediaWrapper).location
- }
+ (item as? MediaWrapper)?.run { mrl = location }
viewModel.currentItem = item
browserFavRepository = BrowserFavRepository.getInstance(requireContext())
@@ -108,8 +107,8 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
}
}
}
- if (BuildConfig.DEBUG) Log.d("FileBrowserTvFragment", "Submit lis of ${items.size} items")
- if (BuildConfig.DEBUG) Log.d("FileBrowserTvFragment", "header size: ${viewModel.provider.headers.size()}")
+ if (BuildConfig.DEBUG) Log.d(TAG, "Submit list of ${items.size} items")
+ if (BuildConfig.DEBUG) Log.d(TAG, "header size: ${viewModel.provider.headers.size()}")
//headers
val nbColumns = if ((viewModel as BrowserModel).sort == AbstractMedialibrary.SORT_ALPHA || (viewModel as BrowserModel).sort == AbstractMedialibrary.SORT_DEFAULT) 9 else 1
@@ -128,12 +127,12 @@ class FileBrowserTvFragment : BaseBrowserTvFragment(), PathAdapterListener {
(viewModel as BrowserModel).provider.liveHeaders.observe(this, Observer {
headerAdapter.notifyDataSetChanged()
- if (BuildConfig.DEBUG) Log.d("FileBrowserTvFragment", "header size (observe): ${viewModel.provider.headers.size()}")
+ if (BuildConfig.DEBUG) Log.d(TAG, "header size (observe): ${viewModel.provider.headers.size()}")
})
(viewModel as BrowserModel).getDescriptionUpdate().observe(this, Observer { pair ->
- if (BuildConfig.DEBUG) Log.d("FileBrowserTvFragment", "Description update: ${pair.first} ${pair.second}")
- if (BuildConfig.DEBUG) Log.d("FileBrowserTvFragment", "header size (desc): ${viewModel.provider.headers.size()}")
+ if (BuildConfig.DEBUG) Log.d(TAG, "Description update: ${pair.first} ${pair.second}")
+ if (BuildConfig.DEBUG) Log.d(TAG, "header size (desc): ${viewModel.provider.headers.size()}")
if (pair != null) (adapter as RecyclerView.Adapter<*>).notifyItemChanged(pair.first)
})
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt
index b308b1a2e..483e2af82 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.kt
@@ -94,10 +94,8 @@ class VerticalGridActivity : BaseTvActivity(), BrowserActivityInterface {
(fragment as DetailsFragment).showDetails()
return true
}
- if (fragment is OnKeyPressedListener) {
- if ((fragment as OnKeyPressedListener).onKeyPressed(keyCode)) {
+ if ((fragment as? OnKeyPressedListener)?.onKeyPressed(keyCode) == true) {
return true
- }
}
}
return super.onKeyDown(keyCode, event)
diff --git a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
index 6fabaaa54..7acc98985 100644
--- a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
@@ -115,7 +115,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
}
protected open fun browse(url: String? = null) {
- loading.postValue(true)
+ if (url != null ) loading.postValue(true)
browserActor.post(Browse(url))
}
@@ -130,7 +130,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
dataset.value = value as MutableList<MediaLibraryItem>
parseSubDirectories(value)
}
- loading.postValue(false)
+ if (url != null ) loading.postValue(false)
}
private suspend fun filesFlow(url: String? = this.url, interact : Boolean = true) = withContext(Dispatchers.IO) {
@@ -280,7 +280,7 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
open fun release() {
cancel()
- loading.postValue(false)
+ if (url != null) loading.postValue(false)
}
protected fun getList(url: String) = prefetchLists[url]
More information about the Android
mailing list