Merge pull request #2889 from Bnyro/master

Fix cloning playlists in the create playlist dialog
This commit is contained in:
Bnyro 2023-01-28 18:02:36 +01:00 committed by GitHub
commit 7193062f49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()
}