Search in sources :

Example 1 with LoaderResults

use of com.android.launcher3.model.LoaderResults in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherModel method startLoader.

/**
 * Starts the loader. Tries to bind {@params synchronousBindPage} synchronously if possible.
 * @return true if the page could be bound synchronously.
 */
public boolean startLoader() {
    // Enable queue before starting loader. It will get disabled in Launcher#finishBindingItems
    ItemInstallQueue.INSTANCE.get(mApp.getContext()).pauseModelPush(ItemInstallQueue.FLAG_LOADER_RUNNING);
    synchronized (mLock) {
        // Don't bother to start the thread if we know it's not going to do anything
        final Callbacks[] callbacksList = getCallbacks();
        if (callbacksList.length > 0) {
            // Clear any pending bind-runnables from the synchronized load process.
            for (Callbacks cb : callbacksList) {
                MAIN_EXECUTOR.execute(cb::clearPendingBinds);
            }
            // If there is already one running, tell it to stop.
            stopLoader();
            LoaderResults loaderResults = new LoaderResults(mApp, mBgDataModel, mBgAllAppsList, callbacksList);
            if (mModelLoaded && !mIsLoaderTaskRunning) {
                // Divide the set of loaded items into those that we are binding synchronously,
                // and everything else that is to be bound normally (asynchronously).
                loaderResults.bindWorkspace();
                // For now, continue posting the binding of AllApps as there are other
                // issues that arise from that.
                loaderResults.bindAllApps();
                loaderResults.bindDeepShortcuts();
                loaderResults.bindWidgets();
                return true;
            } else {
                stopLoader();
                mLoaderTask = new LoaderTask(mApp, mBgAllAppsList, mBgDataModel, mModelDelegate, loaderResults);
                // Always post the loader task, instead of running directly
                // (even on same thread) so that we exit any nested synchronized blocks
                MODEL_EXECUTOR.post(mLoaderTask);
            }
        }
    }
    return false;
}
Also used : Callbacks(com.android.launcher3.model.BgDataModel.Callbacks) LoaderTask(com.android.launcher3.model.LoaderTask) LoaderResults(com.android.launcher3.model.LoaderResults)

Example 2 with LoaderResults

use of com.android.launcher3.model.LoaderResults in project android_packages_apps_Trebuchet by LineageOS.

the class LauncherModel method startLoaderForResults.

public void startLoaderForResults(LoaderResults results) {
    synchronized (mLock) {
        stopLoader();
        mLoaderTask = new LoaderTask(mApp, mBgAllAppsList, mBgDataModel, results);
        // Always post the loader task, instead of running directly (even on same thread) so
        // that we exit any nested synchronized blocks
        MODEL_EXECUTOR.post(mLoaderTask);
    }
}
Also used : LoaderTask(com.android.launcher3.model.LoaderTask)

Example 3 with LoaderResults

use of com.android.launcher3.model.LoaderResults in project android_packages_apps_Trebuchet by LineageOS.

the class LauncherModel method startLoader.

/**
 * Starts the loader. Tries to bind {@params synchronousBindPage} synchronously if possible.
 * @return true if the page could be bound synchronously.
 */
public boolean startLoader() {
    // Enable queue before starting loader. It will get disabled in Launcher#finishBindingItems
    InstallShortcutReceiver.enableInstallQueue(InstallShortcutReceiver.FLAG_LOADER_RUNNING);
    synchronized (mLock) {
        // Don't bother to start the thread if we know it's not going to do anything
        final Callbacks[] callbacksList = getCallbacks();
        if (callbacksList.length > 0) {
            // Clear any pending bind-runnables from the synchronized load process.
            for (Callbacks cb : callbacksList) {
                mMainExecutor.execute(cb::clearPendingBinds);
            }
            // If there is already one running, tell it to stop.
            stopLoader();
            LoaderResults loaderResults = new LoaderResults(mApp, mBgDataModel, mBgAllAppsList, callbacksList, mMainExecutor);
            if (mModelLoaded && !mIsLoaderTaskRunning) {
                // Divide the set of loaded items into those that we are binding synchronously,
                // and everything else that is to be bound normally (asynchronously).
                loaderResults.bindWorkspace();
                // For now, continue posting the binding of AllApps as there are other
                // issues that arise from that.
                loaderResults.bindAllApps();
                loaderResults.bindDeepShortcuts();
                loaderResults.bindWidgets();
                return true;
            } else {
                startLoaderForResults(loaderResults);
            }
        }
    }
    return false;
}
Also used : Callbacks(com.android.launcher3.model.BgDataModel.Callbacks) LoaderResults(com.android.launcher3.model.LoaderResults)

Example 4 with LoaderResults

use of com.android.launcher3.model.LoaderResults in project Neo-Launcher by NeoApplications.

the class LauncherModel method startLoaderForResults.

public void startLoaderForResults(LoaderResults results) {
    synchronized (mLock) {
        stopLoader();
        mLoaderTask = new LoaderTask(mApp, mBgAllAppsList, sBgDataModel, results);
        // Always post the loader task, instead of running directly (even on same thread) so
        // that we exit any nested synchronized blocks
        MODEL_EXECUTOR.post(mLoaderTask);
    }
}
Also used : LoaderTask(com.android.launcher3.model.LoaderTask)

Example 5 with LoaderResults

use of com.android.launcher3.model.LoaderResults in project Neo-Launcher by NeoApplications.

the class LauncherModel method startLoader.

/**
 * Starts the loader. Tries to bind {@params synchronousBindPage} synchronously if possible.
 * @return true if the page could be bound synchronously.
 */
public boolean startLoader(int synchronousBindPage) {
    // Enable queue before starting loader. It will get disabled in Launcher#finishBindingItems
    InstallShortcutReceiver.enableInstallQueue(InstallShortcutReceiver.FLAG_LOADER_RUNNING);
    synchronized (mLock) {
        // Don't bother to start the thread if we know it's not going to do anything
        if (mCallbacks != null && mCallbacks.get() != null) {
            final Callbacks oldCallbacks = mCallbacks.get();
            // Clear any pending bind-runnables from the synchronized load process.
            MAIN_EXECUTOR.execute(oldCallbacks::clearPendingBinds);
            // If there is already one running, tell it to stop.
            stopLoader();
            LoaderResults loaderResults = new LoaderResults(mApp, sBgDataModel, mBgAllAppsList, synchronousBindPage, mCallbacks);
            if (mModelLoaded && !mIsLoaderTaskRunning) {
                // Divide the set of loaded items into those that we are binding synchronously,
                // and everything else that is to be bound normally (asynchronously).
                loaderResults.bindWorkspace();
                // For now, continue posting the binding of AllApps as there are other
                // issues that arise from that.
                loaderResults.bindAllApps();
                loaderResults.bindDeepShortcuts();
                loaderResults.bindWidgets();
                Log.d(TAG, "Reloading apps...");
                return true;
            } else {
                startLoaderForResults(loaderResults);
            }
        }
    }
    return false;
}
Also used : Callbacks(com.android.launcher3.model.BgDataModel.Callbacks) LoaderResults(com.android.launcher3.model.LoaderResults)

Aggregations

Callbacks (com.android.launcher3.model.BgDataModel.Callbacks)7 LoaderResults (com.android.launcher3.model.LoaderResults)7 LoaderTask (com.android.launcher3.model.LoaderTask)7