Fix apps spinner jank.
Change-Id: I7fbe580627538037fd0f1823787f7dcebbb43252 Fixes: 29056706
This commit is contained in:
@@ -26,6 +26,7 @@ import android.content.pm.ResolveInfo;
|
|||||||
import android.icu.text.AlphabeticIndex;
|
import android.icu.text.AlphabeticIndex;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.os.Handler;
|
||||||
import android.os.LocaleList;
|
import android.os.LocaleList;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
@@ -745,6 +746,8 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final ArrayList<View> mActive = new ArrayList<View>();
|
private final ArrayList<View> mActive = new ArrayList<View>();
|
||||||
private final AppStateBaseBridge mExtraInfoBridge;
|
private final AppStateBaseBridge mExtraInfoBridge;
|
||||||
|
private final Handler mBgHandler;
|
||||||
|
private final Handler mFgHandler;
|
||||||
private int mFilterMode;
|
private int mFilterMode;
|
||||||
private ArrayList<ApplicationsState.AppEntry> mBaseEntries;
|
private ArrayList<ApplicationsState.AppEntry> mBaseEntries;
|
||||||
private ArrayList<ApplicationsState.AppEntry> mEntries;
|
private ArrayList<ApplicationsState.AppEntry> mEntries;
|
||||||
@@ -785,6 +788,8 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
public ApplicationsAdapter(ApplicationsState state, ManageApplications manageApplications,
|
public ApplicationsAdapter(ApplicationsState state, ManageApplications manageApplications,
|
||||||
int filterMode) {
|
int filterMode) {
|
||||||
mState = state;
|
mState = state;
|
||||||
|
mFgHandler = new Handler();
|
||||||
|
mBgHandler = new Handler(mState.getBackgroundLooper());
|
||||||
mSession = state.newSession(this);
|
mSession = state.newSession(this);
|
||||||
mManageApplications = manageApplications;
|
mManageApplications = manageApplications;
|
||||||
mContext = manageApplications.getActivity();
|
mContext = manageApplications.getActivity();
|
||||||
@@ -897,17 +902,14 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
comparatorObj = ApplicationsState.ALPHA_COMPARATOR;
|
comparatorObj = ApplicationsState.ALPHA_COMPARATOR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ArrayList<ApplicationsState.AppEntry> entries
|
AppFilter finalFilterObj = filterObj;
|
||||||
= mSession.rebuild(filterObj, comparatorObj);
|
mBgHandler.post(() -> {
|
||||||
if (entries == null && !eraseold) {
|
final ArrayList<AppEntry> entries = mSession.rebuild(finalFilterObj,
|
||||||
// Don't have new list yet, but can continue using the old one.
|
comparatorObj, false);
|
||||||
return;
|
if (entries != null) {
|
||||||
|
mFgHandler.post(() -> onRebuildComplete(entries));
|
||||||
}
|
}
|
||||||
if (mFilterMode == FILTER_APPS_POWER_WHITELIST ||
|
});
|
||||||
mFilterMode == FILTER_APPS_POWER_WHITELIST_ALL) {
|
|
||||||
entries = removeDuplicateIgnoringUser(entries);
|
|
||||||
}
|
|
||||||
onRebuildComplete(entries);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -945,6 +947,10 @@ public class ManageApplications extends InstrumentedFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRebuildComplete(ArrayList<AppEntry> entries) {
|
public void onRebuildComplete(ArrayList<AppEntry> entries) {
|
||||||
|
if (mFilterMode == FILTER_APPS_POWER_WHITELIST ||
|
||||||
|
mFilterMode == FILTER_APPS_POWER_WHITELIST_ALL) {
|
||||||
|
entries = removeDuplicateIgnoringUser(entries);
|
||||||
|
}
|
||||||
mBaseEntries = entries;
|
mBaseEntries = entries;
|
||||||
if (mBaseEntries != null) {
|
if (mBaseEntries != null) {
|
||||||
mEntries = applyPrefixFilter(mCurFilterPrefix, mBaseEntries);
|
mEntries = applyPrefixFilter(mCurFilterPrefix, mBaseEntries);
|
||||||
|
Reference in New Issue
Block a user