Merge pull request #908 from Bnyro/master

fix subscriptions not loading
This commit is contained in:
Bnyro 2022-07-29 08:05:23 +02:00 committed by GitHub
commit 878851034c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 27 deletions

View File

@ -16,12 +16,24 @@ import com.github.libretube.util.setWatchProgressLength
class TrendingAdapter( class TrendingAdapter(
private val streamItems: List<StreamItem>, private val streamItems: List<StreamItem>,
private val childFragmentManager: FragmentManager private val childFragmentManager: FragmentManager,
private val showAllAtOne: Boolean = true
) : RecyclerView.Adapter<SubscriptionViewHolder>() { ) : RecyclerView.Adapter<SubscriptionViewHolder>() {
private val TAG = "SubscriptionAdapter" private val TAG = "TrendingAdapter"
var index = 10
override fun getItemCount(): Int { 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 { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SubscriptionViewHolder {

View File

@ -600,7 +600,6 @@ class PlayerFragment : Fragment() {
} }
mainActivity.requestedOrientation = orientation mainActivity.requestedOrientation = orientation
} }
binding.player.setDoubleTapOverlayLayoutParams(90)
Globals.IS_FULL_SCREEN = true Globals.IS_FULL_SCREEN = true
} }

View File

@ -85,6 +85,20 @@ class SubscriptionsFragment : Fragment() {
binding.subFeedContainer.visibility = View.VISIBLE 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 { } else {
binding.subRefresh.isEnabled = false binding.subRefresh.isEnabled = false
} }
@ -106,7 +120,7 @@ class SubscriptionsFragment : Fragment() {
binding.subRefresh.isRefreshing = false binding.subRefresh.isRefreshing = false
} }
if (response.isNotEmpty()) { if (response.isNotEmpty()) {
subscriptionAdapter = TrendingAdapter(response, childFragmentManager) subscriptionAdapter = TrendingAdapter(response, childFragmentManager, false)
feedRecView.adapter = subscriptionAdapter feedRecView.adapter = subscriptionAdapter
} else { } else {
runOnUiThread { runOnUiThread {

View File

@ -5,7 +5,6 @@ import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View import android.view.View
import com.github.libretube.R
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
import com.github.libretube.util.DoubleTapListener import com.github.libretube.util.DoubleTapListener
import com.github.libretube.util.OnDoubleTapEventListener import com.github.libretube.util.OnDoubleTapEventListener
@ -54,26 +53,6 @@ internal class CustomExoPlayerView(
setOnClickListener(doubleTouchListener) setOnClickListener(doubleTouchListener)
} }
override fun hideController() {
super.hideController()
setDoubleTapOverlayLayoutParams(0)
}
override fun showController() {
setDoubleTapOverlayLayoutParams(90)
super.showController()
}
// set the top and bottom margin of the double tap overlay
fun setDoubleTapOverlayLayoutParams(margin: Int) {
val dpMargin = resources?.displayMetrics?.density!!.toInt() * margin
val doubleTapOverlay = binding.root.findViewById<DoubleTapOverlay>(R.id.doubleTapOverlay)
val params = doubleTapOverlay.layoutParams as MarginLayoutParams
params.topMargin = dpMargin
params.bottomMargin = dpMargin
doubleTapOverlay.layoutParams = params
}
override fun onTouchEvent(event: MotionEvent): Boolean { override fun onTouchEvent(event: MotionEvent): Boolean {
// save the x position of the touch event // save the x position of the touch event
xPos = event.x xPos = event.x

View File

@ -377,7 +377,9 @@
<com.github.libretube.views.DoubleTapOverlay <com.github.libretube.views.DoubleTapOverlay
android:id="@+id/doubleTapOverlay" android:id="@+id/doubleTapOverlay"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_gravity="center"
android:gravity="center"
android:layout_height="wrap_content" />
</com.github.libretube.views.CustomExoPlayerView> </com.github.libretube.views.CustomExoPlayerView>