mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-01-06 01:20:29 +05:30
added videooptionddialog to playlists
This commit is contained in:
parent
37160bcd74
commit
ab78047bd1
@ -13,8 +13,8 @@ import androidx.lifecycle.lifecycleScope
|
|||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.libretube.adapters.PlaylistAdapter
|
import com.github.libretube.adapters.PlaylistAdapter
|
||||||
import java.io.IOException
|
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
class PlaylistFragment : Fragment() {
|
class PlaylistFragment : Fragment() {
|
||||||
private var playlist_id: String? = null
|
private var playlist_id: String? = null
|
||||||
@ -80,7 +80,8 @@ class PlaylistFragment : Fragment() {
|
|||||||
response.relatedStreams!!.toMutableList(),
|
response.relatedStreams!!.toMutableList(),
|
||||||
playlist_id!!,
|
playlist_id!!,
|
||||||
isOwner,
|
isOwner,
|
||||||
requireActivity()
|
requireActivity(),
|
||||||
|
childFragmentManager
|
||||||
)
|
)
|
||||||
view.findViewById<RecyclerView>(R.id.playlist_recView).adapter = playlistAdapter
|
view.findViewById<RecyclerView>(R.id.playlist_recView).adapter = playlistAdapter
|
||||||
val scrollView = view.findViewById<ScrollView>(R.id.playlist_scrollview)
|
val scrollView = view.findViewById<ScrollView>(R.id.playlist_scrollview)
|
||||||
|
@ -7,7 +7,6 @@ import android.os.Bundle
|
|||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
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
|
// Add Video to Playlist Dialog
|
||||||
1 -> {
|
1 -> {
|
||||||
val sharedPreferences = PreferenceManager
|
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||||
.getDefaultSharedPreferences(requireContext())
|
val token = sharedPref?.getString("token", "")
|
||||||
val token = sharedPreferences.getString("token", "")
|
|
||||||
if (token != "") {
|
if (token != "") {
|
||||||
val newFragment = AddtoPlaylistDialog()
|
val newFragment = AddtoPlaylistDialog()
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
|
@ -11,23 +11,26 @@ import android.view.ViewGroup
|
|||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.libretube.PlayerFragment
|
import com.github.libretube.PlayerFragment
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.RetrofitInstance
|
import com.github.libretube.RetrofitInstance
|
||||||
|
import com.github.libretube.VideoOptionsDialog
|
||||||
import com.github.libretube.obj.PlaylistId
|
import com.github.libretube.obj.PlaylistId
|
||||||
import com.github.libretube.obj.StreamItem
|
import com.github.libretube.obj.StreamItem
|
||||||
import com.squareup.picasso.Picasso
|
import com.squareup.picasso.Picasso
|
||||||
import java.io.IOException
|
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
class PlaylistAdapter(
|
class PlaylistAdapter(
|
||||||
private val videoFeed: MutableList<StreamItem>,
|
private val videoFeed: MutableList<StreamItem>,
|
||||||
private val playlistId: String,
|
private val playlistId: String,
|
||||||
private val isOwner: Boolean,
|
private val isOwner: Boolean,
|
||||||
private val activity: Activity
|
private val activity: Activity,
|
||||||
|
private val childFragmentManager: FragmentManager
|
||||||
) : RecyclerView.Adapter<PlaylistViewHolder>() {
|
) : RecyclerView.Adapter<PlaylistViewHolder>() {
|
||||||
private val TAG = "PlaylistAdapter"
|
private val TAG = "PlaylistAdapter"
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
@ -66,6 +69,13 @@ class PlaylistAdapter(
|
|||||||
.replace(R.id.container, frag)
|
.replace(R.id.container, frag)
|
||||||
.commitNow()
|
.commitNow()
|
||||||
}
|
}
|
||||||
|
holder.v.setOnLongClickListener {
|
||||||
|
val videoId = streamItem.url!!.replace("/watch?v=", "")
|
||||||
|
VideoOptionsDialog(videoId, holder.v.context)
|
||||||
|
.show(childFragmentManager, VideoOptionsDialog.TAG)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
if (isOwner) {
|
if (isOwner) {
|
||||||
val delete = holder.v.findViewById<ImageView>(R.id.delete_playlist)
|
val delete = holder.v.findViewById<ImageView>(R.id.delete_playlist)
|
||||||
delete.visibility = View.VISIBLE
|
delete.visibility = View.VISIBLE
|
||||||
|
Loading…
Reference in New Issue
Block a user