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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.ntp; 5 package org.chromium.chrome.browser.ntp;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.res.Configuration; 9 import android.content.res.Configuration;
10 import android.content.res.Resources; 10 import android.content.res.Resources;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 * invalidated (has destroy() called) when the NewTabPage is destroyed s o use this method 293 * invalidated (has destroy() called) when the NewTabPage is destroyed s o use this method
294 * instead of keeping your own reference. 294 * instead of keeping your own reference.
295 */ 295 */
296 @Nullable SuggestionsSource getSuggestionsSource(); 296 @Nullable SuggestionsSource getSuggestionsSource();
297 297
298 /** 298 /**
299 * Registers a {@link SignInStateObserver}, will handle the de-registrat ion when the New Tab 299 * Registers a {@link SignInStateObserver}, will handle the de-registrat ion when the New Tab
300 * Page goes away. 300 * Page goes away.
301 */ 301 */
302 void registerSignInStateObserver(SignInStateObserver signInStateObserver ); 302 void registerSignInStateObserver(SignInStateObserver signInStateObserver );
303
304 /**
305 * @return whether the {@link NewTabPage} associated with this manager i s the current page
306 * displayed to the user.
307 */
308 boolean isCurrentPage();
303 } 309 }
304 310
305 /** 311 /**
306 * Default constructor required for XML inflation. 312 * Default constructor required for XML inflation.
307 */ 313 */
308 public NewTabPageView(Context context, AttributeSet attrs) { 314 public NewTabPageView(Context context, AttributeSet attrs) {
309 super(context, attrs); 315 super(context, attrs);
310 } 316 }
311 317
312 /** 318 /**
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 public void onClick(View v) { 490 public void onClick(View v) {
485 mManager.navigateToBookmarks(); 491 mManager.navigateToBookmarks();
486 } 492 }
487 }); 493 });
488 } 494 }
489 } 495 }
490 496
491 private void updateSearchBoxOnScroll() { 497 private void updateSearchBoxOnScroll() {
492 if (mDisableUrlFocusChangeAnimations) return; 498 if (mDisableUrlFocusChangeAnimations) return;
493 499
500 // When the page changes (tab switching or new page loading), it is poss ible that events
501 // (e.g. delayed RecyclerView change notifications) trigger calls to the se methods after
502 // the current page changes. We check it again to make sure we don't att empt to update the
503 // wrong page.
504 if (!mManager.isCurrentPage()) return;
505
494 if (mSearchBoxScrollListener != null) { 506 if (mSearchBoxScrollListener != null) {
495 mSearchBoxScrollListener.onNtpScrollChanged(getToolbarTransitionPerc entage()); 507 mSearchBoxScrollListener.onNtpScrollChanged(getToolbarTransitionPerc entage());
496 } 508 }
497 } 509 }
498 510
499 /** 511 /**
500 * Calculates the percentage (between 0 and 1) of the transition from the se arch box to the 512 * Calculates the percentage (between 0 and 1) of the transition from the se arch box to the
501 * omnibox at the top of the New Tab Page, which is determined by the amount of scrolling and 513 * omnibox at the top of the New Tab Page, which is determined by the amount of scrolling and
502 * the position of the search box. 514 * the position of the search box.
503 * 515 *
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 } 1230 }
1219 1231
1220 /** 1232 /**
1221 * @return The adapter position the user has scrolled to. 1233 * @return The adapter position the user has scrolled to.
1222 */ 1234 */
1223 public int getScrollPosition() { 1235 public int getScrollPosition() {
1224 if (mUseCardsUi) return mRecyclerView.getScrollPosition(); 1236 if (mUseCardsUi) return mRecyclerView.getScrollPosition();
1225 return RecyclerView.NO_POSITION; 1237 return RecyclerView.NO_POSITION;
1226 } 1238 }
1227 } 1239 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698