[Android] Restrict breadcrumb to supported protocoles
Geoffrey Métais
git at videolan.org
Thu Aug 2 11:17:07 CEST 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Aug 2 11:07:40 2018 +0200| [55a7192292e63da854a780e03c883e7dabd05638] | committer: Geoffrey Métais
Restrict breadcrumb to supported protocoles
> https://code.videolan.org/videolan/vlc-android/commit/55a7192292e63da854a780e03c883e7dabd05638
---
.../vlc/gui/browser/BaseBrowserFragment.kt | 16 +++++--------
.../src/org/videolan/vlc/util/Browserutils.kt | 27 ++++++++++++++++++++++
2 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
index 6a9fd79e8..0c4e3498d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -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)
diff --git a/vlc-android/src/org/videolan/vlc/util/Browserutils.kt b/vlc-android/src/org/videolan/vlc/util/Browserutils.kt
new file mode 100644
index 000000000..acdcb101e
--- /dev/null
+++ b/vlc-android/src/org/videolan/vlc/util/Browserutils.kt
@@ -0,0 +1,27 @@
+/*****************************************************************************
+ * 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
More information about the Android
mailing list