Skip to content

Commit c47bd05

Browse files
committed
fix(message-list): crash caused by using RelativeLayout on message_list.xml and not on split_message_list.xml
1 parent 7034daa commit c47bd05

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

legacy/ui/legacy/src/main/res/layout/split_message_list.xml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,44 @@
88
android:layout_height="match_parent"
99
tools:context="com.fsck.k9.activity.MessageHomeActivity"
1010
>
11+
<!--
12+
As the navigation of Message List (MessageHomeActivity) is based on the ViewSwitcher,
13+
which just toggle the visibility of existing views rather than creating/destroying the
14+
Fragments, the Fragment's lifecycle methods, such as onViewCreated, are not properly called.
1115
12-
<androidx.coordinatorlayout.widget.CoordinatorLayout
16+
Modern layouts (ConstraintLayout, CoordinatorLayout) optimize measurement during visibility
17+
toggles and WindowInsets updates, sometimes causing a transient layout pass with incorrect bounds.
18+
The RecyclerView incorrectly treats this pass as a successful update and marks its state as "clean".
19+
Consequently, it fails to trigger onBindViewHolder when the view is fully restored, leaving the
20+
UI stuck displaying the previous stale state instead of the new data.
21+
22+
RelativeLayout is used to enforce strict vertical dependencies. By using layout_below, it
23+
ensures the Toolbar is measured before the container. This prevents the race condition and forces
24+
the RecyclerView to recognize its actual bounds, ensuring the adapter binds correctly without
25+
performance-heavy requestLayout() calls.
26+
27+
Until we move this screen to use a modern navigation system, or rewrite it using Jetpack Compose,
28+
we need to use this workaround.
29+
-->
30+
<RelativeLayout
1331
android:id="@+id/coordinator_layout"
1432
android:layout_width="match_parent"
1533
android:layout_height="match_parent"
16-
android:orientation="vertical"
1734
>
1835

1936
<com.google.android.material.appbar.AppBarLayout
2037
android:id="@+id/app_bar_layout"
2138
style="@style/Widget.App.AppBarLayout"
2239
android:layout_width="match_parent"
2340
android:layout_height="wrap_content"
41+
android:layout_alignParentTop="true"
2442
>
2543

2644
<include
2745
android:id="@+id/toolbar"
2846
layout="@layout/message_list_toolbar"
2947
android:layout_width="match_parent"
3048
android:layout_height="wrap_content"
31-
android:layout_alignParentTop="true"
3249
/>
3350

3451
</com.google.android.material.appbar.AppBarLayout>
@@ -37,7 +54,7 @@
3754
android:id="@+id/content_container"
3855
android:layout_width="match_parent"
3956
android:layout_height="match_parent"
40-
app:layout_behavior="@string/appbar_scrolling_view_behavior"
57+
android:layout_below="@id/app_bar_layout"
4158
>
4259

4360
<ProgressBar
@@ -86,7 +103,7 @@
86103

87104
</FrameLayout>
88105

89-
</androidx.coordinatorlayout.widget.CoordinatorLayout>
106+
</RelativeLayout>
90107

91108
<include layout="@layout/navigation_drawer_content" />
92109

0 commit comments

Comments
 (0)