Merge pull request #1985 from Bnyro/master

enable save button at player fragment for local playlists
This commit is contained in:
Bnyro 2022-11-22 16:50:45 +01:00 committed by GitHub
commit 8a764b0397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 22 deletions

View File

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

View File

@ -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()
}
AddToPlaylistDialog(videoId!!).show(
childFragmentManager,
AddToPlaylistDialog::class.java.name
)
}
// next and previous buttons

View File

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