Search in sources :

Example 6 with HotseatPredictionController

use of com.android.launcher3.hybridhotseat.HotseatPredictionController in project android_packages_apps_Trebuchet by LineageOS.

the class HotseatPredictionController method fillGapsWithPrediction.

private void fillGapsWithPrediction(boolean animate, Runnable callback) {
    if (mUIUpdatePaused || mDragObject != null) {
        return;
    }
    List<WorkspaceItemInfo> predictedApps = mapToWorkspaceItemInfo(mComponentKeyMappers);
    if (mComponentKeyMappers.isEmpty() != predictedApps.isEmpty()) {
        // apps are ready (HotseatPredictionController#onAppsUpdated)
        return;
    }
    int predictionIndex = 0;
    ArrayList<WorkspaceItemInfo> newItems = new ArrayList<>();
    // make sure predicted icon removal and filling predictions don't step on each other
    if (mIconRemoveAnimators != null && mIconRemoveAnimators.isRunning()) {
        mIconRemoveAnimators.addListener(new AnimationSuccessListener() {

            @Override
            public void onAnimationSuccess(Animator animator) {
                fillGapsWithPrediction(animate, callback);
                mIconRemoveAnimators.removeListener(this);
            }
        });
        return;
    }
    for (int rank = 0; rank < mHotSeatItemsCount; rank++) {
        View child = mHotseat.getChildAt(mHotseat.getCellXFromOrder(rank), mHotseat.getCellYFromOrder(rank));
        if (child != null && !isPredictedIcon(child)) {
            continue;
        }
        if (predictedApps.size() <= predictionIndex) {
            // Remove predicted apps from the past
            if (isPredictedIcon(child)) {
                mHotseat.removeView(child);
            }
            continue;
        }
        WorkspaceItemInfo predictedItem = predictedApps.get(predictionIndex++);
        if (isPredictedIcon(child) && child.isEnabled()) {
            PredictedAppIcon icon = (PredictedAppIcon) child;
            icon.applyFromWorkspaceItem(predictedItem);
            icon.finishBinding(mPredictionLongClickListener);
        } else {
            newItems.add(predictedItem);
        }
        preparePredictionInfo(predictedItem, rank);
    }
    mPredictedSpotsCount = predictionIndex;
    bindItems(newItems, animate, callback);
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) ArrayList(java.util.ArrayList) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 7 with HotseatPredictionController

use of com.android.launcher3.hybridhotseat.HotseatPredictionController in project android_packages_apps_Trebuchet by LineageOS.

the class PredictedAppIcon method performAccessibilityAction.

@Override
public boolean performAccessibilityAction(int action, ItemInfo info) {
    QuickstepLauncher launcher = Launcher.cast(Launcher.getLauncher(getContext()));
    if (action == PIN_PREDICTION) {
        if (launcher == null || launcher.getHotseatPredictionController() == null) {
            return false;
        }
        HotseatPredictionController controller = launcher.getHotseatPredictionController();
        controller.pinPrediction(info);
        return true;
    }
    return false;
}
Also used : HotseatPredictionController(com.android.launcher3.hybridhotseat.HotseatPredictionController)

Example 8 with HotseatPredictionController

use of com.android.launcher3.hybridhotseat.HotseatPredictionController in project android_packages_apps_Launcher3 by AOSPA.

the class QuickstepLauncher method setupViews.

@Override
protected void setupViews() {
    super.setupViews();
    mHotseatPredictionController = new HotseatPredictionController(this);
}
Also used : HotseatPredictionController(com.android.launcher3.hybridhotseat.HotseatPredictionController)

Aggregations

HotseatPredictionController (com.android.launcher3.hybridhotseat.HotseatPredictionController)6 Animator (android.animation.Animator)2 ObjectAnimator (android.animation.ObjectAnimator)2 View (android.view.View)2 AnimationSuccessListener (com.android.launcher3.anim.AnimationSuccessListener)2 AnimatorSet (android.animation.AnimatorSet)1 AppPredictionContext (android.app.prediction.AppPredictionContext)1 AppPredictionManager (android.app.prediction.AppPredictionManager)1 AppPredictor (android.app.prediction.AppPredictor)1 AppTarget (android.app.prediction.AppTarget)1 AppTargetEvent (android.app.prediction.AppTargetEvent)1 ComponentName (android.content.ComponentName)1 Process (android.os.Process)1 Log (android.util.Log)1 HapticFeedbackConstants (android.view.HapticFeedbackConstants)1 ViewGroup (android.view.ViewGroup)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 DragSource (com.android.launcher3.DragSource)1 DropTarget (com.android.launcher3.DropTarget)1