Fix cloning playlists in the create playlist dialog

This commit is contained in:
Bnyro 2023-01-28 18:02:13 +01:00
parent 326df3970a
commit 1eb50adf5e

View File

@ -1,6 +1,7 @@
package com.github.libretube.ui.dialogs package com.github.libretube.ui.dialogs
import android.app.Dialog import android.app.Dialog
import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.widget.Toast import android.widget.Toast
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
@ -24,11 +25,12 @@ class CreatePlaylistDialog(
binding.clonePlaylist.setOnClickListener { binding.clonePlaylist.setOnClickListener {
val playlistUrl = binding.playlistUrl.text.toString() 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() Toast.makeText(context, R.string.invalid_url, Toast.LENGTH_SHORT).show()
return@setOnClickListener return@setOnClickListener
} }
PlaylistsHelper.clonePlaylist(requireContext().applicationContext, playlistUrl) PlaylistsHelper.clonePlaylist(requireContext().applicationContext, playlistId)
dismiss() dismiss()
} }