From 1eb50adf5ef25bdb835cdd4116b862a53f8fb2f6 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 28 Jan 2023 18:02:13 +0100 Subject: [PATCH] Fix cloning playlists in the create playlist dialog --- .../com/github/libretube/ui/dialogs/CreatePlaylistDialog.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/CreatePlaylistDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/CreatePlaylistDialog.kt index 9b8c98027..5fbce2408 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/CreatePlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/CreatePlaylistDialog.kt @@ -1,6 +1,7 @@ package com.github.libretube.ui.dialogs import android.app.Dialog +import android.net.Uri import android.os.Bundle import android.widget.Toast import androidx.fragment.app.DialogFragment @@ -24,11 +25,12 @@ class CreatePlaylistDialog( binding.clonePlaylist.setOnClickListener { val playlistUrl = binding.playlistUrl.text.toString() - if (!TextUtils.validateUrl(playlistUrl)) { + val playlistId = Uri.parse(playlistUrl).getQueryParameter("list") + if (!TextUtils.validateUrl(playlistUrl) || playlistId == null) { Toast.makeText(context, R.string.invalid_url, Toast.LENGTH_SHORT).show() return@setOnClickListener } - PlaylistsHelper.clonePlaylist(requireContext().applicationContext, playlistUrl) + PlaylistsHelper.clonePlaylist(requireContext().applicationContext, playlistId) dismiss() }