Delay showing the loading progress spinner in Managed App.
In warm load, the app list is populated much faster, and we should not show the spinner if we can show the app list immediately. Adding 100ms delay in showing the loading container. If the app list is ready, show the list container directly without first showing the loading container. Change-Id: I8b3ea88d2382ece9226d5c7734fd1aa406160cf2 Fix: 36375109 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -346,7 +346,6 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
|
||||
mRootView = inflater.inflate(R.layout.manage_applications_apps, null);
|
||||
mLoadingContainer = mRootView.findViewById(R.id.loading_container);
|
||||
mLoadingContainer.setVisibility(View.VISIBLE);
|
||||
mListContainer = mRootView.findViewById(R.id.list_container);
|
||||
if (mListContainer != null) {
|
||||
// Create adapter and list view here
|
||||
@@ -395,7 +394,8 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
return mRootView;
|
||||
}
|
||||
|
||||
private void createHeader() {
|
||||
@VisibleForTesting
|
||||
void createHeader() {
|
||||
Activity activity = getActivity();
|
||||
FrameLayout pinnedHeader = (FrameLayout) mRootView.findViewById(R.id.pinned_header);
|
||||
mSpinnerHeader = activity.getLayoutInflater()
|
||||
@@ -834,6 +834,10 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
static class ApplicationsAdapter extends BaseAdapter implements Filterable,
|
||||
ApplicationsState.Callbacks, AppStateBaseBridge.Callback,
|
||||
AbsListView.RecyclerListener, SectionIndexer {
|
||||
|
||||
// how long to wait for app list to populate without showing the loading container
|
||||
private static final long DELAY_SHOW_LOADING_CONTAINER_THRESHOLD_MS = 100L;
|
||||
|
||||
private static final SectionInfo[] EMPTY_SECTIONS = new SectionInfo[0];
|
||||
|
||||
private final ApplicationsState mState;
|
||||
@@ -889,6 +893,13 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
}
|
||||
};
|
||||
|
||||
private Runnable mShowLoadingContainerRunnable = new Runnable() {
|
||||
public void run() {
|
||||
Utils.handleLoadingContainer(mManageApplications.mLoadingContainer,
|
||||
mManageApplications.mListContainer, false /* done */, false /* animate */);
|
||||
}
|
||||
};
|
||||
|
||||
public ApplicationsAdapter(ApplicationsState state, ManageApplications manageApplications,
|
||||
int filterMode) {
|
||||
mState = state;
|
||||
@@ -1097,6 +1108,9 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
|
||||
if (mSession.getAllApps().size() != 0
|
||||
&& mManageApplications.mListContainer.getVisibility() != View.VISIBLE) {
|
||||
// Cancel any pending task to show the loading animation and show the list of
|
||||
// apps directly.
|
||||
mFgHandler.removeCallbacks(mShowLoadingContainerRunnable);
|
||||
Utils.handleLoadingContainer(mManageApplications.mLoadingContainer,
|
||||
mManageApplications.mListContainer, true, true);
|
||||
}
|
||||
@@ -1148,10 +1162,16 @@ public class ManageApplications extends InstrumentedPreferenceFragment
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLoading() {
|
||||
Utils.handleLoadingContainer(mManageApplications.mLoadingContainer,
|
||||
mManageApplications.mListContainer,
|
||||
mHasReceivedLoadEntries && mSession.getAllApps().size() != 0, false);
|
||||
@VisibleForTesting
|
||||
void updateLoading() {
|
||||
final boolean appLoaded = mHasReceivedLoadEntries && mSession.getAllApps().size() != 0;
|
||||
if (appLoaded) {
|
||||
Utils.handleLoadingContainer(mManageApplications.mLoadingContainer,
|
||||
mManageApplications.mListContainer, true /* done */, false /* animate */);
|
||||
} else {
|
||||
mFgHandler.postDelayed(
|
||||
mShowLoadingContainerRunnable, DELAY_SHOW_LOADING_CONTAINER_THRESHOLD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<ApplicationsState.AppEntry> applyPrefixFilter(CharSequence prefix,
|
||||
|
Reference in New Issue
Block a user