Commit 175c098d authored by Geoffrey Métais's avatar Geoffrey Métais Committed by Geoffrey Métais
Browse files

Browser: Don't show loading at root level

parent e2252491
......@@ -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)
})
......
......@@ -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)
......
......@@ -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]
......
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