[Android] Add URI extension to remove query portion

Robert Stone git at videolan.org
Fri Jul 9 09:12:04 UTC 2021


vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Tue Jul  6 22:15:09 2021 -0700| [934bda0f120f3199c4aaff3a1ad1c6b86227bfcf] | committer: Nicolas Pomepuy

Add URI extension to remove query portion

> https://code.videolan.org/videolan/vlc-android/commit/934bda0f120f3199c4aaff3a1ad1c6b86227bfcf
---

 .../src/main/java/org/videolan/tools/KotlinExtensions.kt     | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/application/tools/src/main/java/org/videolan/tools/KotlinExtensions.kt b/application/tools/src/main/java/org/videolan/tools/KotlinExtensions.kt
index 77c8697eb..69d68124b 100644
--- a/application/tools/src/main/java/org/videolan/tools/KotlinExtensions.kt
+++ b/application/tools/src/main/java/org/videolan/tools/KotlinExtensions.kt
@@ -9,7 +9,6 @@ import android.content.Context
 import android.content.res.Resources
 import android.net.ConnectivityManager
 import android.net.Uri
-import android.util.Log
 import android.util.Patterns
 import android.util.TypedValue
 import android.view.View
@@ -139,3 +138,14 @@ fun Uri?.retrieveParent(): Uri? {
     }
     return null
 }
+
+fun Uri?.removeQuery(): Uri? {
+    try {
+        if (this == null) return null
+        val builder = Uri.Builder().scheme(scheme).authority(authority)
+        pathSegments.forEach { builder.appendPath(it) }
+        return builder.build()
+    } catch (e: Exception) {
+    }
+    return null
+}



More information about the Android mailing list