Skip to content
Snippets Groups Projects
Commit 55a71922 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Restrict breadcrumb to supported protocoles

parent 7e8c3430
No related branches found
No related tags found
No related merge requests found
......@@ -113,9 +113,7 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
if (sortItem != null) sortItem.isVisible = !isRootDirectory
}
protected open fun defineIsRoot(): Boolean {
return mrl == null
}
protected open fun defineIsRoot() = mrl == null
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
binding = DirectoryBrowserBinding.inflate(inflater, container, false)
......@@ -132,20 +130,20 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
viewModel.dataset.observe(this, Observer<MutableList<MediaLibraryItem>> { mediaLibraryItems -> adapter.update(mediaLibraryItems!!) })
viewModel.getDescriptionUpdate().observe(this, Observer { pair -> if (pair != null) adapter.notifyItemChanged(pair.first, pair.second) })
}
override fun setBreadcrumb() {
val ariane = requireActivity().findViewById<RecyclerView>(R.id.ariane) ?: return
currentMedia?.let {
val media = currentMedia
if (media != null && isSchemeSupported(media?.uri?.scheme)) {
ariane.visibility = View.VISIBLE
ariane.layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
ariane.adapter = PathAdapter(this, Uri.decode(it.uri.path))
ariane.adapter = PathAdapter(this, Uri.decode(media.uri.path))
if (ariane.itemDecorationCount == 0) {
val did = DividerItemDecoration(requireContext(), DividerItemDecoration.HORIZONTAL)
did.setDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.divider_grey_50_18dp)!!)
ariane.addItemDecoration(did)
}
ariane.scrollToPosition(ariane.adapter.itemCount - 1)
} ?: run { ariane.visibility = View.GONE }
} else ariane.visibility = View.GONE
}
fun backTo(tag: String) {
......@@ -273,9 +271,7 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
}
}
override fun clear() {
adapter.clear()
}
override fun clear() = adapter.clear()
private fun removeMedia(mw: MediaWrapper) {
viewModel.remove(mw)
......
/*****************************************************************************
* browserutils.kt
*****************************************************************************
* Copyright © 2018 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
package org.videolan.vlc.util
fun isSchemeSupported(scheme: String?) = when(scheme) {
"file", "smb", "ssh", "nfs" -> true
else -> false
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment