Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2084)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java

Issue 1389293003: Add 200MS delay before starting toolbar scale animation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert the change in base folder Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java
index 8230379bdb88071bdcf433e0d4009ce69bf9ee8a..a32944c32c01c0242e2db569918de3316ff269a8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/CustomTabToolbar.java
@@ -22,6 +22,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
+import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.WindowDelegate;
@@ -50,6 +51,8 @@ import org.chromium.ui.base.WindowAndroid;
*/
public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
View.OnLongClickListener {
+ private static final int TITLE_ANIM_DELAY_MS = 200;
+
private View mLocationBarFrameLayout;
private View mTitleUrlContainer;
private UrlBar mUrlBar;
@@ -65,6 +68,14 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
private CustomTabToolbarAnimationDelegate mAnimDelegate;
private boolean mBackgroundColorSet;
+ private long mInitializeTimeStamp;
+
+ private Runnable mTitleAnimationStarter = new Runnable() {
+ @Override
+ public void run() {
+ mAnimDelegate.startTitleAnimation(getContext());
+ }
+ };
/**
* Constructor for getting this class inflated from an xml layout file.
@@ -105,6 +116,7 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
ToolbarTabController tabController, AppMenuButtonHelper appMenuButtonHelper) {
super.initialize(toolbarDataProvider, tabController, appMenuButtonHelper);
updateVisualsForState();
+ mInitializeTimeStamp = System.currentTimeMillis();
}
@Override
@@ -203,7 +215,13 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
// It takes some time to parse the title of the webcontent, and before that Tab#getTitle
// always return the url. We postpone the title animation until the title is authentic.
if (mShouldShowTitle && !TextUtils.equals(currentTab.getTitle(), currentTab.getUrl())) {
- mAnimDelegate.startTitleAnimation(getContext());
+ long duration = System.currentTimeMillis() - mInitializeTimeStamp;
+ if (duration >= TITLE_ANIM_DELAY_MS) {
+ mTitleAnimationStarter.run();
+ } else {
+ ThreadUtils.postOnUiThreadDelayed(mTitleAnimationStarter,
+ TITLE_ANIM_DELAY_MS - duration);
+ }
}
mTitleBar.setText(currentTab.getTitle());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698