OLD | NEW |
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 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 loadTaskCompleted(); | 1014 loadTaskCompleted(); |
1015 // The page contents are initially hidden; otherwise they'll be draw
n centered on the | 1015 // The page contents are initially hidden; otherwise they'll be draw
n centered on the |
1016 // page before the most visited sites are available and then jump up
wards to make space | 1016 // page before the most visited sites are available and then jump up
wards to make space |
1017 // once the most visited sites are available. | 1017 // once the most visited sites are available. |
1018 mNewTabPageLayout.setVisibility(View.VISIBLE); | 1018 mNewTabPageLayout.setVisibility(View.VISIBLE); |
1019 } | 1019 } |
1020 mSnapshotMostVisitedChanged = true; | 1020 mSnapshotMostVisitedChanged = true; |
1021 } | 1021 } |
1022 | 1022 |
1023 @Override | 1023 @Override |
1024 public void onPopularURLsAvailable( | 1024 public void onIconMadeAvailable(String siteUrl) { |
1025 String[] urls, String[] faviconUrls, String[] largeIconUrls) { | 1025 mMostVisitedDesign.onIconUpdated(siteUrl); |
1026 for (int i = 0; i < urls.length; i++) { | |
1027 final String url = urls[i]; | |
1028 boolean useLargeIcon = !largeIconUrls[i].isEmpty(); | |
1029 // Only fetch one of favicon or large icon based on what is required
on the NTP. | |
1030 // The other will be fetched on visiting the site. | |
1031 String iconUrl = useLargeIcon ? largeIconUrls[i] : faviconUrls[i]; | |
1032 if (iconUrl.isEmpty()) continue; | |
1033 | |
1034 IconAvailabilityCallback callback = new IconAvailabilityCallback() { | |
1035 @Override | |
1036 public void onIconAvailabilityChecked(boolean newlyAvailable) { | |
1037 if (newlyAvailable) { | |
1038 mMostVisitedDesign.onIconUpdated(url); | |
1039 } | |
1040 } | |
1041 }; | |
1042 mManager.ensureIconIsAvailable( | |
1043 url, iconUrl, useLargeIcon, /*isTemporary=*/false, callback)
; | |
1044 } | |
1045 } | 1026 } |
1046 | 1027 |
1047 /** | 1028 /** |
1048 * Shows the most visited placeholder ("Nothing to see here") if there are n
o most visited | 1029 * Shows the most visited placeholder ("Nothing to see here") if there are n
o most visited |
1049 * items and there is no search provider logo. | 1030 * items and there is no search provider logo. |
1050 */ | 1031 */ |
1051 private void updateMostVisitedPlaceholderVisibility() { | 1032 private void updateMostVisitedPlaceholderVisibility() { |
1052 boolean showPlaceholder = mHasReceivedMostVisitedSites | 1033 boolean showPlaceholder = mHasReceivedMostVisitedSites |
1053 && mMostVisitedLayout.getChildCount() == 0 | 1034 && mMostVisitedLayout.getChildCount() == 0 |
1054 && !mSearchProviderHasLogo; | 1035 && !mSearchProviderHasLogo; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 } | 1212 } |
1232 | 1213 |
1233 /** | 1214 /** |
1234 * @return The adapter position the user has scrolled to. | 1215 * @return The adapter position the user has scrolled to. |
1235 */ | 1216 */ |
1236 public int getScrollPosition() { | 1217 public int getScrollPosition() { |
1237 if (mUseCardsUi) return mRecyclerView.getScrollPosition(); | 1218 if (mUseCardsUi) return mRecyclerView.getScrollPosition(); |
1238 return RecyclerView.NO_POSITION; | 1219 return RecyclerView.NO_POSITION; |
1239 } | 1220 } |
1240 } | 1221 } |
OLD | NEW |