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

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

Issue 2396523002: Unify NewTabPageItem and ItemGroup into a single tree-structured interface. (Closed)
Patch Set: review 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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.cards; 5 package org.chromium.chrome.browser.ntp.cards;
6 6
7 import android.support.annotation.CallSuper; 7 import android.support.annotation.CallSuper;
8 import android.support.annotation.DrawableRes; 8 import android.support.annotation.DrawableRes;
9 import android.support.v4.view.animation.FastOutSlowInInterpolator; 9 import android.support.v4.view.animation.FastOutSlowInInterpolator;
10 import android.support.v7.widget.RecyclerView; 10 import android.support.v7.widget.RecyclerView;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 for (int i = 0; i < itemViewChildCount; ++i) { 226 for (int i = 0; i < itemViewChildCount; ++i) {
227 View snippetChild = ((ViewGroup) itemView).getChildAt(i); 227 View snippetChild = ((ViewGroup) itemView).getChildAt(i);
228 snippetChild.setAlpha(peekPadding / (float) mMaxPeekPadding); 228 snippetChild.setAlpha(peekPadding / (float) mMaxPeekPadding);
229 } 229 }
230 } 230 }
231 231
232 private static View inflateView(int resourceId, ViewGroup parent) { 232 private static View inflateView(int resourceId, ViewGroup parent) {
233 return LayoutInflater.from(parent.getContext()).inflate(resourceId, pare nt, false); 233 return LayoutInflater.from(parent.getContext()).inflate(resourceId, pare nt, false);
234 } 234 }
235 235
236 public static boolean isCard(@NewTabPageItem.ViewType int type) { 236 public static boolean isCard(@ItemViewType int type) {
237 switch (type) { 237 switch (type) {
238 case NewTabPageItem.VIEW_TYPE_SNIPPET: 238 case ItemViewType.SNIPPET:
239 case NewTabPageItem.VIEW_TYPE_STATUS: 239 case ItemViewType.STATUS:
240 case NewTabPageItem.VIEW_TYPE_ACTION: 240 case ItemViewType.ACTION:
241 case NewTabPageItem.VIEW_TYPE_PROMO: 241 case ItemViewType.PROMO:
242 return true; 242 return true;
243 case NewTabPageItem.VIEW_TYPE_ABOVE_THE_FOLD: 243 case ItemViewType.ABOVE_THE_FOLD:
244 case NewTabPageItem.VIEW_TYPE_HEADER: 244 case ItemViewType.HEADER:
245 case NewTabPageItem.VIEW_TYPE_SPACING: 245 case ItemViewType.SPACING:
246 case NewTabPageItem.VIEW_TYPE_PROGRESS: 246 case ItemViewType.PROGRESS:
247 case NewTabPageItem.VIEW_TYPE_FOOTER: 247 case ItemViewType.FOOTER:
248 case NewTabPageItem.VIEW_TYPE_ALL_DISMISSED: 248 case ItemViewType.ALL_DISMISSED:
249 return false; 249 return false;
250 default: 250 default:
251 assert false; 251 assert false;
252 } 252 }
253 return false; 253 return false;
254 } 254 }
255 255
256 @DrawableRes 256 @DrawableRes
257 protected int selectBackground(boolean hasCardAbove, boolean hasCardBelow) { 257 protected int selectBackground(boolean hasCardAbove, boolean hasCardBelow) {
258 if (hasCardAbove && hasCardBelow) return R.drawable.ntp_card_middle; 258 if (hasCardAbove && hasCardBelow) return R.drawable.ntp_card_middle;
259 if (!hasCardAbove && hasCardBelow) return R.drawable.ntp_card_top; 259 if (!hasCardAbove && hasCardBelow) return R.drawable.ntp_card_top;
260 if (hasCardAbove && !hasCardBelow) return R.drawable.ntp_card_bottom; 260 if (hasCardAbove && !hasCardBelow) return R.drawable.ntp_card_bottom;
261 return R.drawable.ntp_card_single; 261 return R.drawable.ntp_card_single;
262 } 262 }
263 263
264 protected NewTabPageRecyclerView getRecyclerView() { 264 protected NewTabPageRecyclerView getRecyclerView() {
265 return mRecyclerView; 265 return mRecyclerView;
266 } 266 }
267 } 267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698