Skip to content
Snippets Groups Projects
Commit 4d15600b authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais
Browse files

Fix hiding "scan folder" menu if folder is scanned

Refs #1060
parent 35c758dd
No related branches found
No related tags found
1 merge request!273Infoactivity fixes
......@@ -8,10 +8,7 @@ import androidx.core.content.ContextCompat
import org.videolan.medialibrary.interfaces.AbstractMedialibrary
import org.videolan.vlc.MediaParsingService
import org.videolan.vlc.VLCApplication
import org.videolan.vlc.util.ACTION_DISCOVER
import org.videolan.vlc.util.ACTION_DISCOVER_DEVICE
import org.videolan.vlc.util.EXTRA_PATH
import org.videolan.vlc.util.runIO
import org.videolan.vlc.util.*
object MedialibraryUtils {
......@@ -36,7 +33,7 @@ object MedialibraryUtils {
//scheme is supported => test if the parent is scanned
var isScanned = false
AbstractMedialibrary.getInstance().foldersList.forEach search@{
if (path.startsWith(Uri.parse(it).toString())) {
if (path.stripTrailingSlash().startsWith(Uri.parse(it).toString().stripTrailingSlash())) {
isScanned = true
return@search
}
......
......@@ -26,9 +26,7 @@ import java.text.DecimalFormat
private const val TAG = "VLC/UiTools/Strings"
fun stripTrailingSlash(s: String): String {
return if (s.endsWith("/") && s.length > 1) s.substring(0, s.length - 1) else s
}
fun String.stripTrailingSlash() = if (endsWith("/") && length > 1) dropLast(1) else this
//TODO: Remove this after convert the dependent code to kotlin
fun startsWith(array: Array<String>, text: String) = array.any { text.startsWith(it)}
......
......@@ -10,11 +10,9 @@ class StringsTest {
@Test
fun stripTrailingSlash() {
var s = stripTrailingSlash("foo/")
assertEquals(s, "foo")
assertEquals("foo/".stripTrailingSlash(), "foo")
s = stripTrailingSlash("bar")
assertEquals(s, "bar")
assertEquals("bar".stripTrailingSlash(), "bar")
}
@Test
......
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