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

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

Issue 2203823002: Handle the search box being detached from the NewTabPageView when calculating its offset. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 int searchBoxX = (int) mSearchBoxView.getX(); 717 int searchBoxX = (int) mSearchBoxView.getX();
718 int searchBoxY = (int) mSearchBoxView.getY(); 718 int searchBoxY = (int) mSearchBoxView.getY();
719 719
720 bounds.set(searchBoxX + mSearchBoxView.getPaddingLeft(), 720 bounds.set(searchBoxX + mSearchBoxView.getPaddingLeft(),
721 searchBoxY + mSearchBoxView.getPaddingTop(), 721 searchBoxY + mSearchBoxView.getPaddingTop(),
722 searchBoxX + mSearchBoxView.getWidth() - mSearchBoxView.getPaddi ngRight(), 722 searchBoxX + mSearchBoxView.getWidth() - mSearchBoxView.getPaddi ngRight(),
723 searchBoxY + mSearchBoxView.getHeight() - mSearchBoxView.getPadd ingBottom()); 723 searchBoxY + mSearchBoxView.getHeight() - mSearchBoxView.getPadd ingBottom());
724 724
725 translation.set(0, 0); 725 translation.set(0, 0);
726 726
727 View view = (View) mSearchBoxView.getParent(); 727 View view = mSearchBoxView;
728 while (view != null) { 728 while (true) {
729 view = (View) view.getParent();
730 if (view == null) {
731 // The |mSearchBoxView| is not a child of this view. This can ha ppen if the
732 // RecyclerView detaches the NewTabPageLayout after it has been scrolled out of
733 // view. Set the translation to the minimum Y value as an approx imation.
734 translation.y = Integer.MIN_VALUE;
735 break;
736 }
729 translation.offset(-view.getScrollX(), -view.getScrollY()); 737 translation.offset(-view.getScrollX(), -view.getScrollY());
730 if (view == this) break; 738 if (view == this) break;
731 translation.offset((int) view.getX(), (int) view.getY()); 739 translation.offset((int) view.getX(), (int) view.getY());
732 view = (View) view.getParent();
733 } 740 }
734 bounds.offset(translation.x, translation.y); 741 bounds.offset(translation.x, translation.y);
735 } 742 }
736 743
737 /** 744 /**
738 * Sets the listener for search box scroll changes. 745 * Sets the listener for search box scroll changes.
739 * @param listener The listener to be notified on changes. 746 * @param listener The listener to be notified on changes.
740 */ 747 */
741 void setSearchBoxScrollListener(OnSearchBoxScrollListener listener) { 748 void setSearchBoxScrollListener(OnSearchBoxScrollListener listener) {
742 mSearchBoxScrollListener = listener; 749 mSearchBoxScrollListener = listener;
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 } 1124 }
1118 1125
1119 private int getVerticalScroll() { 1126 private int getVerticalScroll() {
1120 if (mUseCardsUi) { 1127 if (mUseCardsUi) {
1121 return mRecyclerView.computeVerticalScrollOffset(); 1128 return mRecyclerView.computeVerticalScrollOffset();
1122 } else { 1129 } else {
1123 return mScrollView.getScrollY(); 1130 return mScrollView.getScrollY();
1124 } 1131 }
1125 } 1132 }
1126 } 1133 }
OLDNEW
« 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