added videooptionddialog to playlists

This commit is contained in:
Bnyro 2022-06-02 17:01:35 +02:00
parent 37160bcd74
commit ab78047bd1
3 changed files with 17 additions and 8 deletions

View File

@ -13,8 +13,8 @@ import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.adapters.PlaylistAdapter
import java.io.IOException
import retrofit2.HttpException
import java.io.IOException
class PlaylistFragment : Fragment() {
private var playlist_id: String? = null
@ -80,7 +80,8 @@ class PlaylistFragment : Fragment() {
response.relatedStreams!!.toMutableList(),
playlist_id!!,
isOwner,
requireActivity()
requireActivity(),
childFragmentManager
)
view.findViewById<RecyclerView>(R.id.playlist_recView).adapter = playlistAdapter
val scrollView = view.findViewById<ScrollView>(R.id.playlist_scrollview)

View File

@ -7,7 +7,6 @@ import android.os.Bundle
import android.widget.ArrayAdapter
import android.widget.Toast
import androidx.fragment.app.DialogFragment
import androidx.preference.PreferenceManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
/**
@ -51,9 +50,8 @@ class VideoOptionsDialog(private val videoId: String, context: Context) : Dialog
}
// Add Video to Playlist Dialog
1 -> {
val sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(requireContext())
val token = sharedPreferences.getString("token", "")
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
val token = sharedPref?.getString("token", "")
if (token != "") {
val newFragment = AddtoPlaylistDialog()
val bundle = Bundle()

View File

@ -11,23 +11,26 @@ import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.PlayerFragment
import com.github.libretube.R
import com.github.libretube.RetrofitInstance
import com.github.libretube.VideoOptionsDialog
import com.github.libretube.obj.PlaylistId
import com.github.libretube.obj.StreamItem
import com.squareup.picasso.Picasso
import java.io.IOException
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import retrofit2.HttpException
import java.io.IOException
class PlaylistAdapter(
private val videoFeed: MutableList<StreamItem>,
private val playlistId: String,
private val isOwner: Boolean,
private val activity: Activity
private val activity: Activity,
private val childFragmentManager: FragmentManager
) : RecyclerView.Adapter<PlaylistViewHolder>() {
private val TAG = "PlaylistAdapter"
override fun getItemCount(): Int {
@ -66,6 +69,13 @@ class PlaylistAdapter(
.replace(R.id.container, frag)
.commitNow()
}
holder.v.setOnLongClickListener {
val videoId = streamItem.url!!.replace("/watch?v=", "")
VideoOptionsDialog(videoId, holder.v.context)
.show(childFragmentManager, VideoOptionsDialog.TAG)
true
}
if (isOwner) {
val delete = holder.v.findViewById<ImageView>(R.id.delete_playlist)
delete.visibility = View.VISIBLE