|
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <androidx.drawerlayout.widget.DrawerLayout |
3 | 3 | xmlns:android="http://schemas.android.com/apk/res/android" |
4 | | - xmlns:app="http://schemas.android.com/apk/res-auto" |
5 | 4 | xmlns:tools="http://schemas.android.com/tools" |
6 | 5 | android:id="@+id/navigation_drawer_layout" |
7 | 6 | android:layout_width="match_parent" |
8 | 7 | android:layout_height="match_parent" |
9 | 8 | tools:context="com.fsck.k9.activity.MainActivity" |
10 | 9 | > |
11 | 10 |
|
12 | | - <androidx.coordinatorlayout.widget.CoordinatorLayout |
| 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. |
| 15 | +
|
| 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 |
|
58 | 75 |
|
59 | 76 | <androidx.fragment.app.FragmentContainerView |
60 | 77 | android:id="@+id/message_list_container" |
61 | | - android:layout_width="fill_parent" |
62 | | - android:layout_height="fill_parent" |
| 78 | + android:layout_width="match_parent" |
| 79 | + android:layout_height="match_parent" |
63 | 80 | tools:layout="@layout/message_list_fragment" |
64 | 81 | /> |
65 | 82 |
|
66 | 83 | <androidx.fragment.app.FragmentContainerView |
67 | 84 | android:id="@+id/message_view_container" |
68 | | - android:layout_width="fill_parent" |
69 | | - android:layout_height="fill_parent" |
| 85 | + android:layout_width="match_parent" |
| 86 | + android:layout_height="match_parent" |
70 | 87 | tools:layout="@layout/message" |
71 | 88 | /> |
72 | 89 |
|
73 | 90 | </com.fsck.k9.view.ViewSwitcher> |
74 | 91 |
|
75 | 92 | </FrameLayout> |
76 | 93 |
|
77 | | - </androidx.coordinatorlayout.widget.CoordinatorLayout> |
| 94 | + </RelativeLayout> |
78 | 95 |
|
79 | 96 | <include layout="@layout/navigation_drawer_content" /> |
80 | 97 |
|
|
0 commit comments