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

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

Issue 2400163002: Tentative fix for scroll event related crashes on the NTP (Closed)
Patch Set: address comment Created 4 years, 2 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
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 33cf29924015c9079503ea1637b8e3f1cc23f9d2..3f244fd119f6f155560c253a1cdcac3d8612c687 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
@@ -300,6 +300,12 @@ void ensureIconIsAvailable(String pageUrl, String iconUrl, boolean isLargeIcon,
* Page goes away.
*/
void registerSignInStateObserver(SignInStateObserver signInStateObserver);
+
+ /**
+ * @return whether the {@link NewTabPage} associated with this manager is the current page
+ * displayed to the user.
+ */
+ boolean isCurrentPage();
}
/**
@@ -491,6 +497,12 @@ public void onClick(View v) {
private void updateSearchBoxOnScroll() {
if (mDisableUrlFocusChangeAnimations) return;
+ // When the page changes (tab switching or new page loading), it is possible that events
+ // (e.g. delayed RecyclerView change notifications) trigger calls to these methods after
+ // the current page changes. We check it again to make sure we don't attempt to update the
+ // wrong page.
+ if (!mManager.isCurrentPage()) return;
+
if (mSearchBoxScrollListener != null) {
mSearchBoxScrollListener.onNtpScrollChanged(getToolbarTransitionPercentage());
}

Powered by Google App Engine
This is Rietveld 408576698