mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 02:25:28 +00:00
Fixed slow scrolling and list updates on hide screen
This commit is contained in:
parent
b2b81a5d0f
commit
c5f2f63458
@ -2,6 +2,7 @@ package com.topjohnwu.magisk.redesign.hide
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Insets
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
@ -24,13 +25,21 @@ class HideFragment : CompatFragment<HideViewModel, FragmentHideMd2Binding>() {
|
||||
setHasOptionsMenu(true)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val lama = binding.hideContent.layoutManager ?: return
|
||||
lama.isAutoMeasureEnabled = false
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.menu_hide_md2, menu)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.action_focus_up -> binding.hideScrollContainer.fullScroll(View.FOCUS_UP)
|
||||
R.id.action_focus_up -> binding.hideContent
|
||||
.also { it.scrollToPosition(10) }
|
||||
.also { it.smoothScrollToPosition(0) }
|
||||
}
|
||||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.topjohnwu.magisk.redesign.module
|
||||
import android.graphics.Insets
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.databinding.FragmentModuleMd2Binding
|
||||
import com.topjohnwu.magisk.redesign.compat.CompatFragment
|
||||
@ -37,7 +36,7 @@ class ModuleFragment : CompatFragment<ModuleViewModel, FragmentModuleMd2Binding>
|
||||
}
|
||||
|
||||
private fun setEndlessScroller() {
|
||||
val lama = binding.moduleRemote.layoutManager as? StaggeredGridLayoutManager ?: return
|
||||
val lama = binding.moduleRemote.layoutManager ?: return
|
||||
lama.isAutoMeasureEnabled = false
|
||||
|
||||
listener = EndlessRecyclerScrollListener(lama, viewModel::loadRemote)
|
||||
|
@ -17,28 +17,33 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/hide_scroll_container"
|
||||
onScrollStateChanged="@{() -> viewModel.hideFilter()}"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/hide_content"
|
||||
dividerVertical="@{R.drawable.divider_l1}"
|
||||
invisibleUnless="@{viewModel.loaded || !viewModel.items.empty}"
|
||||
itemBinding="@{viewModel.itemBinding}"
|
||||
items="@{viewModel.items}"
|
||||
nestedScrollingEnabled="@{false}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
android:fillViewport="true"
|
||||
android:paddingTop="@{viewModel.insets.top + (int) @dimen/internal_action_bar_size + (int) @dimen/l1}"
|
||||
android:paddingBottom="@{viewModel.insets.bottom}"
|
||||
tools:paddingTop="40dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="@dimen/l1"
|
||||
android:paddingEnd="@dimen/l1"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/item_hide_md2"
|
||||
tools:paddingTop="40dp" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
style="?styleCardVariant"
|
||||
style="?styleCardElevated"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginStart="@dimen/l1"
|
||||
android:layout_marginEnd="@dimen/l1"
|
||||
android:layout_marginBottom="@{viewModel.insets.bottom + (int) @dimen/l1}"
|
||||
app:cardCornerRadius="24dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
@ -142,26 +147,6 @@
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
dividerVertical="@{R.drawable.divider_l1}"
|
||||
invisibleUnless="@{viewModel.loaded || !viewModel.items.empty}"
|
||||
itemBinding="@{viewModel.itemBinding}"
|
||||
items="@{viewModel.items}"
|
||||
nestedScrollingEnabled="@{false}"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/l1"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="@dimen/l1"
|
||||
android:paddingEnd="@dimen/l1"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/item_hide_md2" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<LinearLayout
|
||||
goneUnless="@{viewModel.loading && viewModel.items.empty}"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -125,7 +125,7 @@
|
||||
style="?styleProgressDeterminate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_gravity="top"
|
||||
progressAnimated="@{item.itemsCheckedPercent}" />
|
||||
android:progress="@{item.itemsCheckedPercent}" />
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user