summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/util/ViewOnDrawExecutor.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/util/ViewOnDrawExecutor.java')
-rw-r--r--src/com/android/launcher3/util/ViewOnDrawExecutor.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/com/android/launcher3/util/ViewOnDrawExecutor.java b/src/com/android/launcher3/util/ViewOnDrawExecutor.java
index 01808ba57..9bd288244 100644
--- a/src/com/android/launcher3/util/ViewOnDrawExecutor.java
+++ b/src/com/android/launcher3/util/ViewOnDrawExecutor.java
@@ -16,6 +16,7 @@
package com.android.launcher3.util;
+import android.util.Log;
import android.view.View;
import android.view.View.OnAttachStateChangeListener;
import android.view.ViewTreeObserver.OnDrawListener;
@@ -39,6 +40,9 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
private View mAttachedView;
private boolean mCompleted;
+ private boolean mLoadAnimationCompleted;
+ private boolean mFirstDrawCompleted;
+
public ViewOnDrawExecutor(DeferredHandler handler) {
mHandler = handler;
}
@@ -72,19 +76,31 @@ public class ViewOnDrawExecutor implements Executor, OnDrawListener, Runnable,
@Override
public void onDraw() {
+ mFirstDrawCompleted = true;
mAttachedView.post(this);
}
+ public void onLoadAnimationCompleted() {
+ mLoadAnimationCompleted = true;
+ if (mAttachedView != null) {
+ mAttachedView.post(this);
+ }
+ }
+
@Override
public void run() {
- for (final Runnable r : mTasks) {
- mHandler.post(r);
+ // Post the pending tasks after both onDraw and onLoadAnimationCompleted have been called.
+ if (mLoadAnimationCompleted && mFirstDrawCompleted && !mCompleted) {
+ for (final Runnable r : mTasks) {
+ mHandler.post(r);
+ }
+ markCompleted();
}
- markCompleted();
}
public void markCompleted() {
mTasks.clear();
+ mCompleted = true;
if (mAttachedView != null) {
mAttachedView.getViewTreeObserver().removeOnDrawListener(this);
mAttachedView.removeOnAttachStateChangeListener(this);