OLD | NEW |
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.content.Context; | 7 import android.content.Context; |
8 import android.support.annotation.DrawableRes; | 8 import android.support.annotation.DrawableRes; |
9 import android.support.annotation.Nullable; | 9 import android.support.annotation.Nullable; |
10 import android.support.annotation.StringRes; | 10 import android.support.annotation.StringRes; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } else { | 53 } else { |
54 mObserver = new SigninObserver(signinManager); | 54 mObserver = new SigninObserver(signinManager); |
55 uiDelegate.addDestructionObserver(mObserver); | 55 uiDelegate.addDestructionObserver(mObserver); |
56 } | 56 } |
57 | 57 |
58 setVisible(signinManager.isSignInAllowed() && !signinManager.isSignedInO
nNative()); | 58 setVisible(signinManager.isSignInAllowed() && !signinManager.isSignedInO
nNative()); |
59 } | 59 } |
60 | 60 |
61 @Override | 61 @Override |
62 @ItemViewType | 62 @ItemViewType |
63 public int getItemViewType() { | 63 protected int getItemViewType() { |
64 return ItemViewType.PROMO; | 64 return ItemViewType.PROMO; |
65 } | 65 } |
66 | 66 |
67 /** | 67 /** |
68 * @return a {@link DestructionObserver} observer that updates the visibilit
y of the signin | 68 * @return a {@link DestructionObserver} observer that updates the visibilit
y of the signin |
69 * promo and unregisters itself when the New Tab Page is destroyed. | 69 * promo and unregisters itself when the New Tab Page is destroyed. |
70 */ | 70 */ |
71 @Nullable | 71 @Nullable |
72 public DestructionObserver getObserver() { | 72 public DestructionObserver getObserver() { |
73 return mObserver; | 73 return mObserver; |
74 } | 74 } |
75 | 75 |
76 @Override | 76 @Override |
77 public void onBindViewHolder(NewTabPageViewHolder holder) { | 77 protected void onBindViewHolder(NewTabPageViewHolder holder) { |
78 assert holder instanceof StatusCardViewHolder; | 78 assert holder instanceof StatusCardViewHolder; |
79 ((StatusCardViewHolder) holder).onBindViewHolder(this); | 79 ((StatusCardViewHolder) holder).onBindViewHolder(this); |
80 mImpressionTracker.reset(mImpressionTracker.wasTriggered() ? null : hold
er.itemView); | 80 mImpressionTracker.reset(mImpressionTracker.wasTriggered() ? null : hold
er.itemView); |
81 } | 81 } |
82 | 82 |
83 @Override | 83 @Override |
| 84 protected void visitOptionalItem(NodeVisitor visitor) { |
| 85 visitor.visitSignInPromo(); |
| 86 } |
| 87 |
| 88 @Override |
84 @StringRes | 89 @StringRes |
85 public int getHeader() { | 90 public int getHeader() { |
86 return R.string.snippets_disabled_generic_prompt; | 91 return R.string.snippets_disabled_generic_prompt; |
87 } | 92 } |
88 | 93 |
89 @Override | 94 @Override |
90 public String getDescription() { | 95 public String getDescription() { |
91 return ContextUtils.getApplicationContext().getString( | 96 return ContextUtils.getApplicationContext().getString( |
92 R.string.snippets_disabled_signed_out_instructions); | 97 R.string.snippets_disabled_signed_out_instructions); |
93 } | 98 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 R.dimen.ntp_sign_in_promo_margin_top); | 192 R.dimen.ntp_sign_in_promo_margin_top); |
188 } | 193 } |
189 | 194 |
190 @DrawableRes | 195 @DrawableRes |
191 @Override | 196 @Override |
192 protected int selectBackground(boolean hasCardAbove, boolean hasCardBelo
w) { | 197 protected int selectBackground(boolean hasCardAbove, boolean hasCardBelo
w) { |
193 return R.drawable.ntp_signin_promo_card_single; | 198 return R.drawable.ntp_signin_promo_card_single; |
194 } | 199 } |
195 } | 200 } |
196 } | 201 } |
OLD | NEW |