fix subscriptions

This commit is contained in:
Bnyro 2022-07-21 17:11:17 +02:00
parent cd43515277
commit e3f538422e
3 changed files with 47 additions and 8 deletions

View File

@ -19,8 +19,17 @@ class SubscriptionAdapter(
) : RecyclerView.Adapter<SubscriptionViewHolder>() {
private val TAG = "SubscriptionAdapter"
var i = 0
override fun getItemCount(): Int {
return videoFeed.size
return i
}
fun updateItems() {
i += 10
if (i > videoFeed.size) {
i = videoFeed.size
}
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SubscriptionViewHolder {

View File

@ -85,6 +85,20 @@ class SubscriptionsFragment : Fragment() {
binding.subFeed.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
}
@ -108,6 +122,7 @@ class SubscriptionsFragment : Fragment() {
if (response.isNotEmpty()) {
subscriptionAdapter = SubscriptionAdapter(response, childFragmentManager)
feedRecView.adapter = subscriptionAdapter
subscriptionAdapter?.updateItems()
} else {
runOnUiThread {
with(binding.boogh) {

View File

@ -94,18 +94,33 @@
</com.google.android.material.card.MaterialCardView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
<androidx.recyclerview.widget.RecyclerView
android:visibility="gone"
android:id="@+id/sub_channels"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
android:visibility="gone" />
android:nestedScrollingEnabled="false" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/sub_feed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:nestedScrollingEnabled="false" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</com.github.libretube.views.CustomSwipeToRefresh>