From b5b9ad68b707154fcc2c3b04b1b6c0b17127e415 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Sat, 2 Apr 2016 11:23:39 -0700 Subject: Fading in the first screen, when launcher loads for the first time Bug: 29007436 Bug: 27705838 Change-Id: I95891d0bad19a67985b689bb96d6068dcd85004a --- .../android/launcher3/util/ViewOnDrawExecutor.java | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/com/android/launcher3/util') 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); -- cgit v1.2.3