prevent scroll to top from showing when it shouldn't

fix zero state

Changelog: changed
This commit is contained in:
Kai 2025-07-11 12:18:02 -05:00
commit e1abb7f8ae
No known key found for this signature in database
5 changed files with 14 additions and 13 deletions

View file

@ -1155,7 +1155,6 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
if (segment.isMainView) {
var transaction = supportFragmentManager.beginTransaction();
transaction.setReorderingAllowed(true)
if (segment.topBar != null) {
if (segment.topBar != fragCurrent.topBar) {
transaction = transaction

View file

@ -101,6 +101,8 @@ class ShortsFragment : MainFragment() {
viewPager?.adapter?.notifyDataSetChanged()
viewPager?.currentItem = 0
}
updateZeroState()
}
override fun onCreateMainView(
@ -201,7 +203,7 @@ class ShortsFragment : MainFragment() {
}
private fun updateZeroState() {
if (mainShorts.isEmpty()) {
if (mainShorts.isEmpty() && !isChannelShortsMode && loadPagerTask == null) {
zeroState.visibility = View.VISIBLE
} else {
zeroState.visibility = View.GONE

View file

@ -3018,7 +3018,7 @@ class VideoDetailView : ConstraintLayout {
}
else if(isOverlayed) {
_playerProgress.layoutParams = _playerProgress.layoutParams.apply {
(this as MarginLayoutParams).bottomMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, -6f, resources.displayMetrics).toInt();
(this as MarginLayoutParams).bottomMargin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, -2f, resources.displayMetrics).toInt();
};
_playerProgress.elevation = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5f, resources.displayMetrics);
}

View file

@ -68,15 +68,7 @@ class CommentsList : ConstraintLayout {
UIDialogs.showGeneralRetryErrorDialog(context, it.message ?: "", it, { loadNextPage() });
};
private val _scrollListener = object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy);
onScrolled();
val totalScrollDistance = recyclerView.computeVerticalScrollOffset()
_layoutScrollToTop.visibility = if (totalScrollDistance > recyclerView.height) View.VISIBLE else View.GONE
}
};
private val _scrollListener: RecyclerView.OnScrollListener
private var _loader: (suspend () -> IPager<IPlatformComment>)? = null;
private val _adapterComments: InsertedViewAdapterWithLoader<CommentViewHolder>;
@ -131,6 +123,14 @@ class CommentsList : ConstraintLayout {
_llmReplies = LinearLayoutManager(context);
_recyclerComments.layoutManager = _llmReplies;
_recyclerComments.adapter = _adapterComments;
_scrollListener = object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy);
onScrolled();
_layoutScrollToTop.visibility = if (_llmReplies.findFirstCompletelyVisibleItemPosition() > 5) View.VISIBLE else View.GONE
}
};
_recyclerComments.addOnScrollListener(_scrollListener);
}

View file

@ -38,7 +38,7 @@
<LinearLayout
android:id="@+id/bottom_bar_buttons"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_height="52dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"