This commit is contained in:
Bnyro 2022-05-30 17:47:54 +02:00
parent 16cccc0a5d
commit a5c0f3154b
3 changed files with 14 additions and 9 deletions

View File

@ -27,11 +27,11 @@ import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.adapters.SearchAdapter import com.github.libretube.adapters.SearchAdapter
import com.github.libretube.adapters.SearchHistoryAdapter import com.github.libretube.adapters.SearchHistoryAdapter
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import java.io.IOException
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException
class SearchFragment : Fragment() { class SearchFragment : Fragment() {
private val TAG = "SearchFragment" private val TAG = "SearchFragment"

View File

@ -9,7 +9,6 @@ import android.widget.Toast
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import java.net.URLEncoder
/** /**
* Dialog with different options for a selected video. * Dialog with different options for a selected video.
@ -52,11 +51,12 @@ class VideoOptionsDialog(private val videoId: String, context: Context) : Dialog
} }
// Add Video to Playlist Dialog // Add Video to Playlist Dialog
1 -> { 1 -> {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()) val sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(requireContext())
val token = sharedPreferences.getString("token", "") val token = sharedPreferences.getString("token", "")
if (token != "") { if (token != "") {
val newFragment = AddtoPlaylistDialog() val newFragment = AddtoPlaylistDialog()
var bundle = Bundle() val bundle = Bundle()
bundle.putString("videoId", videoId) bundle.putString("videoId", videoId)
newFragment.arguments = bundle newFragment.arguments = bundle
newFragment.show(parentFragmentManager, "AddToPlaylist") newFragment.show(parentFragmentManager, "AddToPlaylist")
@ -65,6 +65,7 @@ class VideoOptionsDialog(private val videoId: String, context: Context) : Dialog
} }
} }
2 -> { 2 -> {
/* crashes
val sharedPreferences = val sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(requireContext()) PreferenceManager.getDefaultSharedPreferences(requireContext())
val instancePref = sharedPreferences.getString( val instancePref = sharedPreferences.getString(
@ -77,8 +78,6 @@ class VideoOptionsDialog(private val videoId: String, context: Context) : Dialog
getString(R.string.instance), getString(R.string.instance),
getString(R.string.youtube) getString(R.string.youtube)
) )
/*
// crashes
MaterialAlertDialogBuilder(requireContext()) MaterialAlertDialogBuilder(requireContext())
.setTitle(getString(R.string.share)) .setTitle(getString(R.string.share))
.setItems( .setItems(
@ -101,7 +100,10 @@ class VideoOptionsDialog(private val videoId: String, context: Context) : Dialog
*/ */
val intent = Intent() val intent = Intent()
intent.action = Intent.ACTION_SEND intent.action = Intent.ACTION_SEND
intent.putExtra(Intent.EXTRA_TEXT, "https://piped.kavin.rocks/watch?v=$videoId") intent.putExtra(
Intent.EXTRA_TEXT,
"https://piped.kavin.rocks/watch?v=$videoId"
)
intent.type = "text/plain" intent.type = "text/plain"
startActivity(Intent.createChooser(intent, "Share Url To:")) startActivity(Intent.createChooser(intent, "Share Url To:"))
} }

View File

@ -11,10 +11,13 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.* import com.github.libretube.MainActivity
import com.github.libretube.PlayerFragment
import com.github.libretube.R
import com.github.libretube.VideoOptionsDialog
import com.github.libretube.formatShort
import com.github.libretube.obj.SearchItem import com.github.libretube.obj.SearchItem
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import kotlinx.coroutines.NonDisposableHandle.parent
class SearchAdapter( class SearchAdapter(
private val searchItems: MutableList<SearchItem>, private val searchItems: MutableList<SearchItem>,