|
8 | 8 | android:layout_height="match_parent" |
9 | 9 | tools:context="com.fsck.k9.activity.MessageHomeActivity" |
10 | 10 | > |
| 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. |
11 | 15 |
|
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 |
13 | 31 | android:id="@+id/coordinator_layout" |
14 | 32 | android:layout_width="match_parent" |
15 | 33 | android:layout_height="match_parent" |
16 | | - android:orientation="vertical" |
17 | 34 | > |
18 | 35 |
|
19 | 36 | <com.google.android.material.appbar.AppBarLayout |
20 | 37 | android:id="@+id/app_bar_layout" |
21 | 38 | style="@style/Widget.App.AppBarLayout" |
22 | 39 | android:layout_width="match_parent" |
23 | 40 | android:layout_height="wrap_content" |
| 41 | + android:layout_alignParentTop="true" |
24 | 42 | > |
25 | 43 |
|
26 | 44 | <include |
27 | 45 | android:id="@+id/toolbar" |
28 | 46 | layout="@layout/message_list_toolbar" |
29 | 47 | android:layout_width="match_parent" |
30 | 48 | android:layout_height="wrap_content" |
31 | | - android:layout_alignParentTop="true" |
32 | 49 | /> |
33 | 50 |
|
34 | 51 | </com.google.android.material.appbar.AppBarLayout> |
|
37 | 54 | android:id="@+id/content_container" |
38 | 55 | android:layout_width="match_parent" |
39 | 56 | android:layout_height="match_parent" |
40 | | - app:layout_behavior="@string/appbar_scrolling_view_behavior" |
| 57 | + android:layout_below="@id/app_bar_layout" |
41 | 58 | > |
42 | 59 |
|
43 | 60 | <ProgressBar |
|
86 | 103 |
|
87 | 104 | </FrameLayout> |
88 | 105 |
|
89 | | - </androidx.coordinatorlayout.widget.CoordinatorLayout> |
| 106 | + </RelativeLayout> |
90 | 107 |
|
91 | 108 | <include layout="@layout/navigation_drawer_content" /> |
92 | 109 |
|
|
0 commit comments