mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 13:50:30 +05:30
Lint
This commit is contained in:
parent
5c420b773c
commit
a2339672c6
@ -1,13 +1,11 @@
|
||||
package com.github.libretube
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
@ -21,4 +19,4 @@ class ExampleInstrumentedTest {
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.github.libretube", appContext.packageName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,9 @@ import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.github.libretube.adapters.PlaylistsAdapter
|
||||
import com.github.libretube.obj.PlaylistId
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
import retrofit2.HttpException
|
||||
|
||||
class AddtoPlaylistDialog : DialogFragment() {
|
||||
private val TAG = "AddToPlaylistDialog"
|
||||
@ -26,77 +25,74 @@ class AddtoPlaylistDialog : DialogFragment() {
|
||||
videoId = arguments?.getString("videoId")!!
|
||||
val builder = AlertDialog.Builder(it)
|
||||
// Get the layout inflater
|
||||
val inflater = requireActivity().layoutInflater;
|
||||
val inflater = requireActivity().layoutInflater
|
||||
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||
token = sharedPref?.getString("token","")!!
|
||||
token = sharedPref?.getString("token", "")!!
|
||||
var view: View = inflater.inflate(R.layout.dialog_addtoplaylist, null)
|
||||
spinner = view.findViewById(R.id.playlists_spinner)
|
||||
button = view.findViewById(R.id.addToPlaylist)
|
||||
if(token!=""){
|
||||
fetchPlaylists()
|
||||
if (token != "") {
|
||||
fetchPlaylists()
|
||||
}
|
||||
builder.setView(view)
|
||||
builder.create()
|
||||
} ?: throw IllegalStateException("Activity cannot be null")
|
||||
}
|
||||
private fun fetchPlaylists(){
|
||||
private fun fetchPlaylists() {
|
||||
fun run() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.playlists(token)
|
||||
}catch(e: IOException) {
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
Toast.makeText(context,R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
Log.e(TAG, "HttpException, unexpected response")
|
||||
Toast.makeText(context,R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
}
|
||||
if (response.isNotEmpty()){
|
||||
if (response.isNotEmpty()) {
|
||||
var names = emptyList<String>().toMutableList()
|
||||
for(playlist in response){
|
||||
for (playlist in response) {
|
||||
names.add(playlist.name!!)
|
||||
}
|
||||
val arrayAdapter = ArrayAdapter(requireContext(),android.R.layout.simple_spinner_item,names)
|
||||
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
spinner.adapter = arrayAdapter
|
||||
val arrayAdapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, names)
|
||||
arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
spinner.adapter = arrayAdapter
|
||||
runOnUiThread {
|
||||
button.setOnClickListener {
|
||||
addToPlaylist(response[spinner.selectedItemPosition].id!!)
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
} else {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
run()
|
||||
}
|
||||
private fun addToPlaylist(playlistId: String){
|
||||
private fun addToPlaylist(playlistId: String) {
|
||||
fun run() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.addToPlaylist(token, PlaylistId(playlistId, videoId))
|
||||
}catch(e: IOException) {
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
Toast.makeText(context,R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
Log.e(TAG, "HttpException, unexpected response")
|
||||
Toast.makeText(context,R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
}
|
||||
if (response.message == "ok"){
|
||||
Toast.makeText(context,R.string.success, Toast.LENGTH_SHORT).show()
|
||||
if (response.message == "ok") {
|
||||
Toast.makeText(context, R.string.success, Toast.LENGTH_SHORT).show()
|
||||
dialog?.dismiss()
|
||||
}else{
|
||||
Toast.makeText(context,R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
Toast.makeText(context, R.string.fail, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
run()
|
||||
@ -106,4 +102,4 @@ class AddtoPlaylistDialog : DialogFragment() {
|
||||
if (!isAdded) return // Fragment not attached to an Activity
|
||||
activity?.runOnUiThread(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,10 @@
|
||||
package com.github.libretube
|
||||
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils.substring
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -23,18 +20,17 @@ import com.github.libretube.adapters.ChannelAdapter
|
||||
import com.github.libretube.obj.Subscribe
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.squareup.picasso.Picasso
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
|
||||
import retrofit2.HttpException
|
||||
|
||||
class ChannelFragment : Fragment() {
|
||||
|
||||
private var channel_id: String? = null
|
||||
private val TAG = "ChannelFragment"
|
||||
var nextPage: String? =null
|
||||
var nextPage: String? = null
|
||||
var channelAdapter: ChannelAdapter? = null
|
||||
var isLoading = true
|
||||
var isSubscribed: Boolean =false
|
||||
var isSubscribed: Boolean = false
|
||||
private var refreshLayout: SwipeRefreshLayout? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@ -45,20 +41,19 @@ class ChannelFragment : Fragment() {
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_channel, container, false)
|
||||
|
||||
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
channel_id = channel_id!!.replace("/channel/","")
|
||||
view.findViewById<TextView>(R.id.channel_name).text=channel_id
|
||||
channel_id = channel_id!!.replace("/channel/", "")
|
||||
view.findViewById<TextView>(R.id.channel_name).text = channel_id
|
||||
val recyclerView = view.findViewById<RecyclerView>(R.id.channel_recView)
|
||||
recyclerView.layoutManager = LinearLayoutManager(context)
|
||||
refreshLayout = view.findViewById(R.id.channel_refresh)
|
||||
@ -68,7 +63,7 @@ class ChannelFragment : Fragment() {
|
||||
fetchChannel(view)
|
||||
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||
val subButton = view.findViewById<MaterialButton>(R.id.channel_subscribe)
|
||||
if (sharedPref?.getString("token","") != "") {
|
||||
if (sharedPref?.getString("token", "") != "") {
|
||||
isSubscribed(subButton)
|
||||
}
|
||||
}
|
||||
@ -81,28 +76,26 @@ class ChannelFragment : Fragment() {
|
||||
scrollView.viewTreeObserver
|
||||
.addOnScrollChangedListener {
|
||||
if (scrollView.getChildAt(0).bottom
|
||||
== (scrollView.height + scrollView.scrollY)) {
|
||||
//scroll view is at bottom
|
||||
if(nextPage!=null && !isLoading){
|
||||
isLoading=true
|
||||
refreshLayout?.isRefreshing = true;
|
||||
== (scrollView.height + scrollView.scrollY)
|
||||
) {
|
||||
// scroll view is at bottom
|
||||
if (nextPage != null && !isLoading) {
|
||||
isLoading = true
|
||||
refreshLayout?.isRefreshing = true
|
||||
fetchNextPage()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun isSubscribed(button: MaterialButton){
|
||||
private fun isSubscribed(button: MaterialButton) {
|
||||
@SuppressLint("ResourceAsColor")
|
||||
fun run() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||
RetrofitInstance.api.isSubscribed(channel_id!!,sharedPref?.getString("token","")!!)
|
||||
} catch(e: IOException) {
|
||||
RetrofitInstance.api.isSubscribed(channel_id!!, sharedPref?.getString("token", "")!!)
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
return@launchWhenCreated
|
||||
@ -112,33 +105,34 @@ class ChannelFragment : Fragment() {
|
||||
}
|
||||
|
||||
runOnUiThread {
|
||||
if (response.subscribed==true){
|
||||
isSubscribed=true
|
||||
button.text=getString(R.string.unsubscribe)
|
||||
if (response.subscribed == true) {
|
||||
isSubscribed = true
|
||||
button.text = getString(R.string.unsubscribe)
|
||||
}
|
||||
if(response.subscribed!=null){
|
||||
button.setOnClickListener {
|
||||
if(isSubscribed){
|
||||
unsubscribe()
|
||||
button.text=getString(R.string.subscribe)
|
||||
}else{
|
||||
subscribe()
|
||||
button.text=getString(R.string.unsubscribe)
|
||||
if (response.subscribed != null) {
|
||||
button.setOnClickListener {
|
||||
if (isSubscribed) {
|
||||
unsubscribe()
|
||||
button.text = getString(R.string.subscribe)
|
||||
} else {
|
||||
subscribe()
|
||||
button.text = getString(R.string.unsubscribe)
|
||||
}
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
run()
|
||||
}
|
||||
|
||||
private fun subscribe(){
|
||||
private fun subscribe() {
|
||||
fun run() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||
RetrofitInstance.api.subscribe(sharedPref?.getString("token","")!!, Subscribe(channel_id))
|
||||
}catch(e: IOException) {
|
||||
RetrofitInstance.api.subscribe(sharedPref?.getString("token", "")!!, Subscribe(channel_id))
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
return@launchWhenCreated
|
||||
@ -146,18 +140,18 @@ class ChannelFragment : Fragment() {
|
||||
Log.e(TAG, "HttpException, unexpected response$e")
|
||||
return@launchWhenCreated
|
||||
}
|
||||
isSubscribed=true
|
||||
isSubscribed = true
|
||||
}
|
||||
}
|
||||
run()
|
||||
}
|
||||
private fun unsubscribe(){
|
||||
private fun unsubscribe() {
|
||||
fun run() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||
RetrofitInstance.api.unsubscribe(sharedPref?.getString("token","")!!, Subscribe(channel_id))
|
||||
}catch(e: IOException) {
|
||||
RetrofitInstance.api.unsubscribe(sharedPref?.getString("token", "")!!, Subscribe(channel_id))
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
return@launchWhenCreated
|
||||
@ -165,37 +159,37 @@ class ChannelFragment : Fragment() {
|
||||
Log.e(TAG, "HttpException, unexpected response")
|
||||
return@launchWhenCreated
|
||||
}
|
||||
isSubscribed=false
|
||||
isSubscribed = false
|
||||
}
|
||||
}
|
||||
run()
|
||||
}
|
||||
|
||||
private fun fetchChannel(view: View){
|
||||
private fun fetchChannel(view: View) {
|
||||
fun run() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.getChannel(channel_id!!)
|
||||
}catch(e: IOException) {
|
||||
refreshLayout?.isRefreshing = false;
|
||||
} catch (e: IOException) {
|
||||
refreshLayout?.isRefreshing = false
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
refreshLayout?.isRefreshing = false;
|
||||
refreshLayout?.isRefreshing = false
|
||||
Log.e(TAG, "HttpException, unexpected response")
|
||||
return@launchWhenCreated
|
||||
}
|
||||
nextPage = response.nextpage
|
||||
isLoading=false
|
||||
refreshLayout?.isRefreshing = false;
|
||||
isLoading = false
|
||||
refreshLayout?.isRefreshing = false
|
||||
runOnUiThread {
|
||||
view.findViewById<ScrollView>(R.id.channel_scrollView).visibility = View.VISIBLE
|
||||
val channelName = view.findViewById<TextView>(R.id.channel_name)
|
||||
channelName.text = if (response.name?.length!! > 18) response.name.toString().substring(0,16) + "..." else response.name
|
||||
channelName.text = if (response.name?.length!! > 18) response.name.toString().substring(0, 16) + "..." else response.name
|
||||
val channelVerified = view.findViewById<ImageView>(R.id.channel_verified)
|
||||
if (response.verified) channelVerified.visibility = View.VISIBLE
|
||||
view.findViewById<TextView>(R.id.channel_subs).text=resources.getString(R.string.subscribers, response.subscriberCount.formatShort())
|
||||
view.findViewById<TextView>(R.id.channel_subs).text = resources.getString(R.string.subscribers, response.subscriberCount.formatShort())
|
||||
val channelDescription = view.findViewById<TextView>(R.id.channel_description)
|
||||
if (response.description?.trim() == "") channelDescription.visibility = View.GONE else channelDescription.text = response.description?.trim()
|
||||
val bannerImage = view.findViewById<ImageView>(R.id.channel_banner)
|
||||
@ -204,18 +198,17 @@ class ChannelFragment : Fragment() {
|
||||
Picasso.get().load(response.avatarUrl).into(channelImage)
|
||||
channelAdapter = ChannelAdapter(response.relatedStreams!!.toMutableList())
|
||||
view.findViewById<RecyclerView>(R.id.channel_recView).adapter = channelAdapter
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
run()
|
||||
}
|
||||
private fun fetchNextPage(){
|
||||
private fun fetchNextPage() {
|
||||
fun run() {
|
||||
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.getChannelNextPage(channel_id!!,nextPage!!)
|
||||
RetrofitInstance.api.getChannelNextPage(channel_id!!, nextPage!!)
|
||||
} catch (e: IOException) {
|
||||
refreshLayout?.isRefreshing = false
|
||||
println(e)
|
||||
@ -223,12 +216,12 @@ class ChannelFragment : Fragment() {
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
refreshLayout?.isRefreshing = false
|
||||
Log.e(TAG, "HttpException, unexpected response,"+e.response())
|
||||
Log.e(TAG, "HttpException, unexpected response," + e.response())
|
||||
return@launchWhenCreated
|
||||
}
|
||||
nextPage = response.nextpage
|
||||
channelAdapter?.updateItems(response.relatedStreams!!)
|
||||
isLoading=false
|
||||
isLoading = false
|
||||
refreshLayout?.isRefreshing = false
|
||||
}
|
||||
}
|
||||
@ -244,8 +237,8 @@ class ChannelFragment : Fragment() {
|
||||
val scrollView = view?.findViewById<ScrollView>(R.id.channel_scrollView)
|
||||
scrollView?.viewTreeObserver?.removeOnScrollChangedListener {
|
||||
}
|
||||
channelAdapter=null
|
||||
view?.findViewById<RecyclerView>(R.id.channel_recView)?.adapter=null
|
||||
channelAdapter = null
|
||||
view?.findViewById<RecyclerView>(R.id.channel_recView)?.adapter = null
|
||||
super.onDestroyView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,11 +27,10 @@ class CreatePlaylistDialog : DialogFragment() {
|
||||
val createPlaylistBtn = rootView.findViewById<Button>(R.id.create_new_playlist)
|
||||
createPlaylistBtn.setOnClickListener {
|
||||
var listName = playlistName.text.toString()
|
||||
if(listName != "") {
|
||||
if (listName != "") {
|
||||
setFragmentResult("key_parent", bundleOf("playlistName" to "$listName"))
|
||||
dismiss()
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Toast.makeText(context, R.string.emptyPlaylistName, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,11 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import com.google.android.exoplayer2.ui.PlayerView
|
||||
import com.google.android.exoplayer2.ui.StyledPlayerControlView
|
||||
import com.google.android.exoplayer2.ui.StyledPlayerView
|
||||
|
||||
internal class CustomExoPlayerView(
|
||||
context: Context, attributeSet: AttributeSet? = null
|
||||
context: Context,
|
||||
attributeSet: AttributeSet? = null
|
||||
) : StyledPlayerView(context, attributeSet) {
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@ -18,11 +17,11 @@ internal class CustomExoPlayerView(
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
if (isControllerFullyVisible) {
|
||||
hideController()
|
||||
}else {
|
||||
} else {
|
||||
showController()
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,4 +28,4 @@ class CustomSwipeToRefresh(context: Context?, attrs: AttributeSet?) :
|
||||
init {
|
||||
mTouchSlop = ViewConfiguration.get(context).scaledTouchSlop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import android.widget.*
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.DialogFragment
|
||||
|
||||
|
||||
class DownloadDialog : DialogFragment() {
|
||||
private val TAG = "DownloadDialog"
|
||||
var vidName = arrayListOf<String>()
|
||||
@ -34,9 +33,9 @@ class DownloadDialog : DialogFragment() {
|
||||
val inflater = requireActivity().layoutInflater
|
||||
var view: View = inflater.inflate(R.layout.dialog_download, null)
|
||||
val videoSpinner = view.findViewById<Spinner>(R.id.video_spinner)
|
||||
val videoArrayAdapter =ArrayAdapter<String>(requireContext(),android.R.layout.simple_spinner_item,vidName)
|
||||
val videoArrayAdapter = ArrayAdapter<String>(requireContext(), android.R.layout.simple_spinner_item, vidName)
|
||||
videoArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
videoSpinner.adapter=videoArrayAdapter
|
||||
videoSpinner.adapter = videoArrayAdapter
|
||||
videoSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(
|
||||
parent: AdapterView<*>,
|
||||
@ -45,12 +44,12 @@ class DownloadDialog : DialogFragment() {
|
||||
id: Long
|
||||
) {
|
||||
selectedVideo = position
|
||||
Log.d(TAG,selectedVideo.toString())
|
||||
Log.d(TAG, selectedVideo.toString())
|
||||
}
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {}
|
||||
}
|
||||
val audioSpinner = view.findViewById<Spinner>(R.id.audio_spinner)
|
||||
val audioArrayAdapter = ArrayAdapter<String>(requireContext(),android.R.layout.simple_spinner_item,audioName)
|
||||
val audioArrayAdapter = ArrayAdapter<String>(requireContext(), android.R.layout.simple_spinner_item, audioName)
|
||||
audioArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
audioSpinner.adapter = audioArrayAdapter
|
||||
audioSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
@ -61,7 +60,7 @@ class DownloadDialog : DialogFragment() {
|
||||
id: Long
|
||||
) {
|
||||
selectedAudio = position
|
||||
Log.d(TAG,selectedAudio.toString())
|
||||
Log.d(TAG, selectedAudio.toString())
|
||||
}
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {}
|
||||
}
|
||||
@ -69,16 +68,16 @@ class DownloadDialog : DialogFragment() {
|
||||
radioGroup.setOnCheckedChangeListener { group, checkedId ->
|
||||
val radio: RadioButton = view.findViewById(checkedId)
|
||||
extension = radio.text.toString()
|
||||
Log.d(TAG,extension)
|
||||
Log.d(TAG, extension)
|
||||
}
|
||||
view.findViewById<Button>(R.id.download).setOnClickListener {
|
||||
val intent = Intent(context,DownloadService::class.java)
|
||||
intent.putExtra("videoId",videoId)
|
||||
intent.putExtra("videoUrl",vidUrl[selectedVideo])
|
||||
intent.putExtra("audioUrl",audioUrl[selectedAudio])
|
||||
intent.putExtra("duration",duration)
|
||||
intent.putExtra("extension",extension)
|
||||
//intent.putExtra("command","-y -i ${response.videoStreams[which].url} -i ${response.audioStreams!![0].url} -c copy ${Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)}/${videoId}.mkv")
|
||||
val intent = Intent(context, DownloadService::class.java)
|
||||
intent.putExtra("videoId", videoId)
|
||||
intent.putExtra("videoUrl", vidUrl[selectedVideo])
|
||||
intent.putExtra("audioUrl", audioUrl[selectedAudio])
|
||||
intent.putExtra("duration", duration)
|
||||
intent.putExtra("extension", extension)
|
||||
// intent.putExtra("command","-y -i ${response.videoStreams[which].url} -i ${response.audioStreams!![0].url} -c copy ${Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)}/${videoId}.mkv")
|
||||
context?.startService(intent)
|
||||
dismiss()
|
||||
}
|
||||
|
@ -16,17 +16,16 @@ import androidx.core.app.NotificationManagerCompat
|
||||
import com.arthenica.ffmpegkit.FFmpegKit
|
||||
import java.io.File
|
||||
|
||||
|
||||
var IS_DOWNLOAD_RUNNING = false
|
||||
class DownloadService : Service(){
|
||||
class DownloadService : Service() {
|
||||
val TAG = "DownloadService"
|
||||
private var downloadId: Long =-1
|
||||
private var downloadId: Long = -1
|
||||
private lateinit var videoId: String
|
||||
private lateinit var videoUrl: String
|
||||
private lateinit var audioUrl: String
|
||||
private lateinit var extension: String
|
||||
private var duration: Int = 0
|
||||
//private lateinit var command: String
|
||||
// private lateinit var command: String
|
||||
private lateinit var audioDir: File
|
||||
private lateinit var videoDir: File
|
||||
lateinit var service: NotificationManager
|
||||
@ -41,29 +40,31 @@ class DownloadService : Service(){
|
||||
videoUrl = intent.getStringExtra("videoUrl")!!
|
||||
audioUrl = intent.getStringExtra("audioUrl")!!
|
||||
extension = intent.getStringExtra("extension")!!
|
||||
//command = intent.getStringExtra("command")!!
|
||||
duration = intent.getIntExtra("duration",1)
|
||||
// command = intent.getStringExtra("command")!!
|
||||
duration = intent.getIntExtra("duration", 1)
|
||||
service = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
val channelId =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val chan = NotificationChannel("service",
|
||||
"DownloadService", NotificationManager.IMPORTANCE_NONE)
|
||||
chan.lightColor = Color.BLUE
|
||||
chan.lockscreenVisibility = Notification.VISIBILITY_PRIVATE
|
||||
service.createNotificationChannel(chan)
|
||||
"service"
|
||||
} else {
|
||||
// If earlier version channel ID is not used
|
||||
// https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#NotificationCompat.Builder(android.content.Context)
|
||||
""
|
||||
}
|
||||
val channelId =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val chan = NotificationChannel(
|
||||
"service",
|
||||
"DownloadService", NotificationManager.IMPORTANCE_NONE
|
||||
)
|
||||
chan.lightColor = Color.BLUE
|
||||
chan.lockscreenVisibility = Notification.VISIBILITY_PRIVATE
|
||||
service.createNotificationChannel(chan)
|
||||
"service"
|
||||
} else {
|
||||
// If earlier version channel ID is not used
|
||||
// https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#NotificationCompat.Builder(android.content.Context)
|
||||
""
|
||||
}
|
||||
var pendingIntent: PendingIntent? = null
|
||||
pendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_MUTABLE)
|
||||
} else {
|
||||
PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT)
|
||||
}
|
||||
//Creating a notification and setting its various attributes
|
||||
// Creating a notification and setting its various attributes
|
||||
notification =
|
||||
NotificationCompat.Builder(this@DownloadService, channelId)
|
||||
.setSmallIcon(R.drawable.ic_download)
|
||||
@ -75,7 +76,7 @@ class DownloadService : Service(){
|
||||
.setProgress(100, 0, true)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setAutoCancel(true)
|
||||
startForeground(1,notification.build())
|
||||
startForeground(1, notification.build())
|
||||
downloadManager()
|
||||
|
||||
return super.onStartCommand(intent, flags, startId)
|
||||
@ -112,10 +113,10 @@ class DownloadService : Service(){
|
||||
val downloadManager: DownloadManager =
|
||||
applicationContext.getSystemService(DOWNLOAD_SERVICE) as DownloadManager
|
||||
downloadId = downloadManager.enqueue(request)
|
||||
if(audioUrl==""){downloadId = 0L}
|
||||
if (audioUrl == "") { downloadId = 0L }
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Log.e(TAG, "download error $e")
|
||||
try{
|
||||
try {
|
||||
downloadId = 0L
|
||||
val request: DownloadManager.Request =
|
||||
DownloadManager.Request(Uri.parse(audioUrl))
|
||||
@ -128,36 +129,35 @@ class DownloadService : Service(){
|
||||
val downloadManager: DownloadManager =
|
||||
applicationContext.getSystemService(DOWNLOAD_SERVICE) as DownloadManager
|
||||
downloadManager.enqueue(request)
|
||||
|
||||
}catch (e: Exception){
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "audio download error $e")
|
||||
stopService(Intent(this,DownloadService::class.java))}
|
||||
|
||||
stopService(Intent(this, DownloadService::class.java))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val onDownloadComplete: BroadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
//Fetching the download id received with the broadcast
|
||||
// Fetching the download id received with the broadcast
|
||||
val id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
|
||||
//Checking if the received broadcast is for our enqueued download by matching download id
|
||||
// Checking if the received broadcast is for our enqueued download by matching download id
|
||||
if (downloadId == id) {
|
||||
downloadId=0L
|
||||
try{
|
||||
val request: DownloadManager.Request =
|
||||
DownloadManager.Request(Uri.parse(audioUrl))
|
||||
.setTitle("Audio") // Title of the Download Notification
|
||||
.setDescription("Downloading") // Description of the Download Notification
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE) // Visibility of the download Notification
|
||||
.setDestinationUri(Uri.fromFile(audioDir))
|
||||
.setAllowedOverMetered(true) // Set if download is allowed on Mobile network
|
||||
.setAllowedOverRoaming(true) //
|
||||
val downloadManager: DownloadManager =
|
||||
applicationContext.getSystemService(DOWNLOAD_SERVICE) as DownloadManager
|
||||
downloadManager.enqueue(request)
|
||||
}catch (e: Exception){}
|
||||
}else if (downloadId == 0L){
|
||||
val libreTube = File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),"LibreTube")
|
||||
downloadId = 0L
|
||||
try {
|
||||
val request: DownloadManager.Request =
|
||||
DownloadManager.Request(Uri.parse(audioUrl))
|
||||
.setTitle("Audio") // Title of the Download Notification
|
||||
.setDescription("Downloading") // Description of the Download Notification
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE) // Visibility of the download Notification
|
||||
.setDestinationUri(Uri.fromFile(audioDir))
|
||||
.setAllowedOverMetered(true) // Set if download is allowed on Mobile network
|
||||
.setAllowedOverRoaming(true) //
|
||||
val downloadManager: DownloadManager =
|
||||
applicationContext.getSystemService(DOWNLOAD_SERVICE) as DownloadManager
|
||||
downloadManager.enqueue(request)
|
||||
} catch (e: Exception) {}
|
||||
} else if (downloadId == 0L) {
|
||||
val libreTube = File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "LibreTube")
|
||||
if (!libreTube.exists()) {
|
||||
libreTube.mkdirs()
|
||||
Log.e(TAG, "libreTube Directory make")
|
||||
@ -165,18 +165,19 @@ class DownloadService : Service(){
|
||||
Log.e(TAG, "libreTube Directory already have")
|
||||
}
|
||||
var command: String = when {
|
||||
videoUrl=="" -> {
|
||||
"-y -i $audioDir -c copy ${libreTube}/${videoId}-audio$extension"
|
||||
videoUrl == "" -> {
|
||||
"-y -i $audioDir -c copy $libreTube/$videoId-audio$extension"
|
||||
}
|
||||
audioUrl=="" -> {
|
||||
"-y -i $videoDir -c copy ${libreTube}/${videoId}-video$extension"
|
||||
audioUrl == "" -> {
|
||||
"-y -i $videoDir -c copy $libreTube/$videoId-video$extension"
|
||||
}
|
||||
else -> {
|
||||
"-y -i $videoDir -i $audioDir -c copy ${libreTube}/${videoId}$extension"
|
||||
"-y -i $videoDir -i $audioDir -c copy $libreTube/${videoId}$extension"
|
||||
}
|
||||
}
|
||||
notification.setContentTitle("Muxing")
|
||||
FFmpegKit.executeAsync(command,
|
||||
FFmpegKit.executeAsync(
|
||||
command,
|
||||
{ session ->
|
||||
val state = session.state
|
||||
val returnCode = session.returnCode
|
||||
@ -194,7 +195,7 @@ class DownloadService : Service(){
|
||||
val folder_main = ".tmp"
|
||||
val f = File(path, folder_main)
|
||||
f.deleteRecursively()
|
||||
if (returnCode.toString()!="0"){
|
||||
if (returnCode.toString() != "0") {
|
||||
var builder = NotificationCompat.Builder(this@DownloadService, "failed")
|
||||
.setSmallIcon(R.drawable.ic_download)
|
||||
.setContentTitle(resources.getString(R.string.downloadfailed))
|
||||
@ -207,13 +208,14 @@ class DownloadService : Service(){
|
||||
}
|
||||
}
|
||||
stopForeground(true)
|
||||
stopService(Intent(this@DownloadService,DownloadService::class.java))
|
||||
stopService(Intent(this@DownloadService, DownloadService::class.java))
|
||||
}, {
|
||||
// CALLED WHEN SESSION PRINTS LOGS
|
||||
Log.e(TAG,it.message.toString())
|
||||
}) {
|
||||
// CALLED WHEN SESSION PRINTS LOGS
|
||||
Log.e(TAG, it.message.toString())
|
||||
}
|
||||
) {
|
||||
// CALLED WHEN SESSION GENERATES STATISTICS
|
||||
Log.e(TAG+"stat",it.time.toString())
|
||||
Log.e(TAG + "stat", it.time.toString())
|
||||
/*val progress = it.time/(10*duration!!)
|
||||
if (progress<1){
|
||||
notification
|
||||
@ -221,7 +223,6 @@ class DownloadService : Service(){
|
||||
service.notify(1,notification.build())
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -245,10 +246,9 @@ class DownloadService : Service(){
|
||||
override fun onDestroy() {
|
||||
try {
|
||||
unregisterReceiver(onDownloadComplete)
|
||||
}catch (e: Exception){}
|
||||
} catch (e: Exception) {}
|
||||
IS_DOWNLOAD_RUNNING = false
|
||||
Log.d(TAG,"dl finished!")
|
||||
Log.d(TAG, "dl finished!")
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,23 +2,21 @@ package com.github.libretube
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.Toast
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
|
||||
import okhttp3.*
|
||||
import retrofit2.HttpException
|
||||
import com.github.libretube.adapters.TrendingAdapter
|
||||
import java.io.IOException
|
||||
|
||||
import okhttp3.*
|
||||
import retrofit2.HttpException
|
||||
|
||||
class Home : Fragment() {
|
||||
|
||||
@ -31,51 +29,47 @@ class Home : Fragment() {
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_home, container, false)
|
||||
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val recyclerView = view.findViewById<RecyclerView>(R.id.recview)
|
||||
val recyclerView = view.findViewById<RecyclerView>(R.id.recview)
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
val grid = sharedPreferences.getString("grid", resources.getInteger(R.integer.grid_items).toString())!!
|
||||
recyclerView.layoutManager = GridLayoutManager(view.context, grid.toInt())
|
||||
val progressbar = view.findViewById<ProgressBar>(R.id.progressBar)
|
||||
fetchJson(progressbar,recyclerView)
|
||||
fetchJson(progressbar, recyclerView)
|
||||
refreshLayout = view.findViewById(R.id.home_refresh)
|
||||
refreshLayout?.isEnabled = true
|
||||
refreshLayout?.setOnRefreshListener {
|
||||
Log.d(TAG,"hmm")
|
||||
fetchJson(progressbar,recyclerView)
|
||||
Log.d(TAG, "hmm")
|
||||
fetchJson(progressbar, recyclerView)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun fetchJson(progressBar: ProgressBar, recyclerView: RecyclerView) {
|
||||
private fun fetchJson(progressBar: ProgressBar, recyclerView: RecyclerView) {
|
||||
fun run() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
RetrofitInstance.api.getTrending(sharedPreferences.getString("region", "US")!!)
|
||||
}catch(e: IOException) {
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
Toast.makeText(context,R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
Log.e(TAG, "HttpException, unexpected response")
|
||||
Toast.makeText(context,R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
}finally {
|
||||
} finally {
|
||||
refreshLayout?.isRefreshing = false
|
||||
}
|
||||
runOnUiThread {
|
||||
@ -84,8 +78,7 @@ class Home : Fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
run()
|
||||
|
||||
run()
|
||||
}
|
||||
private fun Fragment?.runOnUiThread(action: () -> Unit) {
|
||||
this ?: return
|
||||
@ -94,9 +87,9 @@ class Home : Fragment() {
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
view?.findViewById<RecyclerView>(R.id.recview)?.adapter=null
|
||||
view?.findViewById<RecyclerView>(R.id.recview)?.adapter = null
|
||||
refreshLayout = null
|
||||
Log.e(TAG,"destroyview")
|
||||
Log.e(TAG, "destroyview")
|
||||
super.onDestroyView()
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,8 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.github.libretube.adapters.PlaylistsAdapter
|
||||
import com.github.libretube.obj.Playlists
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
|
||||
import retrofit2.HttpException
|
||||
|
||||
class Library : Fragment() {
|
||||
|
||||
@ -30,12 +29,12 @@ class Library : Fragment() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
arguments?.let {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
// Inflate the layout for this fragment
|
||||
@ -47,107 +46,104 @@ class Library : Fragment() {
|
||||
playlistRecyclerView = view.findViewById(R.id.playlist_recView)
|
||||
playlistRecyclerView.layoutManager = LinearLayoutManager(view.context)
|
||||
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||
token = sharedPref?.getString("token","")!!
|
||||
token = sharedPref?.getString("token", "")!!
|
||||
refreshLayout = view.findViewById(R.id.playlist_refresh)
|
||||
if(token!="") {
|
||||
view.findViewById<ImageView>(R.id.boogh2).visibility=View.GONE
|
||||
view.findViewById<TextView>(R.id.textLike2).visibility=View.GONE
|
||||
if (token != "") {
|
||||
view.findViewById<ImageView>(R.id.boogh2).visibility = View.GONE
|
||||
view.findViewById<TextView>(R.id.textLike2).visibility = View.GONE
|
||||
fetchPlaylists(view)
|
||||
refreshLayout?.isEnabled = true
|
||||
refreshLayout?.setOnRefreshListener {
|
||||
Log.d(TAG,"hmm")
|
||||
Log.d(TAG, "hmm")
|
||||
fetchPlaylists(view)
|
||||
}
|
||||
view.findViewById<Button>(R.id.create_playlist).setOnClickListener {
|
||||
val newFragment = CreatePlaylistDialog()
|
||||
newFragment.show(childFragmentManager, "Create Playlist")
|
||||
}
|
||||
childFragmentManager.setFragmentResultListener("key_parent", this) { _, result->
|
||||
childFragmentManager.setFragmentResultListener("key_parent", this) { _, result ->
|
||||
val playlistName = result.getString("playlistName")
|
||||
createPlaylist("$playlistName", view);
|
||||
createPlaylist("$playlistName", view)
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
refreshLayout?.isEnabled = false
|
||||
view.findViewById<Button>(R.id.create_playlist).visibility = View.GONE
|
||||
with(view.findViewById<ImageView>(R.id.boogh2)){
|
||||
visibility=View.VISIBLE
|
||||
with(view.findViewById<ImageView>(R.id.boogh2)) {
|
||||
visibility = View.VISIBLE
|
||||
setImageResource(R.drawable.ic_login)
|
||||
}
|
||||
with(view.findViewById<TextView>(R.id.textLike2)){
|
||||
visibility=View.VISIBLE
|
||||
with(view.findViewById<TextView>(R.id.textLike2)) {
|
||||
visibility = View.VISIBLE
|
||||
text = getString(R.string.please_login)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchPlaylists(view: View){
|
||||
private fun fetchPlaylists(view: View) {
|
||||
fun run() {
|
||||
refreshLayout?.isRefreshing = true
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.playlists(token)
|
||||
}catch(e: IOException) {
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
Toast.makeText(context,R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
Log.e(TAG, "HttpException, unexpected response")
|
||||
Toast.makeText(context,R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
}finally {
|
||||
} finally {
|
||||
refreshLayout?.isRefreshing = false
|
||||
}
|
||||
if (response.isNotEmpty()){
|
||||
if (response.isNotEmpty()) {
|
||||
runOnUiThread {
|
||||
with(view.findViewById<ImageView>(R.id.boogh2)){
|
||||
visibility=View.GONE
|
||||
with(view.findViewById<ImageView>(R.id.boogh2)) {
|
||||
visibility = View.GONE
|
||||
}
|
||||
with(view.findViewById<TextView>(R.id.textLike2)){
|
||||
visibility=View.GONE
|
||||
with(view.findViewById<TextView>(R.id.textLike2)) {
|
||||
visibility = View.GONE
|
||||
}
|
||||
}
|
||||
val playlistsAdapter = PlaylistsAdapter(response.toMutableList(),requireActivity())
|
||||
playlistRecyclerView.adapter= playlistsAdapter
|
||||
}else{
|
||||
val playlistsAdapter = PlaylistsAdapter(response.toMutableList(), requireActivity())
|
||||
playlistRecyclerView.adapter = playlistsAdapter
|
||||
} else {
|
||||
runOnUiThread {
|
||||
with(view.findViewById<ImageView>(R.id.boogh2)){
|
||||
visibility=View.VISIBLE
|
||||
with(view.findViewById<ImageView>(R.id.boogh2)) {
|
||||
visibility = View.VISIBLE
|
||||
setImageResource(R.drawable.ic_list)
|
||||
}
|
||||
with(view.findViewById<TextView>(R.id.textLike2)){
|
||||
visibility=View.VISIBLE
|
||||
with(view.findViewById<TextView>(R.id.textLike2)) {
|
||||
visibility = View.VISIBLE
|
||||
text = getString(R.string.emptyList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
run()
|
||||
}
|
||||
private fun createPlaylist(name: String, view: View){
|
||||
private fun createPlaylist(name: String, view: View) {
|
||||
fun run() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.createPlaylist(token, Playlists(name = name))
|
||||
}catch(e: IOException) {
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
Toast.makeText(context,R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
Log.e(TAG, "HttpException, unexpected response $e")
|
||||
Toast.makeText(context,R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
}
|
||||
if (response != null){
|
||||
Toast.makeText(context,R.string.playlistCreated, Toast.LENGTH_SHORT).show()
|
||||
if (response != null) {
|
||||
Toast.makeText(context, R.string.playlistCreated, Toast.LENGTH_SHORT).show()
|
||||
fetchPlaylists(view)
|
||||
}else{
|
||||
|
||||
} else {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
run()
|
||||
|
@ -2,7 +2,6 @@ package com.github.libretube
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
@ -13,14 +12,10 @@ import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.github.libretube.adapters.TrendingAdapter
|
||||
import com.github.libretube.obj.Login
|
||||
import org.w3c.dom.Text
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
import java.lang.Exception
|
||||
import kotlin.math.log
|
||||
import retrofit2.HttpException
|
||||
|
||||
class LoginDialog : DialogFragment() {
|
||||
private val TAG = "LoginDialog"
|
||||
@ -30,43 +25,43 @@ class LoginDialog : DialogFragment() {
|
||||
return activity?.let {
|
||||
val builder = AlertDialog.Builder(it)
|
||||
// Get the layout inflater
|
||||
val inflater = requireActivity().layoutInflater;
|
||||
val inflater = requireActivity().layoutInflater
|
||||
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||
val token = sharedPref?.getString("token","")
|
||||
val token = sharedPref?.getString("token", "")
|
||||
var view: View
|
||||
Log.e("dafaq",token!!)
|
||||
if(token!=""){
|
||||
Log.e("dafaq", token!!)
|
||||
if (token != "") {
|
||||
val sharedPref2 = context?.getSharedPreferences("username", Context.MODE_PRIVATE)
|
||||
val user = sharedPref2?.getString("username","")
|
||||
val user = sharedPref2?.getString("username", "")
|
||||
view = inflater.inflate(R.layout.dialog_logout, null)
|
||||
view.findViewById<TextView>(R.id.user).text = view.findViewById<TextView>(R.id.user).text.toString()+" ("+user+")"
|
||||
view.findViewById<TextView>(R.id.user).text = view.findViewById<TextView>(R.id.user).text.toString() + " (" + user + ")"
|
||||
view.findViewById<Button>(R.id.logout).setOnClickListener {
|
||||
Toast.makeText(context,R.string.loggedout, Toast.LENGTH_SHORT).show()
|
||||
val sharedPref = context?.getSharedPreferences("token",Context.MODE_PRIVATE)
|
||||
with (sharedPref!!.edit()) {
|
||||
putString("token","")
|
||||
Toast.makeText(context, R.string.loggedout, Toast.LENGTH_SHORT).show()
|
||||
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||
with(sharedPref!!.edit()) {
|
||||
putString("token", "")
|
||||
apply()
|
||||
}
|
||||
dialog?.dismiss()
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
view = inflater.inflate(R.layout.dialog_login, null)
|
||||
username=view.findViewById(R.id.username)
|
||||
password=view.findViewById(R.id.password)
|
||||
username = view.findViewById(R.id.username)
|
||||
password = view.findViewById(R.id.password)
|
||||
view.findViewById<Button>(R.id.login).setOnClickListener {
|
||||
if(username.text.toString()!="" && password.text.toString()!=""){
|
||||
val login = Login(username.text.toString(),password.text.toString())
|
||||
login(login)
|
||||
}else{
|
||||
Toast.makeText(context,R.string.empty, Toast.LENGTH_SHORT).show()
|
||||
if (username.text.toString() != "" && password.text.toString() != "") {
|
||||
val login = Login(username.text.toString(), password.text.toString())
|
||||
login(login)
|
||||
} else {
|
||||
Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
view.findViewById<Button>(R.id.register).setOnClickListener {
|
||||
if(username.text.toString()!="" && password.text.toString()!=""){
|
||||
val login = Login(username.text.toString(),password.text.toString())
|
||||
register(login)
|
||||
}else{
|
||||
Toast.makeText(context,R.string.empty, Toast.LENGTH_SHORT).show()
|
||||
if (username.text.toString() != "" && password.text.toString() != "") {
|
||||
val login = Login(username.text.toString(), password.text.toString())
|
||||
register(login)
|
||||
} else {
|
||||
Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -74,83 +69,80 @@ class LoginDialog : DialogFragment() {
|
||||
builder.create()
|
||||
} ?: throw IllegalStateException("Activity cannot be null")
|
||||
}
|
||||
private fun login(login: Login){
|
||||
private fun login(login: Login) {
|
||||
fun run() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.login(login)
|
||||
}catch(e: IOException) {
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
Toast.makeText(context,R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
Log.e(TAG, "HttpException, unexpected response")
|
||||
Toast.makeText(context,R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG,"dafaq?"+e.toString())
|
||||
Log.e(TAG, "dafaq?" + e.toString())
|
||||
return@launchWhenCreated
|
||||
}
|
||||
if (response.error!= null){
|
||||
if (response.error != null) {
|
||||
Toast.makeText(context, response.error, Toast.LENGTH_SHORT).show()
|
||||
}else if(response.token!=null){
|
||||
Toast.makeText(context,R.string.loggedIn, Toast.LENGTH_SHORT).show()
|
||||
val sharedPref = context?.getSharedPreferences("token",Context.MODE_PRIVATE)
|
||||
with (sharedPref!!.edit()) {
|
||||
putString("token",response.token)
|
||||
} else if (response.token != null) {
|
||||
Toast.makeText(context, R.string.loggedIn, Toast.LENGTH_SHORT).show()
|
||||
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||
with(sharedPref!!.edit()) {
|
||||
putString("token", response.token)
|
||||
apply()
|
||||
}
|
||||
val sharedPref2 = context?.getSharedPreferences("username",Context.MODE_PRIVATE)
|
||||
with (sharedPref2!!.edit()) {
|
||||
putString("username",login.username)
|
||||
val sharedPref2 = context?.getSharedPreferences("username", Context.MODE_PRIVATE)
|
||||
with(sharedPref2!!.edit()) {
|
||||
putString("username", login.username)
|
||||
apply()
|
||||
}
|
||||
dialog?.dismiss()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
run()
|
||||
}
|
||||
private fun register(login: Login){
|
||||
private fun register(login: Login) {
|
||||
fun run() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.register(login)
|
||||
}catch(e: IOException) {
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
Toast.makeText(context,R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
Log.e(TAG, "HttpException, unexpected response")
|
||||
Toast.makeText(context,R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG,"dafaq?"+e.toString())
|
||||
Log.e(TAG, "dafaq?" + e.toString())
|
||||
return@launchWhenCreated
|
||||
}
|
||||
if (response.error!= null){
|
||||
Toast.makeText(context, response.error, Toast.LENGTH_SHORT).show()
|
||||
}else if(response.token!=null){
|
||||
Toast.makeText(context,R.string.registered, Toast.LENGTH_SHORT).show()
|
||||
val sharedPref = context?.getSharedPreferences("token",Context.MODE_PRIVATE)
|
||||
with (sharedPref!!.edit()) {
|
||||
putString("token",response.token)
|
||||
if (response.error != null) {
|
||||
Toast.makeText(context, response.error, Toast.LENGTH_SHORT).show()
|
||||
} else if (response.token != null) {
|
||||
Toast.makeText(context, R.string.registered, Toast.LENGTH_SHORT).show()
|
||||
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||
with(sharedPref!!.edit()) {
|
||||
putString("token", response.token)
|
||||
apply()
|
||||
}
|
||||
val sharedPref2 = context?.getSharedPreferences("username",Context.MODE_PRIVATE)
|
||||
with (sharedPref2!!.edit()) {
|
||||
putString("username",login.username)
|
||||
val sharedPref2 = context?.getSharedPreferences("username", Context.MODE_PRIVATE)
|
||||
with(sharedPref2!!.edit()) {
|
||||
putString("username", login.username)
|
||||
apply()
|
||||
}
|
||||
dialog?.dismiss()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
run()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,10 @@ interface PipedApi {
|
||||
suspend fun getSegments(@Path("videoId") videoId: String, @Query("category") category: String): Segments
|
||||
|
||||
@GET("nextpage/comments/{videoId}")
|
||||
suspend fun getCommentsNextPage(@Path("videoId") videoId: String, @Query("nextpage") nextPage: String): CommentsPage
|
||||
suspend fun getCommentsNextPage(
|
||||
@Path("videoId") videoId: String,
|
||||
@Query("nextpage") nextPage: String
|
||||
): CommentsPage
|
||||
|
||||
@GET("search")
|
||||
suspend fun getSearchResults(
|
||||
@ -39,13 +42,19 @@ interface PipedApi {
|
||||
suspend fun getChannel(@Path("channelId") channelId: String): Channel
|
||||
|
||||
@GET("nextpage/channel/{channelId}")
|
||||
suspend fun getChannelNextPage(@Path("channelId") channelId: String, @Query("nextpage") nextPage: String): Channel
|
||||
suspend fun getChannelNextPage(
|
||||
@Path("channelId") channelId: String,
|
||||
@Query("nextpage") nextPage: String
|
||||
): Channel
|
||||
|
||||
@GET("playlists/{playlistId}")
|
||||
suspend fun getPlaylist(@Path("playlistId") playlistId: String): Playlist
|
||||
|
||||
@GET("nextpage/playlists/{playlistId}")
|
||||
suspend fun getPlaylistNextPage(@Path("playlistId") playlistId: String, @Query("nextpage") nextPage: String): Playlist
|
||||
suspend fun getPlaylistNextPage(
|
||||
@Path("playlistId") playlistId: String,
|
||||
@Query("nextpage") nextPage: String
|
||||
): Playlist
|
||||
|
||||
@POST("login")
|
||||
suspend fun login(@Body login: Login): Token
|
||||
@ -57,7 +66,10 @@ interface PipedApi {
|
||||
suspend fun getFeed(@Query("authToken") token: String?): List<StreamItem>
|
||||
|
||||
@GET("subscribed")
|
||||
suspend fun isSubscribed(@Query("channelId") channelId: String, @Header("Authorization") token: String): Subscribed
|
||||
suspend fun isSubscribed(
|
||||
@Query("channelId") channelId: String,
|
||||
@Header("Authorization") token: String
|
||||
): Subscribed
|
||||
|
||||
@GET("subscriptions")
|
||||
suspend fun subscriptions(@Header("Authorization") token: String): List<Subscription>
|
||||
@ -69,7 +81,11 @@ interface PipedApi {
|
||||
suspend fun unsubscribe(@Header("Authorization") token: String, @Body subscribe: Subscribe): Message
|
||||
|
||||
@POST("import")
|
||||
suspend fun importSubscriptions(@Query("override") override: Boolean, @Header("Authorization") token: String, @Body channels: List<String>): Message
|
||||
suspend fun importSubscriptions(
|
||||
@Query("override") override: Boolean,
|
||||
@Header("Authorization") token: String,
|
||||
@Body channels: List<String>
|
||||
): Message
|
||||
|
||||
@GET("user/playlists")
|
||||
suspend fun playlists(@Header("Authorization") token: String): List<Playlists>
|
||||
@ -84,12 +100,12 @@ interface PipedApi {
|
||||
suspend fun addToPlaylist(@Header("Authorization") token: String, @Body playlistId: PlaylistId): Message
|
||||
|
||||
@POST("user/playlists/remove")
|
||||
suspend fun removeFromPlaylist(@Header("Authorization") token: String, @Body playlistId: PlaylistId): Message
|
||||
suspend fun removeFromPlaylist(
|
||||
@Header("Authorization") token: String,
|
||||
@Body playlistId: PlaylistId
|
||||
): Message
|
||||
|
||||
//only for fetching servers list
|
||||
// only for fetching servers list
|
||||
@GET
|
||||
suspend fun getInstances(@Url url: String): List<Instances>
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,12 @@
|
||||
package com.github.libretube
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
|
||||
|
||||
class Player : Activity() {
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_player)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -58,13 +58,12 @@ import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
|
||||
import com.google.android.exoplayer2.util.RepeatModeUtil
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.squareup.picasso.Picasso
|
||||
import org.chromium.net.CronetEngine
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
import java.net.URLEncoder
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.abs
|
||||
|
||||
import org.chromium.net.CronetEngine
|
||||
import retrofit2.HttpException
|
||||
|
||||
var isFullScreen = false
|
||||
|
||||
@ -247,7 +246,6 @@ class PlayerFragment : Fragment() {
|
||||
) {
|
||||
fetchNextComments()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
commentsRecView = view.findViewById(R.id.comments_recView)
|
||||
@ -274,22 +272,21 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkForSegments()
|
||||
{
|
||||
private fun checkForSegments() {
|
||||
if (!exoPlayer.isPlaying || !SponsorBlockSettings.sponsorBlockEnabled) return
|
||||
|
||||
exoPlayerView.postDelayed(this::checkForSegments, 100)
|
||||
|
||||
if(segmentData.segments.isEmpty() )
|
||||
if (segmentData.segments.isEmpty())
|
||||
return
|
||||
|
||||
segmentData.segments.forEach { segment: Segment ->
|
||||
val segmentStart = (segment.segment!![0] * 1000.0f).toLong()
|
||||
val segmentEnd = (segment.segment!![1] * 1000.0f).toLong()
|
||||
val currentPosition = exoPlayer.currentPosition
|
||||
if(currentPosition in segmentStart until segmentEnd) {
|
||||
Toast.makeText(context,R.string.segment_skipped, Toast.LENGTH_SHORT).show()
|
||||
exoPlayer.seekTo(segmentEnd);
|
||||
if (currentPosition in segmentStart until segmentEnd) {
|
||||
Toast.makeText(context, R.string.segment_skipped, Toast.LENGTH_SHORT).show()
|
||||
exoPlayer.seekTo(segmentEnd)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -321,7 +318,7 @@ class PlayerFragment : Fragment() {
|
||||
Toast.makeText(context, R.string.server_error, Toast.LENGTH_SHORT).show()
|
||||
return@launchWhenCreated
|
||||
}
|
||||
if(SponsorBlockSettings.sponsorBlockEnabled) {
|
||||
if (SponsorBlockSettings.sponsorBlockEnabled) {
|
||||
val categories: ArrayList<String> = arrayListOf()
|
||||
if (SponsorBlockSettings.introEnabled) {
|
||||
categories.add("intro")
|
||||
@ -338,7 +335,7 @@ class PlayerFragment : Fragment() {
|
||||
if (SponsorBlockSettings.outroEnabled) {
|
||||
categories.add("outro")
|
||||
}
|
||||
if(categories.size > 0) {
|
||||
if (categories.size > 0) {
|
||||
segmentData = try {
|
||||
|
||||
RetrofitInstance.api.getSegments(
|
||||
@ -401,10 +398,10 @@ class PlayerFragment : Fragment() {
|
||||
exoPlayerView.setShowSubtitleButton(true)
|
||||
exoPlayerView.setShowNextButton(false)
|
||||
exoPlayerView.setShowPreviousButton(false)
|
||||
exoPlayerView.setRepeatToggleModes(RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL);
|
||||
exoPlayerView.setRepeatToggleModes(RepeatModeUtil.REPEAT_TOGGLE_MODE_ALL)
|
||||
// exoPlayerView.controllerShowTimeoutMs = 1500
|
||||
exoPlayerView.controllerHideOnTouch = true
|
||||
exoPlayer.setAudioAttributes(audioAttributes,true);
|
||||
exoPlayer.setAudioAttributes(audioAttributes, true)
|
||||
exoPlayerView.player = exoPlayer
|
||||
val sharedPreferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
@ -433,9 +430,11 @@ class PlayerFragment : Fragment() {
|
||||
ProgressiveMediaSource.Factory(dataSourceFactory)
|
||||
.createMediaSource(
|
||||
fromUri(
|
||||
response.audioStreams!![getMostBitRate(
|
||||
response.audioStreams
|
||||
)].url!!
|
||||
response.audioStreams!![
|
||||
getMostBitRate(
|
||||
response.audioStreams
|
||||
)
|
||||
].url!!
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -479,9 +478,11 @@ class PlayerFragment : Fragment() {
|
||||
audioSource = ProgressiveMediaSource.Factory(dataSourceFactory)
|
||||
.createMediaSource(
|
||||
fromUri(
|
||||
response.audioStreams!![getMostBitRate(
|
||||
response.audioStreams
|
||||
)].url!!
|
||||
response.audioStreams!![
|
||||
getMostBitRate(
|
||||
response.audioStreams
|
||||
)
|
||||
].url!!
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -545,9 +546,11 @@ class PlayerFragment : Fragment() {
|
||||
ProgressiveMediaSource.Factory(dataSourceFactory)
|
||||
.createMediaSource(
|
||||
fromUri(
|
||||
response.audioStreams!![getMostBitRate(
|
||||
response.audioStreams
|
||||
)].url!!
|
||||
response.audioStreams!![
|
||||
getMostBitRate(
|
||||
response.audioStreams
|
||||
)
|
||||
].url!!
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -555,7 +558,7 @@ class PlayerFragment : Fragment() {
|
||||
MergingMediaSource(videoSource, audioSource)
|
||||
exoPlayer.setMediaSource(mergeSource)
|
||||
}
|
||||
exoPlayer.seekTo(lastPosition);
|
||||
exoPlayer.seekTo(lastPosition)
|
||||
view.findViewById<TextView>(R.id.quality_text).text =
|
||||
videosNameArray[which]
|
||||
}
|
||||
@ -566,8 +569,7 @@ class PlayerFragment : Fragment() {
|
||||
// Listener for play and pause icon change
|
||||
exoPlayer!!.addListener(object : com.google.android.exoplayer2.Player.Listener {
|
||||
override fun onIsPlayingChanged(isPlaying: Boolean) {
|
||||
if(isPlaying && SponsorBlockSettings.sponsorBlockEnabled)
|
||||
{
|
||||
if (isPlaying && SponsorBlockSettings.sponsorBlockEnabled) {
|
||||
exoPlayerView.postDelayed(this@PlayerFragment::checkForSegments, 100)
|
||||
}
|
||||
}
|
||||
@ -578,9 +580,9 @@ class PlayerFragment : Fragment() {
|
||||
) {
|
||||
|
||||
exoPlayerView.keepScreenOn = !(
|
||||
playbackState == Player.STATE_IDLE || playbackState == Player.STATE_ENDED ||
|
||||
!playWhenReady
|
||||
)
|
||||
playbackState == Player.STATE_IDLE || playbackState == Player.STATE_ENDED ||
|
||||
!playWhenReady
|
||||
)
|
||||
|
||||
if (playWhenReady && playbackState == Player.STATE_READY) {
|
||||
// media actually playing
|
||||
@ -678,9 +680,9 @@ class PlayerFragment : Fragment() {
|
||||
requireContext(),
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(
|
||||
requireContext(),
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
) != PackageManager.PERMISSION_GRANTED
|
||||
requireContext(),
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
) != PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
ActivityCompat.requestPermissions(
|
||||
mainActivity,
|
||||
@ -772,7 +774,6 @@ class PlayerFragment : Fragment() {
|
||||
return@launchWhenCreated
|
||||
}
|
||||
|
||||
|
||||
runOnUiThread {
|
||||
if (response.subscribed == true) {
|
||||
isSubscribed = true
|
||||
@ -864,25 +865,25 @@ class PlayerFragment : Fragment() {
|
||||
super.onResume()
|
||||
}
|
||||
|
||||
private fun fetchNextComments(){
|
||||
lifecycleScope.launchWhenCreated {
|
||||
if (!isLoading) {
|
||||
isLoading = true
|
||||
val response = try {
|
||||
RetrofitInstance.api.getCommentsNextPage(videoId!!, nextPage!!)
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
Log.e(TAG, "HttpException, unexpected response," + e.response())
|
||||
return@launchWhenCreated
|
||||
}
|
||||
nextPage = response.nextpage
|
||||
commentsAdapter?.updateItems(response.comments!!)
|
||||
isLoading = false
|
||||
private fun fetchNextComments() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
if (!isLoading) {
|
||||
isLoading = true
|
||||
val response = try {
|
||||
RetrofitInstance.api.getCommentsNextPage(videoId!!, nextPage!!)
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
Log.e(TAG, "HttpException, unexpected response," + e.response())
|
||||
return@launchWhenCreated
|
||||
}
|
||||
nextPage = response.nextpage
|
||||
commentsAdapter?.updateItems(response.comments!!)
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
|
||||
@ -898,7 +899,7 @@ class PlayerFragment : Fragment() {
|
||||
view?.findViewById<FrameLayout>(R.id.top_bar)?.visibility = View.GONE
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
isFullScreen = false;
|
||||
isFullScreen = false
|
||||
} else {
|
||||
with(motionLayout) {
|
||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
||||
@ -917,6 +918,6 @@ class PlayerFragment : Fragment() {
|
||||
|
||||
if (SDK_INT >= Build.VERSION_CODES.N && exoPlayer.isPlaying && (scrollView?.getLocalVisibleRect(bounds) == true || isFullScreen)) {
|
||||
requireActivity().enterPictureInPictureMode()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,27 +3,23 @@ package com.github.libretube
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.ScrollView
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.adapters.ChannelAdapter
|
||||
import com.github.libretube.adapters.PlaylistAdapter
|
||||
import com.squareup.picasso.Picasso
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
|
||||
import retrofit2.HttpException
|
||||
|
||||
class PlaylistFragment : Fragment() {
|
||||
private var playlist_id: String? = null
|
||||
private val TAG = "PlaylistFragment"
|
||||
var nextPage: String? =null
|
||||
var nextPage: String? = null
|
||||
var playlistAdapter: PlaylistAdapter? = null
|
||||
var isLoading = true
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@ -34,7 +30,8 @@ class PlaylistFragment : Fragment() {
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
// Inflate the layout for this fragment
|
||||
@ -44,19 +41,19 @@ class PlaylistFragment : Fragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
playlist_id = playlist_id!!.replace("/playlist?list=","")
|
||||
view.findViewById<TextView>(R.id.playlist_name).text=playlist_id
|
||||
playlist_id = playlist_id!!.replace("/playlist?list=", "")
|
||||
view.findViewById<TextView>(R.id.playlist_name).text = playlist_id
|
||||
val recyclerView = view.findViewById<RecyclerView>(R.id.playlist_recView)
|
||||
recyclerView.layoutManager = LinearLayoutManager(context)
|
||||
|
||||
fetchPlaylist(view)
|
||||
}
|
||||
private fun fetchPlaylist(view: View){
|
||||
private fun fetchPlaylist(view: View) {
|
||||
fun run() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.getPlaylist(playlist_id!!)
|
||||
}catch(e: IOException) {
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
return@launchWhenCreated
|
||||
@ -65,15 +62,15 @@ class PlaylistFragment : Fragment() {
|
||||
return@launchWhenCreated
|
||||
}
|
||||
nextPage = response.nextpage
|
||||
isLoading=false
|
||||
isLoading = false
|
||||
runOnUiThread {
|
||||
view.findViewById<TextView>(R.id.playlist_name).text=response.name
|
||||
view.findViewById<TextView>(R.id.playlist_uploader).text=response.uploader
|
||||
view.findViewById<TextView>(R.id.playlist_totVideos).text=response.videos.toString()+" Videos"
|
||||
view.findViewById<TextView>(R.id.playlist_name).text = response.name
|
||||
view.findViewById<TextView>(R.id.playlist_uploader).text = response.uploader
|
||||
view.findViewById<TextView>(R.id.playlist_totVideos).text = response.videos.toString() + " Videos"
|
||||
val sharedPref2 = context?.getSharedPreferences("username", Context.MODE_PRIVATE)
|
||||
val user = sharedPref2?.getString("username","")
|
||||
val user = sharedPref2?.getString("username", "")
|
||||
var isOwner = false
|
||||
if(response.uploaderUrl == null && response.uploader.equals(user, true)){
|
||||
if (response.uploaderUrl == null && response.uploader.equals(user, true)) {
|
||||
isOwner = true
|
||||
}
|
||||
playlistAdapter = PlaylistAdapter(response.relatedStreams!!.toMutableList(), playlist_id!!, isOwner, requireActivity())
|
||||
@ -82,15 +79,15 @@ class PlaylistFragment : Fragment() {
|
||||
scrollView.viewTreeObserver
|
||||
.addOnScrollChangedListener {
|
||||
if (scrollView.getChildAt(0).bottom
|
||||
== (scrollView.height + scrollView.scrollY)) {
|
||||
//scroll view is at bottom
|
||||
if(nextPage!=null && !isLoading){
|
||||
isLoading=true
|
||||
== (scrollView.height + scrollView.scrollY)
|
||||
) {
|
||||
// scroll view is at bottom
|
||||
if (nextPage != null && !isLoading) {
|
||||
isLoading = true
|
||||
fetchNextPage()
|
||||
}
|
||||
|
||||
} else {
|
||||
//scroll view is not at bottom
|
||||
// scroll view is not at bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -99,24 +96,23 @@ class PlaylistFragment : Fragment() {
|
||||
run()
|
||||
}
|
||||
|
||||
private fun fetchNextPage(){
|
||||
private fun fetchNextPage() {
|
||||
fun run() {
|
||||
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.getPlaylistNextPage(playlist_id!!,nextPage!!)
|
||||
RetrofitInstance.api.getPlaylistNextPage(playlist_id!!, nextPage!!)
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
Log.e(TAG, "HttpException, unexpected response,"+e.response())
|
||||
Log.e(TAG, "HttpException, unexpected response," + e.response())
|
||||
return@launchWhenCreated
|
||||
}
|
||||
nextPage = response.nextpage
|
||||
playlistAdapter?.updateItems(response.relatedStreams!!)
|
||||
isLoading=false
|
||||
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
run()
|
||||
@ -127,4 +123,4 @@ class PlaylistFragment : Fragment() {
|
||||
if (!isAdded) return // Fragment not attached to an Activity
|
||||
activity?.runOnUiThread(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,13 @@ class ResettableLazyManager {
|
||||
val managedDelegates = LinkedList<Resettable>()
|
||||
|
||||
fun register(managed: Resettable) {
|
||||
synchronized (managedDelegates) {
|
||||
synchronized(managedDelegates) {
|
||||
managedDelegates.add(managed)
|
||||
}
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
synchronized (managedDelegates) {
|
||||
synchronized(managedDelegates) {
|
||||
managedDelegates.forEach { it.reset() }
|
||||
managedDelegates.clear()
|
||||
}
|
||||
@ -25,7 +25,7 @@ interface Resettable {
|
||||
fun reset()
|
||||
}
|
||||
|
||||
class ResettableLazy<PROPTYPE>(val manager: ResettableLazyManager, val init: ()->PROPTYPE): Resettable {
|
||||
class ResettableLazy<PROPTYPE>(val manager: ResettableLazyManager, val init: () -> PROPTYPE) : Resettable {
|
||||
@Volatile var lazyHolder = makeInitBlock()
|
||||
|
||||
operator fun getValue(thisRef: Any?, property: KProperty<*>): PROPTYPE {
|
||||
@ -44,8 +44,8 @@ class ResettableLazy<PROPTYPE>(val manager: ResettableLazyManager, val init: ()-
|
||||
}
|
||||
}
|
||||
|
||||
fun <PROPTYPE> resettableLazy(manager: ResettableLazyManager, init: ()->PROPTYPE): ResettableLazy<PROPTYPE> {
|
||||
fun <PROPTYPE> resettableLazy(manager: ResettableLazyManager, init: () -> PROPTYPE): ResettableLazy<PROPTYPE> {
|
||||
return ResettableLazy(manager, init)
|
||||
}
|
||||
|
||||
fun resettableManager(): ResettableLazyManager = ResettableLazyManager()
|
||||
fun resettableManager(): ResettableLazyManager = ResettableLazyManager()
|
||||
|
@ -13,5 +13,4 @@ object RetrofitInstance {
|
||||
.build()
|
||||
.create(PipedApi::class.java)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -23,37 +23,36 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.adapters.SearchAdapter
|
||||
import com.github.libretube.adapters.SearchHistoryAdapter
|
||||
import java.io.IOException
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
|
||||
class SearchFragment : Fragment() {
|
||||
private val TAG = "SearchFragment"
|
||||
private var selectedFilter = 0
|
||||
private var apiSearchFilter = "all"
|
||||
private var nextPage : String? = null
|
||||
private lateinit var searchRecView : RecyclerView
|
||||
private var searchAdapter : SearchAdapter? = null
|
||||
private var isLoading : Boolean = true
|
||||
private var nextPage: String? = null
|
||||
private lateinit var searchRecView: RecyclerView
|
||||
private var searchAdapter: SearchAdapter? = null
|
||||
private var isLoading: Boolean = true
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
arguments?.let {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_search, container, false)
|
||||
}
|
||||
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
searchRecView = view.findViewById<RecyclerView>(R.id.search_recycler)
|
||||
@ -80,30 +79,37 @@ class SearchFragment : Fragment() {
|
||||
|
||||
AlertDialog.Builder(view.context)
|
||||
.setTitle(getString(R.string.choose_filter))
|
||||
.setSingleChoiceItems(filterOptions, selectedFilter, DialogInterface.OnClickListener {
|
||||
_, id -> tempSelectedItem = id
|
||||
})
|
||||
.setPositiveButton(getString(R.string.okay), DialogInterface.OnClickListener { _, _ ->
|
||||
selectedFilter = tempSelectedItem
|
||||
apiSearchFilter = when (selectedFilter) {
|
||||
0 -> "all"
|
||||
1 -> "videos"
|
||||
2 -> "channels"
|
||||
3 -> "playlists"
|
||||
4 -> "music_songs"
|
||||
5 -> "music_videos"
|
||||
6 -> "music_albums"
|
||||
7 -> "music_playlists"
|
||||
else -> "all"
|
||||
.setSingleChoiceItems(
|
||||
filterOptions, selectedFilter,
|
||||
DialogInterface.OnClickListener {
|
||||
_, id ->
|
||||
tempSelectedItem = id
|
||||
}
|
||||
)
|
||||
.setPositiveButton(
|
||||
getString(R.string.okay),
|
||||
DialogInterface.OnClickListener { _, _ ->
|
||||
selectedFilter = tempSelectedItem
|
||||
apiSearchFilter = when (selectedFilter) {
|
||||
0 -> "all"
|
||||
1 -> "videos"
|
||||
2 -> "channels"
|
||||
3 -> "playlists"
|
||||
4 -> "music_songs"
|
||||
5 -> "music_videos"
|
||||
6 -> "music_albums"
|
||||
7 -> "music_playlists"
|
||||
else -> "all"
|
||||
}
|
||||
fetchSearch(autoTextView.text.toString())
|
||||
})
|
||||
}
|
||||
)
|
||||
.setNegativeButton(getString(R.string.cancel), null)
|
||||
.create()
|
||||
.show()
|
||||
}
|
||||
|
||||
//show search history
|
||||
// show search history
|
||||
|
||||
searchRecView.visibility = GONE
|
||||
historyRecycler.visibility = VISIBLE
|
||||
@ -128,7 +134,6 @@ class SearchFragment : Fragment() {
|
||||
count: Int,
|
||||
after: Int
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
@ -142,7 +147,6 @@ class SearchFragment : Fragment() {
|
||||
if (!searchRecView.canScrollVertically(1)) {
|
||||
fetchNextSearchItems(autoTextView.text.toString())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GlobalScope.launch {
|
||||
@ -166,22 +170,23 @@ class SearchFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
autoTextView.setOnEditorActionListener(OnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||
hideKeyboard()
|
||||
autoTextView.dismissDropDown()
|
||||
return@OnEditorActionListener true
|
||||
autoTextView.setOnEditorActionListener(
|
||||
OnEditorActionListener { _, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||
hideKeyboard()
|
||||
autoTextView.dismissDropDown()
|
||||
return@OnEditorActionListener true
|
||||
}
|
||||
false
|
||||
}
|
||||
false
|
||||
})
|
||||
)
|
||||
autoTextView.setOnItemClickListener { _, _, _, _ ->
|
||||
hideKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchSuggestions(query: String, autoTextView: AutoCompleteTextView){
|
||||
private fun fetchSuggestions(query: String, autoTextView: AutoCompleteTextView) {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.getSuggestions(query)
|
||||
@ -197,7 +202,7 @@ class SearchFragment : Fragment() {
|
||||
autoTextView.setAdapter(adapter)
|
||||
}
|
||||
}
|
||||
private fun fetchSearch(query: String){
|
||||
private fun fetchSearch(query: String) {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.getSearchResults(query, apiSearchFilter)
|
||||
@ -210,22 +215,22 @@ class SearchFragment : Fragment() {
|
||||
return@launchWhenCreated
|
||||
}
|
||||
nextPage = response.nextpage
|
||||
if(response.items!!.isNotEmpty()){
|
||||
runOnUiThread {
|
||||
searchAdapter = SearchAdapter(response.items)
|
||||
searchRecView.adapter = searchAdapter
|
||||
}
|
||||
if (response.items!!.isNotEmpty()) {
|
||||
runOnUiThread {
|
||||
searchAdapter = SearchAdapter(response.items)
|
||||
searchRecView.adapter = searchAdapter
|
||||
}
|
||||
}
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchNextSearchItems(query: String){
|
||||
private fun fetchNextSearchItems(query: String) {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
if (!isLoading) {
|
||||
isLoading = true
|
||||
val response = try {
|
||||
RetrofitInstance.api.getSearchResultsNextPage(query,apiSearchFilter,nextPage!!)
|
||||
RetrofitInstance.api.getSearchResultsNextPage(query, apiSearchFilter, nextPage!!)
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
@ -239,7 +244,7 @@ class SearchFragment : Fragment() {
|
||||
isLoading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Fragment?.runOnUiThread(action: () -> Unit) {
|
||||
this ?: return
|
||||
@ -262,18 +267,14 @@ class SearchFragment : Fragment() {
|
||||
|
||||
var historyList = getHistory()
|
||||
|
||||
|
||||
if (historyList.size != 0 && query == historyList.get(historyList.size - 1)) {
|
||||
return
|
||||
} else if (query == "") {
|
||||
return
|
||||
} else {
|
||||
historyList = historyList + query
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (historyList.size > 10) {
|
||||
historyList = historyList.takeLast(10)
|
||||
}
|
||||
@ -292,7 +293,5 @@ class SearchFragment : Fragment() {
|
||||
} catch (e: Exception) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,13 +24,13 @@ import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.google.android.material.color.DynamicColors
|
||||
import org.json.JSONObject
|
||||
import org.json.JSONTokener
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
import org.json.JSONObject
|
||||
import org.json.JSONTokener
|
||||
import retrofit2.HttpException
|
||||
|
||||
class SettingsActivity :
|
||||
AppCompatActivity(),
|
||||
|
@ -3,13 +3,10 @@ package com.github.libretube
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.GestureDetector
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.motion.widget.MotionLayout
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@ -20,7 +17,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeSet? = null) : MotionLayout(context, attributeSet) {
|
||||
|
||||
private val viewToDetectTouch by lazy {
|
||||
findViewById<View>(R.id.main_container) //TODO move to Attributes
|
||||
findViewById<View>(R.id.main_container) // TODO move to Attributes
|
||||
}
|
||||
private val viewRect = Rect()
|
||||
private var touchStarted = false
|
||||
@ -33,7 +30,6 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
|
||||
startId: Int,
|
||||
endId: Int
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTransitionChange(p0: MotionLayout?, p1: Int, p2: Int, p3: Float) {
|
||||
@ -49,7 +45,6 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
|
||||
positive: Boolean,
|
||||
progress: Float
|
||||
) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
@ -59,7 +54,6 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
|
||||
startId: Int,
|
||||
endId: Int
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTransitionChange(p0: MotionLayout?, p1: Int, p2: Int, p3: Float) {
|
||||
@ -78,7 +72,6 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
|
||||
positive: Boolean,
|
||||
progress: Float
|
||||
) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -91,15 +84,18 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
|
||||
transitionListenerList += listener
|
||||
}
|
||||
|
||||
private val gestureDetector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
|
||||
override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
|
||||
transitionToEnd()
|
||||
return false
|
||||
private val gestureDetector = GestureDetector(
|
||||
context,
|
||||
object : GestureDetector.SimpleOnGestureListener() {
|
||||
override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
|
||||
transitionToEnd()
|
||||
return false
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
//gestureDetector.onTouchEvent(event)
|
||||
// gestureDetector.onTouchEvent(event)
|
||||
when (event.actionMasked) {
|
||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
||||
touchStarted = false
|
||||
@ -112,4 +108,4 @@ class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeS
|
||||
}
|
||||
return touchStarted && super.onTouchEvent(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,4 +52,4 @@ class SponsorBlockSettings : PreferenceFragmentCompat() {
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,29 +3,28 @@ package com.github.libretube
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.fragment.app.Fragment
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.*
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.github.libretube.adapters.SubscriptionAdapter
|
||||
import com.github.libretube.adapters.SubscriptionChannelAdapter
|
||||
import java.io.IOException
|
||||
import org.chromium.base.ThreadUtils.runOnUiThread
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
|
||||
class Subscriptions : Fragment() {
|
||||
val TAG = "SubFragment"
|
||||
lateinit var token: String
|
||||
var isLoaded = false
|
||||
private var subscriptionAdapter: SubscriptionAdapter? =null
|
||||
private var subscriptionAdapter: SubscriptionAdapter? = null
|
||||
private var refreshLayout: SwipeRefreshLayout? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -34,7 +33,8 @@ class Subscriptions : Fragment() {
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
// Inflate the layout for this fragment
|
||||
@ -44,14 +44,14 @@ class Subscriptions : Fragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||
token = sharedPref?.getString("token","")!!
|
||||
token = sharedPref?.getString("token", "")!!
|
||||
refreshLayout = view.findViewById(R.id.sub_refresh)
|
||||
if(token!=""){
|
||||
view.findViewById<RelativeLayout>(R.id.loginOrRegister).visibility=View.GONE
|
||||
if (token != "") {
|
||||
view.findViewById<RelativeLayout>(R.id.loginOrRegister).visibility = View.GONE
|
||||
refreshLayout?.isEnabled = true
|
||||
|
||||
var progressBar = view.findViewById<ProgressBar>(R.id.sub_progress)
|
||||
progressBar.visibility=View.VISIBLE
|
||||
progressBar.visibility = View.VISIBLE
|
||||
|
||||
var channelRecView = view.findViewById<RecyclerView>(R.id.sub_channels)
|
||||
|
||||
@ -78,8 +78,7 @@ class Subscriptions : Fragment() {
|
||||
}
|
||||
channelRecView.visibility = View.VISIBLE
|
||||
feedRecView.visibility = View.GONE
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
channelRecView.visibility = View.GONE
|
||||
feedRecView.visibility = View.VISIBLE
|
||||
}
|
||||
@ -89,14 +88,14 @@ class Subscriptions : Fragment() {
|
||||
scrollView.viewTreeObserver
|
||||
.addOnScrollChangedListener {
|
||||
if (scrollView.getChildAt(0).bottom
|
||||
== (scrollView.height + scrollView.scrollY)) {
|
||||
//scroll view is at bottom
|
||||
if(isLoaded){
|
||||
== (scrollView.height + scrollView.scrollY)
|
||||
) {
|
||||
// scroll view is at bottom
|
||||
if (isLoaded) {
|
||||
refreshLayout?.isRefreshing = true
|
||||
subscriptionAdapter?.updateItems()
|
||||
refreshLayout?.isRefreshing = false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -109,8 +108,8 @@ class Subscriptions : Fragment() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.getFeed(token)
|
||||
}catch(e: IOException) {
|
||||
Log.e(TAG,e.toString())
|
||||
} catch (e: IOException) {
|
||||
Log.e(TAG, e.toString())
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
@ -119,25 +118,25 @@ class Subscriptions : Fragment() {
|
||||
} finally {
|
||||
refreshLayout?.isRefreshing = false
|
||||
}
|
||||
if (response.isNotEmpty()){
|
||||
if (response.isNotEmpty()) {
|
||||
subscriptionAdapter = SubscriptionAdapter(response)
|
||||
feedRecView?.adapter= subscriptionAdapter
|
||||
feedRecView?.adapter = subscriptionAdapter
|
||||
subscriptionAdapter?.updateItems()
|
||||
}else{
|
||||
} else {
|
||||
runOnUiThread {
|
||||
with(view.findViewById<ImageView>(R.id.boogh)){
|
||||
visibility=View.VISIBLE
|
||||
with(view.findViewById<ImageView>(R.id.boogh)) {
|
||||
visibility = View.VISIBLE
|
||||
setImageResource(R.drawable.ic_list)
|
||||
}
|
||||
with(view.findViewById<TextView>(R.id.textLike)){
|
||||
visibility=View.VISIBLE
|
||||
with(view.findViewById<TextView>(R.id.textLike)) {
|
||||
visibility = View.VISIBLE
|
||||
text = getString(R.string.emptyList)
|
||||
}
|
||||
view.findViewById<RelativeLayout>(R.id.loginOrRegister).visibility=View.VISIBLE
|
||||
view.findViewById<RelativeLayout>(R.id.loginOrRegister).visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
progressBar.visibility=View.GONE
|
||||
isLoaded=true
|
||||
progressBar.visibility = View.GONE
|
||||
isLoaded = true
|
||||
}
|
||||
}
|
||||
run()
|
||||
@ -148,8 +147,8 @@ class Subscriptions : Fragment() {
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val response = try {
|
||||
RetrofitInstance.api.subscriptions(token)
|
||||
}catch(e: IOException) {
|
||||
Log.e(TAG,e.toString())
|
||||
} catch (e: IOException) {
|
||||
Log.e(TAG, e.toString())
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
return@launchWhenCreated
|
||||
} catch (e: HttpException) {
|
||||
@ -158,25 +157,24 @@ class Subscriptions : Fragment() {
|
||||
} finally {
|
||||
refreshLayout?.isRefreshing = false
|
||||
}
|
||||
if (response.isNotEmpty()){
|
||||
channelRecView?.adapter=SubscriptionChannelAdapter(response.toMutableList())
|
||||
}else{
|
||||
Toast.makeText(context,R.string.subscribeIsEmpty, Toast.LENGTH_SHORT).show()
|
||||
if (response.isNotEmpty()) {
|
||||
channelRecView?.adapter = SubscriptionChannelAdapter(response.toMutableList())
|
||||
} else {
|
||||
Toast.makeText(context, R.string.subscribeIsEmpty, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
run()
|
||||
}
|
||||
override fun onDestroy() {
|
||||
Log.e(TAG,"Destroyed")
|
||||
Log.e(TAG, "Destroyed")
|
||||
super.onDestroy()
|
||||
subscriptionAdapter = null
|
||||
view?.findViewById<RecyclerView>(R.id.sub_feed)?.adapter=null
|
||||
view?.findViewById<RecyclerView>(R.id.sub_feed)?.adapter = null
|
||||
}
|
||||
private fun Fragment?.runOnUiThread(action: () -> Unit) {
|
||||
this ?: return
|
||||
if (!isAdded) return // Fragment not attached to an Activity
|
||||
activity?.runOnUiThread(action)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,31 +15,31 @@ import com.github.libretube.formatShort
|
||||
import com.github.libretube.obj.StreamItem
|
||||
import com.squareup.picasso.Picasso
|
||||
|
||||
class ChannelAdapter(private val videoFeed: MutableList<StreamItem>): RecyclerView.Adapter<ChannelViewHolder>() {
|
||||
class ChannelAdapter(private val videoFeed: MutableList<StreamItem>) : RecyclerView.Adapter<ChannelViewHolder>() {
|
||||
override fun getItemCount(): Int {
|
||||
return videoFeed.size
|
||||
}
|
||||
fun updateItems(newItems: List<StreamItem>){
|
||||
fun updateItems(newItems: List<StreamItem>) {
|
||||
videoFeed.addAll(newItems)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChannelViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val cell = layoutInflater.inflate(R.layout.video_channel_row,parent,false)
|
||||
val cell = layoutInflater.inflate(R.layout.video_channel_row, parent, false)
|
||||
return ChannelViewHolder(cell)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ChannelViewHolder, position: Int) {
|
||||
val trending = videoFeed[position]
|
||||
holder.v.findViewById<TextView>(R.id.channel_description).text = trending.title
|
||||
holder.v.findViewById<TextView>(R.id.channel_views).text = trending.views.formatShort()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
|
||||
holder.v.findViewById<TextView>(R.id.channel_views).text = trending.views.formatShort() + " • " + DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
|
||||
holder.v.findViewById<TextView>(R.id.channel_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
|
||||
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.channel_thumbnail)
|
||||
Picasso.get().load(trending.thumbnail).into(thumbnailImage)
|
||||
holder.v.setOnClickListener{
|
||||
holder.v.setOnClickListener {
|
||||
var bundle = Bundle()
|
||||
bundle.putString("videoId",trending.url!!.replace("/watch?v=",""))
|
||||
bundle.putString("videoId", trending.url!!.replace("/watch?v=", ""))
|
||||
var frag = PlayerFragment()
|
||||
frag.arguments = bundle
|
||||
val activity = holder.v.context as AppCompatActivity
|
||||
@ -52,7 +52,7 @@ class ChannelAdapter(private val videoFeed: MutableList<StreamItem>): RecyclerVi
|
||||
}
|
||||
}
|
||||
}
|
||||
class ChannelViewHolder(val v: View): RecyclerView.ViewHolder(v){
|
||||
class ChannelViewHolder(val v: View) : RecyclerView.ViewHolder(v) {
|
||||
init {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.github.libretube.adapters
|
||||
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -15,9 +14,9 @@ import com.github.libretube.formatShort
|
||||
import com.github.libretube.obj.Comment
|
||||
import com.squareup.picasso.Picasso
|
||||
|
||||
class CommentsAdapter(private val comments: MutableList<Comment>): RecyclerView.Adapter<ViewHolder>(){
|
||||
class CommentsAdapter(private val comments: MutableList<Comment>) : RecyclerView.Adapter<ViewHolder>() {
|
||||
|
||||
fun updateItems(newItems: List<Comment>){
|
||||
fun updateItems(newItems: List<Comment>) {
|
||||
var commentsSize = comments.size
|
||||
comments.addAll(newItems)
|
||||
notifyItemRangeInserted(commentsSize, newItems.size)
|
||||
@ -43,7 +42,7 @@ class CommentsAdapter(private val comments: MutableList<Comment>): RecyclerView
|
||||
if (comments[position].hearted == true) {
|
||||
holder.v.findViewById<ImageView>(R.id.hearted_imageView).visibility = View.VISIBLE
|
||||
}
|
||||
channelImage.setOnClickListener{
|
||||
channelImage.setOnClickListener {
|
||||
val activity = holder.v.context as MainActivity
|
||||
val bundle = bundleOf("channel_id" to comments[position].commentorUrl)
|
||||
activity.navController.navigate(R.id.channel, bundle)
|
||||
@ -53,8 +52,7 @@ class CommentsAdapter(private val comments: MutableList<Comment>): RecyclerView
|
||||
mainMotionLayout.transitionToEnd()
|
||||
activity.findViewById<MotionLayout>(R.id.playerMotionLayout).transitionToEnd()
|
||||
}
|
||||
}catch (e: Exception){
|
||||
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -62,10 +60,9 @@ class CommentsAdapter(private val comments: MutableList<Comment>): RecyclerView
|
||||
override fun getItemCount(): Int {
|
||||
return comments.size
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ViewHolder(val v: View): RecyclerView.ViewHolder(v){
|
||||
class ViewHolder(val v: View) : RecyclerView.ViewHolder(v) {
|
||||
init {
|
||||
}
|
||||
}
|
||||
|
@ -18,24 +18,29 @@ import com.github.libretube.RetrofitInstance
|
||||
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): RecyclerView.Adapter<PlaylistViewHolder>() {
|
||||
class PlaylistAdapter(
|
||||
private val videoFeed: MutableList<StreamItem>,
|
||||
private val playlistId: String,
|
||||
private val isOwner: Boolean,
|
||||
private val activity: Activity
|
||||
) : RecyclerView.Adapter<PlaylistViewHolder>() {
|
||||
private val TAG = "PlaylistAdapter"
|
||||
override fun getItemCount(): Int {
|
||||
return videoFeed.size
|
||||
}
|
||||
fun updateItems(newItems: List<StreamItem>){
|
||||
fun updateItems(newItems: List<StreamItem>) {
|
||||
videoFeed.addAll(newItems)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlaylistViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val cell = layoutInflater.inflate(R.layout.playlist_row,parent,false)
|
||||
val cell = layoutInflater.inflate(R.layout.playlist_row, parent, false)
|
||||
return PlaylistViewHolder(cell)
|
||||
}
|
||||
|
||||
@ -46,9 +51,9 @@ class PlaylistAdapter(private val videoFeed: MutableList<StreamItem>, private va
|
||||
holder.v.findViewById<TextView>(R.id.playlist_duration).text = DateUtils.formatElapsedTime(streamItem.duration!!)
|
||||
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.playlist_thumbnail)
|
||||
Picasso.get().load(streamItem.thumbnail).into(thumbnailImage)
|
||||
holder.v.setOnClickListener{
|
||||
holder.v.setOnClickListener {
|
||||
var bundle = Bundle()
|
||||
bundle.putString("videoId",streamItem.url!!.replace("/watch?v=",""))
|
||||
bundle.putString("videoId", streamItem.url!!.replace("/watch?v=", ""))
|
||||
var frag = PlayerFragment()
|
||||
frag.arguments = bundle
|
||||
val activity = holder.v.context as AppCompatActivity
|
||||
@ -59,34 +64,33 @@ class PlaylistAdapter(private val videoFeed: MutableList<StreamItem>, private va
|
||||
.replace(R.id.container, frag)
|
||||
.commitNow()
|
||||
}
|
||||
if(isOwner){
|
||||
if (isOwner) {
|
||||
val delete = holder.v.findViewById<ImageView>(R.id.delete_playlist)
|
||||
delete.visibility = View.VISIBLE
|
||||
delete.setOnClickListener {
|
||||
val sharedPref = holder.v.context.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||
val token = sharedPref?.getString("token","")!!
|
||||
val token = sharedPref?.getString("token", "")!!
|
||||
removeFromPlaylist(token, position)
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun removeFromPlaylist(token: String, position: Int) {
|
||||
fun run() {
|
||||
GlobalScope.launch{
|
||||
GlobalScope.launch {
|
||||
val response = try {
|
||||
RetrofitInstance.api.removeFromPlaylist(token, PlaylistId(playlistId = playlistId, index = position))
|
||||
}catch(e: IOException) {
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
return@launch
|
||||
} catch (e: HttpException) {
|
||||
Log.e(TAG, "HttpException, unexpected response")
|
||||
return@launch
|
||||
}finally {
|
||||
|
||||
} finally {
|
||||
}
|
||||
try{
|
||||
if(response.message == "ok"){
|
||||
Log.d(TAG,"deleted!")
|
||||
try {
|
||||
if (response.message == "ok") {
|
||||
Log.d(TAG, "deleted!")
|
||||
videoFeed.removeAt(position)
|
||||
// FIXME: This needs to run on UI thread?
|
||||
activity.runOnUiThread { notifyDataSetChanged() }
|
||||
@ -95,17 +99,15 @@ class PlaylistAdapter(private val videoFeed: MutableList<StreamItem>, private va
|
||||
view.findViewById<ImageView>(R.id.boogh2).visibility=View.VISIBLE
|
||||
}*/
|
||||
}
|
||||
}catch (e:Exception){
|
||||
Log.e(TAG,e.toString())
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, e.toString())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
run()
|
||||
|
||||
}
|
||||
}
|
||||
class PlaylistViewHolder(val v: View): RecyclerView.ViewHolder(v){
|
||||
class PlaylistViewHolder(val v: View) : RecyclerView.ViewHolder(v) {
|
||||
init {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,25 +17,27 @@ import com.github.libretube.RetrofitInstance
|
||||
import com.github.libretube.obj.PlaylistId
|
||||
import com.github.libretube.obj.Playlists
|
||||
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 PlaylistsAdapter(private val playlists: MutableList<Playlists>, private val activity: Activity): RecyclerView.Adapter<PlaylistsViewHolder>() {
|
||||
class PlaylistsAdapter(
|
||||
private val playlists: MutableList<Playlists>,
|
||||
private val activity: Activity
|
||||
) : RecyclerView.Adapter<PlaylistsViewHolder>() {
|
||||
val TAG = "PlaylistsAdapter"
|
||||
override fun getItemCount(): Int {
|
||||
return playlists.size
|
||||
}
|
||||
fun updateItems(newItems: List<Playlists>){
|
||||
fun updateItems(newItems: List<Playlists>) {
|
||||
playlists.addAll(newItems)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlaylistsViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val cell = layoutInflater.inflate(R.layout.playlists_row,parent,false)
|
||||
val cell = layoutInflater.inflate(R.layout.playlists_row, parent, false)
|
||||
return PlaylistsViewHolder(cell)
|
||||
}
|
||||
|
||||
@ -50,7 +52,7 @@ class PlaylistsAdapter(private val playlists: MutableList<Playlists>, private va
|
||||
builder.setMessage(R.string.areYouSure)
|
||||
builder.setPositiveButton(R.string.yes) { dialog, which ->
|
||||
val sharedPref = holder.v.context.getSharedPreferences("token", Context.MODE_PRIVATE)
|
||||
val token = sharedPref?.getString("token","")!!
|
||||
val token = sharedPref?.getString("token", "")!!
|
||||
deletePlaylist(playlist.id!!, token, position)
|
||||
}
|
||||
builder.setNegativeButton(R.string.cancel) { dialog, which ->
|
||||
@ -58,31 +60,29 @@ class PlaylistsAdapter(private val playlists: MutableList<Playlists>, private va
|
||||
builder.show()
|
||||
}
|
||||
holder.v.setOnClickListener {
|
||||
//playlists clicked
|
||||
// playlists clicked
|
||||
val activity = holder.v.context as MainActivity
|
||||
val bundle = bundleOf("playlist_id" to playlist.id)
|
||||
activity.navController.navigate(R.id.playlistFragment,bundle)
|
||||
activity.navController.navigate(R.id.playlistFragment, bundle)
|
||||
}
|
||||
|
||||
}
|
||||
private fun deletePlaylist(id: String, token: String, position: Int) {
|
||||
fun run() {
|
||||
GlobalScope.launch{
|
||||
GlobalScope.launch {
|
||||
val response = try {
|
||||
RetrofitInstance.api.deletePlaylist(token, PlaylistId(id))
|
||||
}catch(e: IOException) {
|
||||
} catch (e: IOException) {
|
||||
println(e)
|
||||
Log.e(TAG, "IOException, you might not have internet connection")
|
||||
return@launch
|
||||
} catch (e: HttpException) {
|
||||
Log.e(TAG, "HttpException, unexpected response")
|
||||
return@launch
|
||||
}finally {
|
||||
|
||||
} finally {
|
||||
}
|
||||
try{
|
||||
if(response.message == "ok"){
|
||||
Log.d(TAG,"deleted!")
|
||||
try {
|
||||
if (response.message == "ok") {
|
||||
Log.d(TAG, "deleted!")
|
||||
playlists.removeAt(position)
|
||||
// FIXME: This needs to run on UI thread?
|
||||
activity.runOnUiThread { notifyDataSetChanged() }
|
||||
@ -91,18 +91,15 @@ class PlaylistsAdapter(private val playlists: MutableList<Playlists>, private va
|
||||
view.findViewById<ImageView>(R.id.boogh2).visibility=View.VISIBLE
|
||||
}*/
|
||||
}
|
||||
}catch (e:Exception){
|
||||
Log.e(TAG,e.toString())
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, e.toString())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
run()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
class PlaylistsViewHolder(val v: View): RecyclerView.ViewHolder(v){
|
||||
class PlaylistsViewHolder(val v: View) : RecyclerView.ViewHolder(v) {
|
||||
init {
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,9 @@ import com.github.libretube.formatShort
|
||||
import com.github.libretube.obj.SearchItem
|
||||
import com.squareup.picasso.Picasso
|
||||
|
||||
class SearchAdapter(private val searchItems: MutableList<SearchItem>) : RecyclerView.Adapter<CustomViewHolder1>() {
|
||||
|
||||
class SearchAdapter(private val searchItems: MutableList<SearchItem>): RecyclerView.Adapter<CustomViewHolder1>() {
|
||||
|
||||
fun updateItems(newItems: List<SearchItem>){
|
||||
fun updateItems(newItems: List<SearchItem>) {
|
||||
var searchItemsSize = searchItems.size
|
||||
searchItems.addAll(newItems)
|
||||
notifyItemRangeInserted(searchItemsSize, newItems.size)
|
||||
@ -38,7 +37,7 @@ class SearchAdapter(private val searchItems: MutableList<SearchItem>): RecyclerV
|
||||
else -> throw IllegalArgumentException("Invalid type")
|
||||
}
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val cell = layoutInflater.inflate(layout,parent,false)
|
||||
val cell = layoutInflater.inflate(layout, parent, false)
|
||||
return CustomViewHolder1(cell)
|
||||
}
|
||||
|
||||
@ -48,14 +47,14 @@ class SearchAdapter(private val searchItems: MutableList<SearchItem>): RecyclerV
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return when {
|
||||
searchItems[position].url!!.startsWith("/watch",false) -> 0
|
||||
searchItems[position].url!!.startsWith("/channel",false) -> 1
|
||||
searchItems[position].url!!.startsWith("/playlist",false) -> 2
|
||||
searchItems[position].url!!.startsWith("/watch", false) -> 0
|
||||
searchItems[position].url!!.startsWith("/channel", false) -> 1
|
||||
searchItems[position].url!!.startsWith("/playlist", false) -> 2
|
||||
else -> 3
|
||||
}
|
||||
}
|
||||
}
|
||||
class CustomViewHolder1(private val v: View): RecyclerView.ViewHolder(v){
|
||||
class CustomViewHolder1(private val v: View) : RecyclerView.ViewHolder(v) {
|
||||
|
||||
private fun bindWatch(item: SearchItem) {
|
||||
val thumbnailImage = v.findViewById<ImageView>(R.id.search_thumbnail)
|
||||
@ -72,9 +71,9 @@ class CustomViewHolder1(private val v: View): RecyclerView.ViewHolder(v){
|
||||
views.text = if (viewsString != "" && uploadDate != "") viewsString + " • " + uploadDate else viewsString + uploadDate
|
||||
val channelName = v.findViewById<TextView>(R.id.search_channel_name)
|
||||
channelName.text = item.uploaderName
|
||||
v.setOnClickListener{
|
||||
v.setOnClickListener {
|
||||
var bundle = Bundle()
|
||||
bundle.putString("videoId",item.url!!.replace("/watch?v=",""))
|
||||
bundle.putString("videoId", item.url!!.replace("/watch?v=", ""))
|
||||
var frag = PlayerFragment()
|
||||
frag.arguments = bundle
|
||||
val activity = v.context as AppCompatActivity
|
||||
@ -101,9 +100,9 @@ class CustomViewHolder1(private val v: View): RecyclerView.ViewHolder(v){
|
||||
v.setOnClickListener {
|
||||
val activity = v.context as MainActivity
|
||||
val bundle = bundleOf("channel_id" to item.url)
|
||||
activity.navController.navigate(R.id.channel,bundle)
|
||||
activity.navController.navigate(R.id.channel, bundle)
|
||||
}
|
||||
//todo sub button
|
||||
// todo sub button
|
||||
}
|
||||
private fun bindPlaylist(item: SearchItem) {
|
||||
val playlistImage = v.findViewById<ImageView>(R.id.search_thumbnail)
|
||||
@ -117,20 +116,20 @@ class CustomViewHolder1(private val v: View): RecyclerView.ViewHolder(v){
|
||||
val playlistVideosNumber = v.findViewById<TextView>(R.id.search_playlist_videos)
|
||||
if (item.videos?.toInt() != -1) playlistVideosNumber.text = v.context.getString(R.string.videoCount, item.videos.toString())
|
||||
v.setOnClickListener {
|
||||
//playlist clicked
|
||||
// playlist clicked
|
||||
val activity = v.context as MainActivity
|
||||
val bundle = bundleOf("playlist_id" to item.url)
|
||||
activity.navController.navigate(R.id.playlistFragment,bundle)
|
||||
activity.navController.navigate(R.id.playlistFragment, bundle)
|
||||
}
|
||||
}
|
||||
|
||||
fun bind(searchItem: SearchItem) {
|
||||
when {
|
||||
searchItem.url!!.startsWith("/watch",false) -> bindWatch(searchItem)
|
||||
searchItem.url!!.startsWith("/channel",false) -> bindChannel(searchItem)
|
||||
searchItem.url!!.startsWith("/playlist",false) -> bindPlaylist(searchItem)
|
||||
searchItem.url!!.startsWith("/watch", false) -> bindWatch(searchItem)
|
||||
searchItem.url!!.startsWith("/channel", false) -> bindChannel(searchItem)
|
||||
searchItem.url!!.startsWith("/playlist", false) -> bindPlaylist(searchItem)
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,16 +11,17 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.R
|
||||
import com.google.android.material.imageview.ShapeableImageView
|
||||
|
||||
|
||||
class SearchHistoryAdapter(private val context: Context, private var historyList: List<String> , private val editText : AutoCompleteTextView) :
|
||||
class SearchHistoryAdapter(
|
||||
private val context: Context,
|
||||
private var historyList: List<String>,
|
||||
private val editText: AutoCompleteTextView
|
||||
) :
|
||||
RecyclerView.Adapter<SearchHistoryViewHolder>() {
|
||||
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return historyList.size
|
||||
}
|
||||
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SearchHistoryViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val cell = layoutInflater.inflate(R.layout.searchhistory_row, parent, false)
|
||||
@ -31,7 +32,6 @@ class SearchHistoryAdapter(private val context: Context, private var historyList
|
||||
val history = historyList[position]
|
||||
holder.v.findViewById<TextView>(R.id.history_text).text = history
|
||||
|
||||
|
||||
holder.v.findViewById<ShapeableImageView>(R.id.delete_history).setOnClickListener {
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
@ -52,4 +52,4 @@ class SearchHistoryAdapter(private val context: Context, private var historyList
|
||||
class SearchHistoryViewHolder(val v: View) : RecyclerView.ViewHolder(v) {
|
||||
init {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,35 +18,35 @@ import com.github.libretube.formatShort
|
||||
import com.github.libretube.obj.StreamItem
|
||||
import com.squareup.picasso.Picasso
|
||||
|
||||
class SubscriptionAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Adapter<SubscriptionViewHolder>() {
|
||||
//private var limitedVideoFeed: MutableList<String> = [""].toMutableList()
|
||||
class SubscriptionAdapter(private val videoFeed: List<StreamItem>) : RecyclerView.Adapter<SubscriptionViewHolder>() {
|
||||
// private var limitedVideoFeed: MutableList<String> = [""].toMutableList()
|
||||
var i = 0
|
||||
override fun getItemCount(): Int {
|
||||
return i
|
||||
}
|
||||
|
||||
fun updateItems(){
|
||||
//limitedVideoFeed.add("")
|
||||
fun updateItems() {
|
||||
// limitedVideoFeed.add("")
|
||||
i += 10
|
||||
if(i>videoFeed.size)
|
||||
i=videoFeed.size
|
||||
if (i > videoFeed.size)
|
||||
i = videoFeed.size
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SubscriptionViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val cell = layoutInflater.inflate(R.layout.trending_row,parent,false)
|
||||
val cell = layoutInflater.inflate(R.layout.trending_row, parent, false)
|
||||
return SubscriptionViewHolder(cell)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: SubscriptionViewHolder, position: Int) {
|
||||
val trending = videoFeed[position]
|
||||
holder.v.findViewById<TextView>(R.id.textView_title).text = trending.title
|
||||
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.formatShort()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
|
||||
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName + " • " + trending.views.formatShort() + " • " + DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
|
||||
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.thumbnail)
|
||||
holder.v.findViewById<TextView>(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
|
||||
val channelImage = holder.v.findViewById<ImageView>(R.id.channel_image)
|
||||
channelImage.setOnClickListener{
|
||||
channelImage.setOnClickListener {
|
||||
val activity = holder.v.context as MainActivity
|
||||
val bundle = bundleOf("channel_id" to trending.uploaderUrl)
|
||||
activity.navController.navigate(R.id.channel, bundle)
|
||||
@ -56,15 +56,14 @@ class SubscriptionAdapter(private val videoFeed: List<StreamItem>): RecyclerView
|
||||
mainMotionLayout.transitionToEnd()
|
||||
activity.findViewById<MotionLayout>(R.id.playerMotionLayout).transitionToEnd()
|
||||
}
|
||||
}catch (e: Exception){
|
||||
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
Picasso.get().load(trending.thumbnail).into(thumbnailImage)
|
||||
Picasso.get().load(trending.uploaderAvatar).into(channelImage)
|
||||
holder.v.setOnClickListener{
|
||||
holder.v.setOnClickListener {
|
||||
var bundle = Bundle()
|
||||
bundle.putString("videoId",trending.url!!.replace("/watch?v=",""))
|
||||
bundle.putString("videoId", trending.url!!.replace("/watch?v=", ""))
|
||||
var frag = PlayerFragment()
|
||||
frag.arguments = bundle
|
||||
val activity = holder.v.context as AppCompatActivity
|
||||
@ -77,7 +76,7 @@ class SubscriptionAdapter(private val videoFeed: List<StreamItem>): RecyclerView
|
||||
}
|
||||
}
|
||||
}
|
||||
class SubscriptionViewHolder(val v: View): RecyclerView.ViewHolder(v){
|
||||
class SubscriptionViewHolder(val v: View) : RecyclerView.ViewHolder(v) {
|
||||
init {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,30 +12,30 @@ import com.github.libretube.R
|
||||
import com.github.libretube.obj.Subscription
|
||||
import com.squareup.picasso.Picasso
|
||||
|
||||
class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscription>): RecyclerView.Adapter<SubscriptionChannelViewHolder>() {
|
||||
class SubscriptionChannelAdapter(private val subscriptions: MutableList<Subscription>) : RecyclerView.Adapter<SubscriptionChannelViewHolder>() {
|
||||
override fun getItemCount(): Int {
|
||||
return subscriptions.size
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SubscriptionChannelViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val cell = layoutInflater.inflate(R.layout.channel_subscription_row,parent,false)
|
||||
val cell = layoutInflater.inflate(R.layout.channel_subscription_row, parent, false)
|
||||
return SubscriptionChannelViewHolder(cell)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: SubscriptionChannelViewHolder, position: Int) {
|
||||
val subscription = subscriptions[position]
|
||||
holder.v.findViewById<TextView>(R.id.subscription_channel_name).text=subscription.name
|
||||
holder.v.findViewById<TextView>(R.id.subscription_channel_name).text = subscription.name
|
||||
val avatar = holder.v.findViewById<ImageView>(R.id.subscription_channel_image)
|
||||
Picasso.get().load(subscription.avatar).into(avatar)
|
||||
holder.v.setOnClickListener{
|
||||
holder.v.setOnClickListener {
|
||||
val activity = holder.v.context as MainActivity
|
||||
val bundle = bundleOf("channel_id" to subscription.url)
|
||||
activity.navController.navigate(R.id.channel,bundle)
|
||||
activity.navController.navigate(R.id.channel, bundle)
|
||||
}
|
||||
}
|
||||
}
|
||||
class SubscriptionChannelViewHolder(val v: View): RecyclerView.ViewHolder(v){
|
||||
class SubscriptionChannelViewHolder(val v: View) : RecyclerView.ViewHolder(v) {
|
||||
init {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,25 +18,25 @@ import com.github.libretube.formatShort
|
||||
import com.github.libretube.obj.StreamItem
|
||||
import com.squareup.picasso.Picasso
|
||||
|
||||
class TrendingAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Adapter<CustomViewHolder>() {
|
||||
class TrendingAdapter(private val videoFeed: List<StreamItem>) : RecyclerView.Adapter<CustomViewHolder>() {
|
||||
override fun getItemCount(): Int {
|
||||
return videoFeed.size
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomViewHolder {
|
||||
val layoutInflater = LayoutInflater.from(parent.context)
|
||||
val cell = layoutInflater.inflate(R.layout.trending_row,parent,false)
|
||||
val cell = layoutInflater.inflate(R.layout.trending_row, parent, false)
|
||||
return CustomViewHolder(cell)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: CustomViewHolder, position: Int) {
|
||||
val trending = videoFeed[position]
|
||||
holder.v.findViewById<TextView>(R.id.textView_title).text = trending.title
|
||||
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.formatShort()+" • "+DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
|
||||
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName + " • " + trending.views.formatShort() + " • " + DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
|
||||
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.thumbnail)
|
||||
holder.v.findViewById<TextView>(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
|
||||
val channelImage = holder.v.findViewById<ImageView>(R.id.channel_image)
|
||||
channelImage.setOnClickListener{
|
||||
channelImage.setOnClickListener {
|
||||
val activity = holder.v.context as MainActivity
|
||||
val bundle = bundleOf("channel_id" to trending.uploaderUrl)
|
||||
activity.navController.navigate(R.id.channel, bundle)
|
||||
@ -46,23 +46,21 @@ class TrendingAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Ada
|
||||
mainMotionLayout.transitionToEnd()
|
||||
activity.findViewById<MotionLayout>(R.id.playerMotionLayout).transitionToEnd()
|
||||
}
|
||||
}catch (e: Exception){
|
||||
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
if (trending.thumbnail!!.isEmpty()) {
|
||||
} else{
|
||||
} else {
|
||||
Picasso.get().load(trending.thumbnail).into(thumbnailImage)
|
||||
}
|
||||
if (trending.uploaderAvatar!!.isEmpty()) {
|
||||
} else{
|
||||
} else {
|
||||
Picasso.get().load(trending.uploaderAvatar).into(channelImage)
|
||||
}
|
||||
|
||||
|
||||
holder.v.setOnClickListener{
|
||||
holder.v.setOnClickListener {
|
||||
var bundle = Bundle()
|
||||
bundle.putString("videoId",trending.url!!.replace("/watch?v=",""))
|
||||
bundle.putString("videoId", trending.url!!.replace("/watch?v=", ""))
|
||||
var frag = PlayerFragment()
|
||||
frag.arguments = bundle
|
||||
val activity = holder.v.context as AppCompatActivity
|
||||
@ -75,7 +73,7 @@ class TrendingAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Ada
|
||||
}
|
||||
}
|
||||
}
|
||||
class CustomViewHolder(val v: View): RecyclerView.ViewHolder(v){
|
||||
class CustomViewHolder(val v: View) : RecyclerView.ViewHolder(v) {
|
||||
init {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,4 @@ package com.github.libretube
|
||||
|
||||
import android.app.Application
|
||||
|
||||
class myApp : Application() {
|
||||
|
||||
}
|
||||
class myApp : Application()
|
||||
|
@ -7,6 +7,6 @@ data class ChapterSegment(
|
||||
var title: String?,
|
||||
var image: String?,
|
||||
var start: Int?
|
||||
){
|
||||
constructor(): this("","",-1)
|
||||
) {
|
||||
constructor() : this("", "", -1)
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ data class Comment(
|
||||
val pinned: Boolean?,
|
||||
val thumbnail: String?,
|
||||
val verified: Boolean?
|
||||
){
|
||||
constructor(): this("", "","","","",null,0,null,"",null)
|
||||
) {
|
||||
constructor() : this("", "", "", "", "", null, 0, null, "", null)
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,9 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class CommentsPage(
|
||||
val comments: MutableList<Comment> = arrayListOf(),
|
||||
val disabled: Boolean? = null,
|
||||
val nextpage: String? = "",
|
||||
){
|
||||
constructor(): this(arrayListOf(),null,"")
|
||||
val comments: MutableList<Comment> = arrayListOf(),
|
||||
val disabled: Boolean? = null,
|
||||
val nextpage: String? = "",
|
||||
) {
|
||||
constructor() : this(arrayListOf(), null, "")
|
||||
}
|
||||
|
@ -18,6 +18,6 @@ data class PipedStream(
|
||||
var width: Int?,
|
||||
var height: Int?,
|
||||
var fps: Int?
|
||||
){
|
||||
constructor(): this("","","","","",null,-1,-1,-1,-1,-1,-1,-1,-1)
|
||||
) {
|
||||
constructor() : this("", "", "", "", "", null, -1, -1, -1, -1, -1, -1, -1, -1)
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ data class SearchItem(
|
||||
var uploaderName: String?,
|
||||
var uploaded: Long?,
|
||||
var shortDescription: String?,
|
||||
//Video only attributes
|
||||
// Video only attributes
|
||||
var title: String?,
|
||||
var uploaderUrl: String?,
|
||||
var uploaderAvatar: String?,
|
||||
@ -17,12 +17,12 @@ data class SearchItem(
|
||||
var duration: Long?,
|
||||
var views: Long?,
|
||||
var uploaderVerified: Boolean?,
|
||||
//Channel and Playlist attributes
|
||||
// Channel and Playlist attributes
|
||||
var name: String? = null,
|
||||
var description: String? = null,
|
||||
var subscribers: Long? = -1,
|
||||
var videos: Long? = -1,
|
||||
var verified: Boolean? = null
|
||||
){
|
||||
constructor() : this("","","",0,"","","","","",0,0,null)
|
||||
) {
|
||||
constructor() : this("", "", "", 0, "", "", "", "", "", 0, 0, null)
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class SearchResult(
|
||||
val items: MutableList<SearchItem>? = arrayListOf(),
|
||||
val nextpage: String? ="",
|
||||
val suggestion: String?="",
|
||||
val nextpage: String? = "",
|
||||
val suggestion: String? = "",
|
||||
val corrected: Boolean? = null
|
||||
)
|
||||
|
@ -7,6 +7,6 @@ data class Segment(
|
||||
val actionType: String?,
|
||||
val category: String?,
|
||||
val segment: List<Float>?
|
||||
){
|
||||
constructor(): this("", "", arrayListOf())
|
||||
) {
|
||||
constructor() : this("", "", arrayListOf())
|
||||
}
|
||||
|
@ -5,6 +5,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
data class Segments(
|
||||
val segments: MutableList<Segment> = arrayListOf()
|
||||
){
|
||||
constructor(): this(arrayListOf())
|
||||
) {
|
||||
constructor() : this(arrayListOf())
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ data class StreamItem(
|
||||
var uploaderVerified: Boolean?,
|
||||
var uploaded: Long?,
|
||||
var shortDescription: String?
|
||||
){
|
||||
constructor() : this("","","","","","","",0,0,null,0,"")
|
||||
) {
|
||||
constructor() : this("", "", "", "", "", "", "", 0, 0, null, 0, "")
|
||||
}
|
||||
|
@ -26,7 +26,9 @@ data class Streams(
|
||||
val livestream: Boolean?,
|
||||
val proxyUrl: String?,
|
||||
val chapters: List<ChapterSegment>?
|
||||
){
|
||||
constructor(): this("","","","","","","","","","",null,-1,-1,-1,-1, emptyList(), emptyList(),
|
||||
emptyList(), emptyList(), null,"", emptyList())
|
||||
) {
|
||||
constructor() : this(
|
||||
"", "", "", "", "", "", "", "", "", "", null, -1, -1, -1, -1, emptyList(), emptyList(),
|
||||
emptyList(), emptyList(), null, "", emptyList()
|
||||
)
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ data class Subtitle(
|
||||
val name: String?,
|
||||
val code: String?,
|
||||
val autoGenerated: Boolean?
|
||||
){
|
||||
constructor(): this("","","","",null)
|
||||
) {
|
||||
constructor() : this("", "", "", "", null)
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.github.libretube
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
@ -14,4 +13,4 @@ class ExampleUnitTest {
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user