| 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.support.annotation.CallSuper; | 7 import android.support.annotation.CallSuper; |
| 8 | 8 |
| 9 import org.chromium.base.Callback; | 9 import org.chromium.base.Callback; |
| 10 import org.chromium.base.Log; | 10 import org.chromium.base.Log; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 import java.util.List; | 30 import java.util.List; |
| 31 import java.util.Set; | 31 import java.util.Set; |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * A group of suggestions, with a header, a status card, and a progress indicato
r. This is | 34 * A group of suggestions, with a header, a status card, and a progress indicato
r. This is |
| 35 * responsible for tracking whether its suggestions have been saved offline. | 35 * responsible for tracking whether its suggestions have been saved offline. |
| 36 */ | 36 */ |
| 37 public class SuggestionsSection extends InnerNode { | 37 public class SuggestionsSection extends InnerNode { |
| 38 private static final String TAG = "NtpCards"; | 38 private static final String TAG = "NtpCards"; |
| 39 | 39 |
| 40 private static final Set<Integer> SECTION_DISMISSAL_GROUP = new HashSet<>(Ar
rays.asList(1, 2)); | |
| 41 | |
| 42 private final Delegate mDelegate; | 40 private final Delegate mDelegate; |
| 43 private final SuggestionsCategoryInfo mCategoryInfo; | 41 private final SuggestionsCategoryInfo mCategoryInfo; |
| 44 private final OfflinePageBridge mOfflinePageBridge; | 42 private final OfflinePageBridge mOfflinePageBridge; |
| 45 private final OfflinePageBridge.OfflinePageModelObserver mOfflinePageObserve
r; | 43 private final OfflinePageBridge.OfflinePageModelObserver mOfflinePageObserve
r; |
| 46 | 44 |
| 47 // Children | 45 // Children |
| 48 private final SectionHeader mHeader; | 46 private final SectionHeader mHeader; |
| 49 private final SuggestionsList mSuggestionsList; | 47 private final SuggestionsList mSuggestionsList; |
| 50 private final StatusItem mStatus; | 48 private final StatusItem mStatus; |
| 51 private final ActionItem mMoreButton; | 49 private final ActionItem mMoreButton; |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 mHeader.setVisible(headerVisibility); | 480 mHeader.setVisible(headerVisibility); |
| 483 } | 481 } |
| 484 | 482 |
| 485 /** | 483 /** |
| 486 * @return The set of indices corresponding to items that can dismiss this e
ntire section | 484 * @return The set of indices corresponding to items that can dismiss this e
ntire section |
| 487 * (as opposed to individual items in it). | 485 * (as opposed to individual items in it). |
| 488 */ | 486 */ |
| 489 private Set<Integer> getSectionDismissalRange() { | 487 private Set<Integer> getSectionDismissalRange() { |
| 490 if (hasSuggestions()) return Collections.emptySet(); | 488 if (hasSuggestions()) return Collections.emptySet(); |
| 491 | 489 |
| 492 if (!mMoreButton.isVisible()) { | 490 int statusCardIndex = getStartingOffsetForChild(mStatus); |
| 493 assert getStartingOffsetForChild(mStatus) == 1; | 491 if (!mMoreButton.isVisible()) return Collections.singleton(statusCardInd
ex); |
| 494 return Collections.singleton(1); | |
| 495 } | |
| 496 | 492 |
| 497 assert SECTION_DISMISSAL_GROUP.contains(getStartingOffsetForChild(mStatu
s)); | 493 assert statusCardIndex + 1 == getStartingOffsetForChild(mMoreButton); |
| 498 assert SECTION_DISMISSAL_GROUP.contains(getStartingOffsetForChild(mMoreB
utton)); | 494 return new HashSet<>(Arrays.asList(statusCardIndex, statusCardIndex + 1)
); |
| 499 return SECTION_DISMISSAL_GROUP; | |
| 500 } | 495 } |
| 501 | 496 |
| 502 public SuggestionsCategoryInfo getCategoryInfo() { | 497 public SuggestionsCategoryInfo getCategoryInfo() { |
| 503 return mCategoryInfo; | 498 return mCategoryInfo; |
| 504 } | 499 } |
| 505 | 500 |
| 506 public String getHeaderText() { | 501 public String getHeaderText() { |
| 507 return mHeader.getHeaderText(); | 502 return mHeader.getHeaderText(); |
| 508 } | 503 } |
| 509 | 504 |
| 510 ProgressItem getProgressItemForTesting() { | 505 ProgressItem getProgressItemForTesting() { |
| 511 return mProgressIndicator; | 506 return mProgressIndicator; |
| 512 } | 507 } |
| 513 | 508 |
| 514 ActionItem getActionItemForTesting() { | 509 ActionItem getActionItemForTesting() { |
| 515 return mMoreButton; | 510 return mMoreButton; |
| 516 } | 511 } |
| 517 | 512 |
| 518 SectionHeader getHeaderItemForTesting() { | 513 SectionHeader getHeaderItemForTesting() { |
| 519 return mHeader; | 514 return mHeader; |
| 520 } | 515 } |
| 521 } | 516 } |
| OLD | NEW |