This commit is contained in:
Bnyro 2022-07-08 14:16:22 +02:00
parent c996b584a5
commit 283e74062d
3 changed files with 6 additions and 10 deletions

View File

@ -17,7 +17,6 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.squareup.picasso.Picasso
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import retrofit2.HttpException
import java.io.IOException

View File

@ -7,8 +7,6 @@ import android.util.Log
import android.widget.ArrayAdapter
import android.widget.Toast
import androidx.fragment.app.DialogFragment
import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController
import com.github.libretube.R
import com.github.libretube.obj.PlaylistId
import com.github.libretube.preferences.PreferenceHelper
@ -16,7 +14,6 @@ import com.github.libretube.util.RetrofitInstance
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import retrofit2.HttpException
import java.io.IOException
@ -36,8 +33,8 @@ class PlaylistOptionsDialog(
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
if (isOwner) {
optionsList = optionsList +
context?.getString(R.string.deletePlaylist)!! -
context?.getString(R.string.clonePlaylist)!!
context?.getString(R.string.deletePlaylist)!! -
context?.getString(R.string.clonePlaylist)!!
}
val dialog = MaterialAlertDialogBuilder(requireContext())

View File

@ -43,14 +43,14 @@ class VideoOptionsDialog(private val videoId: String, context: Context) : Dialog
) { _, which ->
// For now, this checks the position of the option with the position that is in the
// list. I don't like it, but we will do like this for now.
when (which) {
when (optionsList[which]) {
// This for example will be the "Background mode" option
0 -> {
context?.getString(R.string.playOnBackground) -> {
BackgroundMode.getInstance()
.playOnBackgroundMode(requireContext(), videoId)
}
// Add Video to Playlist Dialog
1 -> {
context?.getString(R.string.addToPlaylist) -> {
val token = PreferenceHelper.getToken(requireContext())
if (token != "") {
val newFragment = AddtoPlaylistDialog()
@ -62,7 +62,7 @@ class VideoOptionsDialog(private val videoId: String, context: Context) : Dialog
Toast.makeText(context, R.string.login_first, Toast.LENGTH_SHORT).show()
}
}
2 -> {
context?.getString(R.string.share) -> {
val shareDialog = ShareDialog(videoId, false)
// using parentFragmentManager is important here
shareDialog.show(parentFragmentManager, "ShareDialog")