mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
fix subscriptions
This commit is contained in:
parent
03a6e190a1
commit
ba0263791c
@ -16,12 +16,24 @@ import com.github.libretube.util.setWatchProgressLength
|
||||
|
||||
class TrendingAdapter(
|
||||
private val streamItems: List<StreamItem>,
|
||||
private val childFragmentManager: FragmentManager
|
||||
private val childFragmentManager: FragmentManager,
|
||||
private val showAllAtOne: Boolean = true
|
||||
) : RecyclerView.Adapter<SubscriptionViewHolder>() {
|
||||
private val TAG = "SubscriptionAdapter"
|
||||
private val TAG = "TrendingAdapter"
|
||||
|
||||
var index = 10
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return streamItems.size
|
||||
return if (showAllAtOne) streamItems.size
|
||||
else index
|
||||
}
|
||||
|
||||
fun updateItems() {
|
||||
index += 10
|
||||
if (index > streamItems.size) {
|
||||
index = streamItems.size
|
||||
}
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SubscriptionViewHolder {
|
||||
|
@ -85,6 +85,20 @@ class SubscriptionsFragment : Fragment() {
|
||||
binding.subFeedContainer.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
binding.scrollviewSub.viewTreeObserver
|
||||
.addOnScrollChangedListener {
|
||||
if (binding.scrollviewSub.getChildAt(0).bottom
|
||||
== (binding.scrollviewSub.height + binding.scrollviewSub.scrollY)
|
||||
) {
|
||||
// scroll view is at bottom
|
||||
if (isLoaded) {
|
||||
binding.subRefresh.isRefreshing = true
|
||||
subscriptionAdapter?.updateItems()
|
||||
binding.subRefresh.isRefreshing = false
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
binding.subRefresh.isEnabled = false
|
||||
}
|
||||
@ -106,7 +120,7 @@ class SubscriptionsFragment : Fragment() {
|
||||
binding.subRefresh.isRefreshing = false
|
||||
}
|
||||
if (response.isNotEmpty()) {
|
||||
subscriptionAdapter = TrendingAdapter(response, childFragmentManager)
|
||||
subscriptionAdapter = TrendingAdapter(response, childFragmentManager, false)
|
||||
feedRecView.adapter = subscriptionAdapter
|
||||
} else {
|
||||
runOnUiThread {
|
||||
|
@ -5,7 +5,6 @@ import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
|
||||
import com.github.libretube.util.DoubleTapListener
|
||||
import com.github.libretube.util.OnDoubleTapEventListener
|
||||
|
Loading…
x
Reference in New Issue
Block a user