Loading src/com/android/launcher3/Launcher.java +24 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.Executor; /** * Default launcher application. Loading Loading @@ -1855,6 +1856,8 @@ public class Launcher extends BaseActivity LauncherAnimUtils.onDestroyActivity(); clearPendingBinds(); if (mLauncherCallbacks != null) { mLauncherCallbacks.onDestroy(); } Loading Loading @@ -3705,6 +3708,13 @@ public class Launcher extends BaseActivity } if (mAppsView != null) { Executor pendingExecutor = getPendingExecutor(); if (pendingExecutor != null && mState != State.APPS) { // Wait until the fade in animation has finished before setting all apps list. mTmpAppsList = apps; pendingExecutor.execute(mBindAllApplicationsRunnable); return; } mAppsView.setApps(apps); } if (mLauncherCallbacks != null) { Loading @@ -3712,6 +3722,14 @@ public class Launcher extends BaseActivity } } /** * Returns an Executor that will run after the launcher is first drawn (including after the * initial fade in animation). Returns null if the first draw has already occurred. */ public @Nullable Executor getPendingExecutor() { return mPendingExecutor != null && mPendingExecutor.canQueue() ? mPendingExecutor : null; } /** * Copies LauncherModel's map of activities to shortcut ids to Launcher's. This is necessary * because LauncherModel's map is updated in the background, while Launcher runs on the UI. Loading Loading @@ -3904,6 +3922,12 @@ public class Launcher extends BaseActivity } if (mWidgetsView != null && allWidgets != null) { Executor pendingExecutor = getPendingExecutor(); if (pendingExecutor != null && mState != State.WIDGETS) { mAllWidgets = allWidgets; pendingExecutor.execute(mBindAllWidgetsRunnable); return; } mWidgetsView.setWidgets(allWidgets); mAllWidgets = null; } Loading src/com/android/launcher3/LauncherModel.java +4 −0 Original line number Diff line number Diff line Loading @@ -689,4 +689,8 @@ public class LauncherModel extends BroadcastReceiver public static Looper getWorkerLooper() { return sWorkerThread.getLooper(); } public static void setWorkerPriority(final int priority) { Process.setThreadPriority(sWorkerThread.getThreadId(), priority); } } src/com/android/launcher3/util/ViewOnDrawExecutor.java +14 −0 Original line number Diff line number Diff line Loading @@ -16,11 +16,13 @@ package com.android.launcher3.util; import android.os.Process; import android.view.View; import android.view.View.OnAttachStateChangeListener; import android.view.ViewTreeObserver.OnDrawListener; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherModel; import java.util.ArrayList; import java.util.concurrent.Executor; Loading @@ -37,6 +39,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, private Launcher mLauncher; private View mAttachedView; private boolean mCompleted; private boolean mIsExecuting; private boolean mLoadAnimationCompleted; private boolean mFirstDrawCompleted; Loading @@ -62,6 +65,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, @Override public void execute(Runnable command) { mTasks.add(command); LauncherModel.setWorkerPriority(Process.THREAD_PRIORITY_BACKGROUND); } @Override Loading @@ -78,6 +82,13 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, mAttachedView.post(this); } /** * Returns whether the executor is still queuing tasks and hasn't yet executed them. */ public boolean canQueue() { return !mIsExecuting && !mCompleted; } public void onLoadAnimationCompleted() { mLoadAnimationCompleted = true; if (mAttachedView != null) { Loading @@ -89,6 +100,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, public void run() { // Post the pending tasks after both onDraw and onLoadAnimationCompleted have been called. if (mLoadAnimationCompleted && mFirstDrawCompleted && !mCompleted) { mIsExecuting = true; for (final Runnable r : mTasks) { mExecutor.execute(r); } Loading @@ -99,6 +111,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, public void markCompleted() { mTasks.clear(); mCompleted = true; mIsExecuting = false; if (mAttachedView != null) { mAttachedView.getViewTreeObserver().removeOnDrawListener(this); mAttachedView.removeOnAttachStateChangeListener(this); Loading @@ -106,5 +119,6 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, if (mLauncher != null) { mLauncher.clearPendingExecutor(this); } LauncherModel.setWorkerPriority(Process.THREAD_PRIORITY_DEFAULT); } } Loading
src/com/android/launcher3/Launcher.java +24 −0 Original line number Diff line number Diff line Loading @@ -144,6 +144,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.Executor; /** * Default launcher application. Loading Loading @@ -1855,6 +1856,8 @@ public class Launcher extends BaseActivity LauncherAnimUtils.onDestroyActivity(); clearPendingBinds(); if (mLauncherCallbacks != null) { mLauncherCallbacks.onDestroy(); } Loading Loading @@ -3705,6 +3708,13 @@ public class Launcher extends BaseActivity } if (mAppsView != null) { Executor pendingExecutor = getPendingExecutor(); if (pendingExecutor != null && mState != State.APPS) { // Wait until the fade in animation has finished before setting all apps list. mTmpAppsList = apps; pendingExecutor.execute(mBindAllApplicationsRunnable); return; } mAppsView.setApps(apps); } if (mLauncherCallbacks != null) { Loading @@ -3712,6 +3722,14 @@ public class Launcher extends BaseActivity } } /** * Returns an Executor that will run after the launcher is first drawn (including after the * initial fade in animation). Returns null if the first draw has already occurred. */ public @Nullable Executor getPendingExecutor() { return mPendingExecutor != null && mPendingExecutor.canQueue() ? mPendingExecutor : null; } /** * Copies LauncherModel's map of activities to shortcut ids to Launcher's. This is necessary * because LauncherModel's map is updated in the background, while Launcher runs on the UI. Loading Loading @@ -3904,6 +3922,12 @@ public class Launcher extends BaseActivity } if (mWidgetsView != null && allWidgets != null) { Executor pendingExecutor = getPendingExecutor(); if (pendingExecutor != null && mState != State.WIDGETS) { mAllWidgets = allWidgets; pendingExecutor.execute(mBindAllWidgetsRunnable); return; } mWidgetsView.setWidgets(allWidgets); mAllWidgets = null; } Loading
src/com/android/launcher3/LauncherModel.java +4 −0 Original line number Diff line number Diff line Loading @@ -689,4 +689,8 @@ public class LauncherModel extends BroadcastReceiver public static Looper getWorkerLooper() { return sWorkerThread.getLooper(); } public static void setWorkerPriority(final int priority) { Process.setThreadPriority(sWorkerThread.getThreadId(), priority); } }
src/com/android/launcher3/util/ViewOnDrawExecutor.java +14 −0 Original line number Diff line number Diff line Loading @@ -16,11 +16,13 @@ package com.android.launcher3.util; import android.os.Process; import android.view.View; import android.view.View.OnAttachStateChangeListener; import android.view.ViewTreeObserver.OnDrawListener; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherModel; import java.util.ArrayList; import java.util.concurrent.Executor; Loading @@ -37,6 +39,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, private Launcher mLauncher; private View mAttachedView; private boolean mCompleted; private boolean mIsExecuting; private boolean mLoadAnimationCompleted; private boolean mFirstDrawCompleted; Loading @@ -62,6 +65,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, @Override public void execute(Runnable command) { mTasks.add(command); LauncherModel.setWorkerPriority(Process.THREAD_PRIORITY_BACKGROUND); } @Override Loading @@ -78,6 +82,13 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, mAttachedView.post(this); } /** * Returns whether the executor is still queuing tasks and hasn't yet executed them. */ public boolean canQueue() { return !mIsExecuting && !mCompleted; } public void onLoadAnimationCompleted() { mLoadAnimationCompleted = true; if (mAttachedView != null) { Loading @@ -89,6 +100,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, public void run() { // Post the pending tasks after both onDraw and onLoadAnimationCompleted have been called. if (mLoadAnimationCompleted && mFirstDrawCompleted && !mCompleted) { mIsExecuting = true; for (final Runnable r : mTasks) { mExecutor.execute(r); } Loading @@ -99,6 +111,7 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, public void markCompleted() { mTasks.clear(); mCompleted = true; mIsExecuting = false; if (mAttachedView != null) { mAttachedView.getViewTreeObserver().removeOnDrawListener(this); mAttachedView.removeOnAttachStateChangeListener(this); Loading @@ -106,5 +119,6 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable, if (mLauncher != null) { mLauncher.clearPendingExecutor(this); } LauncherModel.setWorkerPriority(Process.THREAD_PRIORITY_DEFAULT); } }