diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/AddToPlaylistDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/AddToPlaylistDialog.kt index fb333acd5..1c052f2d1 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/AddToPlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/AddToPlaylistDialog.kt @@ -11,7 +11,6 @@ import androidx.fragment.app.activityViewModels import androidx.lifecycle.lifecycleScope import com.github.libretube.R import com.github.libretube.api.PlaylistsHelper -import com.github.libretube.constants.IntentData import com.github.libretube.databinding.DialogAddtoplaylistBinding import com.github.libretube.extensions.TAG import com.github.libretube.extensions.toastFromMainThread @@ -22,14 +21,13 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -class AddToPlaylistDialog : DialogFragment() { +class AddToPlaylistDialog( + private val videoId: String +) : DialogFragment() { private lateinit var binding: DialogAddtoplaylistBinding private val viewModel: PlaylistViewModel by activityViewModels() - private lateinit var videoId: String - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - videoId = arguments?.getString(IntentData.videoId)!! binding = DialogAddtoplaylistBinding.inflate(layoutInflater) binding.title.text = ThemeHelper.getStyledAppName(requireContext()) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index eadf776b6..e0f4be3c4 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -942,18 +942,11 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { streams.uploader ) - if (token != "") { - binding.relPlayerSave.setOnClickListener { - val newFragment = AddToPlaylistDialog() - val bundle = Bundle() - bundle.putString(IntentData.videoId, videoId) - newFragment.arguments = bundle - newFragment.show(childFragmentManager, AddToPlaylistDialog::class.java.name) - } - } else { - binding.relPlayerSave.setOnClickListener { - Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show() - } + binding.relPlayerSave.setOnClickListener { + AddToPlaylistDialog(videoId!!).show( + childFragmentManager, + AddToPlaylistDialog::class.java.name + ) } // next and previous buttons diff --git a/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt index 2e26bf4cf..354df30bb 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/VideoOptionsBottomSheet.kt @@ -1,10 +1,8 @@ package com.github.libretube.ui.sheets import android.os.Bundle -import androidx.core.os.bundleOf import com.github.libretube.R import com.github.libretube.api.RetrofitInstance -import com.github.libretube.constants.IntentData import com.github.libretube.enums.ShareObjectType import com.github.libretube.extensions.toStreamItem import com.github.libretube.obj.ShareData @@ -52,9 +50,7 @@ class VideoOptionsBottomSheet( } // Add Video to Playlist Dialog context?.getString(R.string.addToPlaylist) -> { - AddToPlaylistDialog().apply { - arguments = bundleOf(IntentData.videoId to videoId) - }.show( + AddToPlaylistDialog(videoId).show( parentFragmentManager, AddToPlaylistDialog::class.java.name )