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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/suggestions/TileGridLayout.java

Issue 2754203004: 📰 Add tests for context menu usage (Closed)
Patch Set: y Created 3 years, 9 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.suggestions; 5 package org.chromium.chrome.browser.suggestions;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.res.Resources; 8 import android.content.res.Resources;
9 import android.text.TextUtils; 9 import android.text.TextUtils;
10 import android.util.AttributeSet; 10 import android.util.AttributeSet;
11 import android.view.View; 11 import android.view.View;
12 import android.widget.FrameLayout; 12 import android.widget.FrameLayout;
13 13
14 import org.chromium.base.ApiCompatibilityUtils; 14 import org.chromium.base.ApiCompatibilityUtils;
15 import org.chromium.base.VisibleForTesting;
15 import org.chromium.chrome.R; 16 import org.chromium.chrome.R;
16 import org.chromium.chrome.browser.util.MathUtils; 17 import org.chromium.chrome.browser.util.MathUtils;
17 18
18 /** 19 /**
19 * A layout that arranges tiles in a grid. 20 * A layout that arranges tiles in a grid.
20 */ 21 */
21 public class TileGridLayout extends FrameLayout { 22 public class TileGridLayout extends FrameLayout {
22 private final int mVerticalSpacing; 23 private final int mVerticalSpacing;
23 private final int mMinHorizontalSpacing; 24 private final int mMinHorizontalSpacing;
24 private final int mMaxHorizontalSpacing; 25 private final int mMaxHorizontalSpacing;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 getChildAt(i).setVisibility(View.GONE); 155 getChildAt(i).setVisibility(View.GONE);
155 } 156 }
156 157
157 int totalHeight = paddingTop + getPaddingBottom() + numRows * childHeigh t 158 int totalHeight = paddingTop + getPaddingBottom() + numRows * childHeigh t
158 + (numRows - 1) * mVerticalSpacing + mExtraVerticalSpacing; 159 + (numRows - 1) * mVerticalSpacing + mExtraVerticalSpacing;
159 160
160 setMeasuredDimension(totalWidth, resolveSize(totalHeight, heightMeasureS pec)); 161 setMeasuredDimension(totalWidth, resolveSize(totalHeight, heightMeasureS pec));
161 } 162 }
162 163
163 /** @return A tile view associated to the provided URL, or {@code null} if n one is found. */ 164 /** @return A tile view associated to the provided URL, or {@code null} if n one is found. */
164 private TileView getTileView(String url) { 165 @VisibleForTesting
166 TileView getTileView(String url) {
165 int childCount = getChildCount(); 167 int childCount = getChildCount();
166 for (int i = 0; i < childCount; i++) { 168 for (int i = 0; i < childCount; i++) {
167 TileView tileView = (TileView) getChildAt(i); 169 TileView tileView = (TileView) getChildAt(i);
168 if (TextUtils.equals(url, tileView.getUrl())) return tileView; 170 if (TextUtils.equals(url, tileView.getUrl())) return tileView;
169 } 171 }
170 return null; 172 return null;
171 } 173 }
172 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698