Search in sources :

Example 61 with Callbacks

use of com.android.launcher3.model.BgDataModel.Callbacks in project android_packages_apps_Launcher3 by ArrowOS.

the class FallbackActivityInterface method getParallelAnimationToLauncher.

@Override
@Nullable
public Animator getParallelAnimationToLauncher(GestureEndTarget endTarget, long duration, RecentsAnimationCallbacks callbacks) {
    FallbackTaskbarUIController uiController = getTaskbarController();
    Animator superAnimator = super.getParallelAnimationToLauncher(endTarget, duration, callbacks);
    if (uiController == null) {
        return superAnimator;
    }
    RecentsState toState = stateFromGestureEndTarget(endTarget);
    Animator taskbarAnimator = uiController.createAnimToRecentsState(toState, duration);
    if (taskbarAnimator == null) {
        return superAnimator;
    }
    if (superAnimator == null) {
        return taskbarAnimator;
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(superAnimator, taskbarAnimator);
    return animatorSet;
}
Also used : Animator(android.animation.Animator) FallbackTaskbarUIController(com.android.launcher3.taskbar.FallbackTaskbarUIController) RecentsState(com.android.quickstep.fallback.RecentsState) AnimatorSet(android.animation.AnimatorSet) Nullable(androidx.annotation.Nullable)

Example 62 with Callbacks

use of com.android.launcher3.model.BgDataModel.Callbacks in project android_packages_apps_Launcher3 by ArrowOS.

the class LauncherModelHelper method loadModelSync.

/**
 * Loads the model in memory synchronously
 */
public void loadModelSync() throws ExecutionException, InterruptedException {
    Callbacks mockCb = new Callbacks() {
    };
    Executors.MAIN_EXECUTOR.submit(() -> getModel().addCallbacksAndLoad(mockCb)).get();
    Executors.MODEL_EXECUTOR.submit(() -> {
    }).get();
    Executors.MAIN_EXECUTOR.submit(() -> {
    }).get();
    Executors.MAIN_EXECUTOR.submit(() -> getModel().removeCallbacks(mockCb)).get();
}
Also used : Callbacks(com.android.launcher3.model.BgDataModel.Callbacks)

Example 63 with Callbacks

use of com.android.launcher3.model.BgDataModel.Callbacks in project android_packages_apps_Launcher3 by ArrowOS.

the class LauncherModelHelper method executeTaskForTest.

/**
 * Synchronously executes the task and returns all the UI callbacks posted.
 */
public List<Runnable> executeTaskForTest(ModelUpdateTask task) throws Exception {
    LauncherModel model = getModel();
    if (!model.isModelLoaded()) {
        ReflectionHelpers.setField(model, "mModelLoaded", true);
    }
    Executor mockExecutor = mock(Executor.class);
    model.enqueueModelUpdateTask(new ModelUpdateTask() {

        @Override
        public void init(LauncherAppState app, LauncherModel model, BgDataModel dataModel, AllAppsList allAppsList, Executor uiExecutor) {
            task.init(app, model, dataModel, allAppsList, mockExecutor);
        }

        @Override
        public void run() {
            task.run();
        }
    });
    MODEL_EXECUTOR.submit(() -> null).get();
    ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class);
    verify(mockExecutor, atLeast(0)).execute(captor.capture());
    return captor.getAllValues();
}
Also used : LauncherModel(com.android.launcher3.LauncherModel) ModelUpdateTask(com.android.launcher3.LauncherModel.ModelUpdateTask) Executor(java.util.concurrent.Executor) LauncherAppState(com.android.launcher3.LauncherAppState) BgDataModel(com.android.launcher3.model.BgDataModel) AllAppsList(com.android.launcher3.model.AllAppsList)

Example 64 with Callbacks

use of com.android.launcher3.model.BgDataModel.Callbacks in project android_packages_apps_Launcher3 by ProtonAOSP.

the class BaseActivityInterface method getParallelAnimationToLauncher.

/**
 * Called when the gesture ends and the animation starts towards the given target. Used to add
 * an optional additional animation with the same duration.
 */
@Nullable
public Animator getParallelAnimationToLauncher(GestureState.GestureEndTarget endTarget, long duration, RecentsAnimationCallbacks callbacks) {
    if (endTarget == RECENTS) {
        ACTIVITY_TYPE activity = getCreatedActivity();
        if (activity == null) {
            return null;
        }
        STATE_TYPE state = stateFromGestureEndTarget(endTarget);
        ScrimView scrimView = activity.getScrimView();
        ObjectAnimator anim = ObjectAnimator.ofArgb(scrimView, VIEW_BACKGROUND_COLOR, getOverviewScrimColorForState(activity, state));
        anim.setDuration(duration);
        return anim;
    }
    return null;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ScrimView(com.android.launcher3.views.ScrimView) Nullable(androidx.annotation.Nullable)

Example 65 with Callbacks

use of com.android.launcher3.model.BgDataModel.Callbacks in project android_packages_apps_Launcher3 by ProtonAOSP.

the class FallbackActivityInterface method getParallelAnimationToLauncher.

@Override
@Nullable
public Animator getParallelAnimationToLauncher(GestureEndTarget endTarget, long duration, RecentsAnimationCallbacks callbacks) {
    FallbackTaskbarUIController uiController = getTaskbarController();
    Animator superAnimator = super.getParallelAnimationToLauncher(endTarget, duration, callbacks);
    if (uiController == null) {
        return superAnimator;
    }
    RecentsState toState = stateFromGestureEndTarget(endTarget);
    Animator taskbarAnimator = uiController.createAnimToRecentsState(toState, duration);
    if (taskbarAnimator == null) {
        return superAnimator;
    }
    if (superAnimator == null) {
        return taskbarAnimator;
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(superAnimator, taskbarAnimator);
    return animatorSet;
}
Also used : Animator(android.animation.Animator) FallbackTaskbarUIController(com.android.launcher3.taskbar.FallbackTaskbarUIController) RecentsState(com.android.quickstep.fallback.RecentsState) AnimatorSet(android.animation.AnimatorSet) Nullable(androidx.annotation.Nullable)

Aggregations

Callbacks (com.android.launcher3.model.BgDataModel.Callbacks)39 ArrayList (java.util.ArrayList)22 IntArray (com.android.launcher3.util.IntArray)21 ItemInfo (com.android.launcher3.model.data.ItemInfo)18 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)18 Nullable (androidx.annotation.Nullable)16 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)13 AppInfo (com.android.launcher3.model.data.AppInfo)11 CallbackTask (com.android.launcher3.LauncherModel.CallbackTask)9 Animator (android.animation.Animator)8 AnimatorSet (android.animation.AnimatorSet)8 Intent (android.content.Intent)7 ApplicationInfo (android.content.pm.ApplicationInfo)7 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)7 SessionInfo (android.content.pm.PackageInstaller.SessionInfo)7 PackageManager (android.content.pm.PackageManager)7 Rect (android.graphics.Rect)7 LauncherAppState (com.android.launcher3.LauncherAppState)7 LauncherModel (com.android.launcher3.LauncherModel)7 LoaderResults (com.android.launcher3.model.LoaderResults)7