fix subscriptions

This commit is contained in:
Bnyro 2022-07-29 08:04:51 +02:00
parent 03a6e190a1
commit ba0263791c
3 changed files with 30 additions and 5 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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