Skip to content

Commit

Permalink
fix #213
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Sep 10, 2024
1 parent 764a56b commit 1fc6778
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class MyRecyclerView(context: Context, attributeSet: AttributeSet?, defStyleAttr
private var scrollIsNatural = false

override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
super.onLayout(changed, l, t, r, b)
if (lastWidth != width) {
adapter.dispatchToAdapter { it.onWidthChanged(width) }
lastWidth = width
Expand All @@ -63,6 +62,7 @@ class MyRecyclerView(context: Context, attributeSet: AttributeSet?, defStyleAttr
deferredFastScrollBuilder = null
}
}
super.onLayout(changed, l, t, r, b)
}

private fun RecyclerView.Adapter<*>?.dispatchToAdapter(action: (Adapter<*>) -> Unit) {
Expand Down Expand Up @@ -161,6 +161,12 @@ class MyRecyclerView(context: Context, attributeSet: AttributeSet?, defStyleAttr
fsBuilder()
}

override fun setAdapter(adapter: RecyclerView.Adapter<*>?) {
super.setAdapter(adapter)
if (width != 0)
adapter.dispatchToAdapter { it.onWidthChanged(width) }
}

override fun onOffsetChanged(unused: AppBarLayout?, offset: Int) {
if (offset == 0) ah?.hideScrollbar()
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<dimen name="decor_height">48dp</dimen>
<dimen name="list_height">75dp</dimen>
<dimen name="larger_list_height">78dp</dimen>
<dimen name="grid_card_label_height">45dp</dimen>
<dimen name="grid_card_label_height">70sp</dimen>
<dimen name="grid_card_margin_top">8dp</dimen>
<dimen name="grid_card_margin_label">12.5dp</dimen>
<dimen name="grid_card_padding_bottom">24dp</dimen>
<dimen name="grid_card_padding_bottom">0dp</dimen>
<dimen name="lyric_top_padding">36dp</dimen>
<dimen name="lyric_bottom_padding">640dp</dimen>
</resources>

0 comments on commit 1fc6778

Please sign in to comment.