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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java

Issue 2133753002: 🏠Delay the URL focus effects if they happen before NTP is loaded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use onLayoutChange Created 4 years, 5 months 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 | « chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java ('k') | 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/ntp/NewTabPageView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
index cb60db70713415b2311dda7a3a95b44de7c1db7c..426fcf5d998e873576e78dab923ea0e0adcb4550 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPageView.java
@@ -113,6 +113,8 @@
private float mUrlFocusChangePercent;
private boolean mDisableUrlFocusChangeAnimations;
+ /** Flag used to request some layout changes after the next layout pass is completed. */
+ private boolean mTileCountChanged;
private boolean mSnapshotMostVisitedChanged;
private int mSnapshotWidth;
private int mSnapshotHeight;
@@ -368,7 +370,7 @@ public void onClick(View v) {
params.bottomMargin = 0;
}
- addOnLayoutChangeListener(this);
+ mNewTabPageLayout.addOnLayoutChangeListener(this);
setSearchProviderHasLogo(searchProviderHasLogo);
mPendingLoadTasks++;
@@ -807,9 +809,11 @@ void captureThumbnail(Canvas canvas) {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
- int oldWidth = oldRight - oldLeft;
- int newWidth = right - left;
- if (oldWidth == newWidth) return;
+ int oldHeight = oldBottom - oldTop;
dgn 2016/07/08 23:45:36 Using height should achieve the same effect as wid
+ int newHeight = bottom - top;
+
+ if (oldHeight == newHeight && !mTileCountChanged) return;
+ mTileCountChanged = false;
// Re-apply the url focus change amount after a rotation to ensure the views are correctly
// placed with their new layout configurations.
@@ -892,6 +896,12 @@ private void onOfflineUrlsAvailable(final String[] titles, final String[] urls,
mHasReceivedMostVisitedSites = true;
updateMostVisitedPlaceholderVisibility();
+ if (mUrlFocusChangePercent == 1f && oldItemCount != mMostVisitedItems.length) {
+ // If the number of NTP Tile rows change while the URL bar is focused, the icons'
+ // position will be wrong. Schedule the translation to be updated.
+ mTileCountChanged = true;
+ }
+
if (isInitialLoad) {
loadTaskCompleted();
// The page contents are initially hidden; otherwise they'll be drawn centered on the
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698