Fix janky in App info screen
If a Recycle view inside in a NestedScrollView, The times of calling recyclerView#onCreateViewHolder() is requal to its data set. When there are large set of apps need to be shown, RecyclerView will need to take many time to call onCreateViewHolder for each item. So, it causes the screen is janky or freeze UI when page is loading large data set. For now, we get rid of NestedScrollView, just use RecycleView and AppBarLayout to have same bahavior for spinner. Fixes: 124384314 Fixes: 123036231 Fixes: 122964660 Fixes: 123088178 Test: 1. Select show system in App info screen. Observe whether there is any janky. 2. Select show system in App info screen, and then change device orientation. Observer whether there is any janky. 3. Go to Settings > Apps & notifications> Advanced > Special app access > Select "battery optimization", and then Tap drop down and select "all apps". Observe whether ther is any janky. Change-Id: Icd65e91eec3b32476d80cc12e9c4baa71151306a
This commit is contained in:
@@ -18,7 +18,8 @@
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent">
|
||||
|
||||
<com.android.settingslib.widget.settingsspinner.SettingsSpinner
|
||||
android:id="@+id/filter_spinner"
|
||||
|
@@ -21,17 +21,11 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true"
|
||||
settings:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/content_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/list_container"
|
||||
android:layout_width="match_parent"
|
||||
@@ -47,6 +41,7 @@
|
||||
android:id="@+id/apps_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false"
|
||||
settings:fastScrollEnabled="true"
|
||||
settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
|
||||
settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
|
||||
@@ -71,8 +66,6 @@
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
@@ -186,7 +186,6 @@ public class ManageApplications extends InstrumentedFragment
|
||||
|
||||
private View mLoadingContainer;
|
||||
private View mListContainer;
|
||||
private RecyclerView mRecyclerView;
|
||||
private SearchView mSearchView;
|
||||
|
||||
// Size resource used for packages whose size computation failed for some reason
|
||||
@@ -220,7 +219,7 @@ public class ManageApplications extends InstrumentedFragment
|
||||
@VisibleForTesting
|
||||
FilterSpinnerAdapter mFilterAdapter;
|
||||
@VisibleForTesting
|
||||
View mContentContainer;
|
||||
RecyclerView mRecyclerView;
|
||||
|
||||
private View mRootView;
|
||||
private Spinner mFilterSpinner;
|
||||
@@ -330,7 +329,6 @@ public class ManageApplications extends InstrumentedFragment
|
||||
Bundle savedInstanceState) {
|
||||
mRootView = inflater.inflate(R.layout.manage_applications_apps, null);
|
||||
mLoadingContainer = mRootView.findViewById(R.id.loading_container);
|
||||
mContentContainer = mRootView.findViewById(R.id.content_container);
|
||||
mListContainer = mRootView.findViewById(R.id.list_container);
|
||||
if (mListContainer != null) {
|
||||
// Create adapter and list view here
|
||||
@@ -861,14 +859,14 @@ public class ManageApplications extends InstrumentedFragment
|
||||
// overlapped by floating filter.
|
||||
if (hasFilter) {
|
||||
mManageApplications.mSpinnerHeader.setVisibility(View.VISIBLE);
|
||||
mManageApplications.mContentContainer.setPadding(0 /* left */,
|
||||
mManageApplications.mRecyclerView.setPadding(0 /* left */,
|
||||
mContext.getResources().getDimensionPixelSize(
|
||||
R.dimen.app_bar_height) /* top */,
|
||||
0 /* right */,
|
||||
0 /* bottom */);
|
||||
} else {
|
||||
mManageApplications.mSpinnerHeader.setVisibility(View.GONE);
|
||||
mManageApplications.mContentContainer.setPadding(0 /* left */, 0 /* top */,
|
||||
mManageApplications.mRecyclerView.setPadding(0 /* left */, 0 /* top */,
|
||||
0 /* right */,
|
||||
0 /* bottom */);
|
||||
}
|
||||
|
@@ -466,27 +466,27 @@ public class ManageApplicationsTest {
|
||||
|
||||
@Test
|
||||
public void updateFilterView_hasFilterSet_shouldShowFilterAndHavePaddingTop() {
|
||||
mFragment.mContentContainer = new View(mContext);
|
||||
mFragment.mRecyclerView = new RecyclerView(mContext);
|
||||
mFragment.mSpinnerHeader = new View(mContext);
|
||||
mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment);
|
||||
|
||||
mFragment.mFilterAdapter.updateFilterView(true);
|
||||
|
||||
assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(mFragment.mContentContainer.getPaddingTop()).isEqualTo(
|
||||
assertThat(mFragment.mRecyclerView.getPaddingTop()).isEqualTo(
|
||||
mContext.getResources().getDimensionPixelSize(R.dimen.app_bar_height));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateFilterView_noFilterSet_shouldHideFilterAndNoPaddingTop() {
|
||||
mFragment.mContentContainer = new View(mContext);
|
||||
mFragment.mRecyclerView = new RecyclerView(mContext);
|
||||
mFragment.mSpinnerHeader = new View(mContext);
|
||||
mFragment.mFilterAdapter = new ManageApplications.FilterSpinnerAdapter(mFragment);
|
||||
|
||||
mFragment.mFilterAdapter.updateFilterView(false);
|
||||
|
||||
assertThat(mFragment.mSpinnerHeader.getVisibility()).isEqualTo(View.GONE);
|
||||
assertThat(mFragment.mContentContainer.getPaddingTop()).isEqualTo(0);
|
||||
assertThat(mFragment.mRecyclerView.getPaddingTop()).isEqualTo(0);
|
||||
}
|
||||
|
||||
private void setUpOptionMenus() {
|
||||
|
Reference in New Issue
Block a user