Magisk/app/src/main/res/layout/fragment_module_md2.xml

68 lines
2.4 KiB
XML
Raw Normal View History

2019-10-17 18:57:00 +02:00
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
2019-10-17 18:57:00 +02:00
<data>
2020-01-13 22:01:46 +08:00
<import type="com.topjohnwu.magisk.core.Config" />
2019-10-17 18:57:00 +02:00
<variable
name="viewModel"
2020-01-13 00:43:09 +08:00
type="com.topjohnwu.magisk.ui.module.ModuleViewModel" />
2019-10-17 18:57:00 +02:00
</data>
<FrameLayout
2019-10-17 18:57:00 +02:00
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/module_list"
2022-01-17 15:08:54 +08:00
gone="@{viewModel.loading}"
itemBinding="@{viewModel.itemBinding}"
items="@{viewModel.items}"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:orientation="vertical"
android:paddingTop="@dimen/internal_action_bar_size"
2022-01-17 15:08:54 +08:00
android:paddingBottom="@dimen/internal_action_bar_size"
app:fitsSystemWindowsInsets="top|bottom"
Fixed modules screen crashing on load This commit fixes the issue of adding single-span items in between full-span items whilst using `StaggeredGridLayoutManager` on recycler view. Adding such items results in: ``` java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 13 at java.util.Arrays.rangeCheck(Arrays.java:123) at java.util.Arrays.fill(Arrays.java:2828) at androidx.recyclerview.widget.StaggeredGridLayoutManager$LazySpanLookup.invalidateAfter(StaggeredGridLayoutManager.java:2876) at androidx.recyclerview.widget.StaggeredGridLayoutManager.handleUpdate(StaggeredGridLayoutManager.java:1548) at androidx.recyclerview.widget.StaggeredGridLayoutManager.onItemsUpdated(StaggeredGridLayoutManager.java:1524) at androidx.recyclerview.widget.RecyclerView$6.dispatchUpdate(RecyclerView.java:1021) at androidx.recyclerview.widget.RecyclerView$6.onDispatchSecondPass(RecyclerView.java:1032) at androidx.recyclerview.widget.AdapterHelper.consumePostponedUpdates(AdapterHelper.java:121) at androidx.recyclerview.widget.AdapterHelper.consumeUpdatesInOnePass(AdapterHelper.java:557) at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4128) at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851) at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404) ...and more ``` Affects versions including and prior to androidx.recyclerview:recyclerview:1.2.0-alpha02 (at the time of this commit) and possibly more after that. This bug is caused by a single fact and that is - array inside of `LazySpanLookup` is not being invalidated and resized correctly when non-full-span item is being added in between of two full-span items. The invalidation however passes on some (high performance) devices so it doesn't necessarily cause issues for _some_ users; others keep getting the same crash over and over again. Possible fix for anyone reading this, in the hope of fixing the same error, is to copy-paste the `StaggeredGridLayoutManager` and fix the array length before calling `Arrays.fill()`. There's no fix from user's perspective if you need to keep the UI as-is. We however don't need the UI as-is, so we're instead opting to use LinearLayoutManager until is the issue resolved. Continues tracking at https://issuetracker.google.com/issues/37034096 Close #2631
2020-04-11 17:58:10 +02:00
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_module_md2" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<TextView
2022-05-29 16:40:20 +08:00
goneUnless="@{viewModel.loading}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
2020-09-24 04:44:44 +08:00
android:text="@string/loading"
android:textAppearance="@style/AppearanceFoundation.Title"
android:textStyle="bold" />
<ProgressBar
style="@style/WidgetFoundation.ProgressBar.Indeterminate"
2022-05-29 16:40:20 +08:00
goneUnless="@{viewModel.loading}"
android:layout_marginTop="@dimen/l1" />
2022-05-29 16:40:20 +08:00
<TextView
gone="@{viewModel.loading || viewModel.items.size() != 1 }"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/module_empty"
android:textAppearance="@style/AppearanceFoundation.Title"
android:textStyle="bold" />
</LinearLayout>
</FrameLayout>
2019-10-17 18:57:00 +02:00
2020-01-13 00:43:09 +08:00
</layout>