[part 2] Update standalone picker to align widget loading and animations
In usual picker, widgets are already available before picker opens, so, the work that happens during animations doesn't interrupt animations on the scale it interrupt animations in standalone picker. Bug: 346341156 Flag: EXEMPT bugfix Test: Manual / see before after video Change-Id: I7c8701447bd519b306799b28341d8f2f03daf59f
This commit is contained in:
1 parent
e4ca191001
commit
558afdafe2
2 files changed
+30
-13
No files matched your search
@@ -65,6 +65,7 @@ public class WidgetPredictionsRequester {
|
||||
private final Context mContext;
|
||||
@NonNull
|
||||
private final String mUiSurface;
|
||||
private boolean mPredictionsAvailable;
|
||||
@NonNull
|
||||
private final Map<ComponentKey, WidgetItem> mAllWidgets;
|
||||
|
||||
@@ -76,8 +77,8 @@ public class WidgetPredictionsRequester {
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests predictions from the app predictions manager and registers the provided callback to
|
||||
* receive updates when predictions are available.
|
||||
* Requests one time predictions from the app predictions manager and invokes provided callback
|
||||
* once predictions are available.
|
||||
*
|
||||
* @param existingWidgets widgets that are currently added to the surface;
|
||||
* @param callback consumer of prediction results to be called when predictions are
|
||||
@@ -159,10 +160,14 @@ public class WidgetPredictionsRequester {
|
||||
@WorkerThread
|
||||
private void bindPredictions(List<AppTarget> targets, Predicate<WidgetItem> filter,
|
||||
Consumer<List<ItemInfo>> callback) {
|
||||
List<WidgetItem> filteredPredictions = filterPredictions(targets, mAllWidgets, filter);
|
||||
List<ItemInfo> mappedPredictions = mapWidgetItemsToItemInfo(filteredPredictions);
|
||||
if (!mPredictionsAvailable) {
|
||||
mPredictionsAvailable = true;
|
||||
List<WidgetItem> filteredPredictions = filterPredictions(targets, mAllWidgets, filter);
|
||||
List<ItemInfo> mappedPredictions = mapWidgetItemsToItemInfo(filteredPredictions);
|
||||
|
||||
MAIN_EXECUTOR.execute(() -> callback.accept(mappedPredictions));
|
||||
MAIN_EXECUTOR.execute(() -> callback.accept(mappedPredictions));
|
||||
MODEL_EXECUTOR.execute(this::clear);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,5 +219,6 @@ public class WidgetPredictionsRequester {
|
||||
mAppPredictor.destroy();
|
||||
mAppPredictor = null;
|
||||
}
|
||||
mPredictionsAvailable = false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user