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.suggestions; | 5 package org.chromium.chrome.browser.suggestions; |
6 | 6 |
7 import android.graphics.drawable.Drawable; | 7 import android.graphics.drawable.Drawable; |
8 import android.support.annotation.Nullable; | 8 import android.support.annotation.Nullable; |
9 | 9 |
10 import org.chromium.chrome.browser.ntp.MostVisitedTileType; | 10 import org.chromium.chrome.browser.suggestions.TileSource.TileSourceEnum; |
11 import org.chromium.chrome.browser.ntp.MostVisitedTileType.MostVisitedTileTypeEn
um; | 11 import org.chromium.chrome.browser.suggestions.TileVisualType.TileVisualTypeEnum
; |
12 import org.chromium.chrome.browser.ntp.NTPTileSource.NTPTileSourceEnum; | |
13 | 12 |
14 /** | 13 /** |
15 * Holds the details to populate a site suggestion tile. | 14 * Holds the details to populate a site suggestion tile. |
16 */ | 15 */ |
17 public class Tile implements OfflinableSuggestion { | 16 public class Tile implements OfflinableSuggestion { |
18 private final String mTitle; | 17 private final String mTitle; |
19 private final String mUrl; | 18 private final String mUrl; |
20 private final String mWhitelistIconPath; | 19 private final String mWhitelistIconPath; |
21 private final int mIndex; | 20 private final int mIndex; |
22 | 21 |
23 @NTPTileSourceEnum | 22 @TileSourceEnum |
24 private final int mSource; | 23 private final int mSource; |
25 | 24 |
26 @MostVisitedTileTypeEnum | 25 @TileVisualTypeEnum |
27 private int mType = MostVisitedTileType.NONE; | 26 private int mType = TileVisualType.NONE; |
28 | 27 |
29 @Nullable | 28 @Nullable |
30 private Drawable mIcon; | 29 private Drawable mIcon; |
31 | 30 |
32 @Nullable | 31 @Nullable |
33 private Long mOfflinePageOfflineId; | 32 private Long mOfflinePageOfflineId; |
34 | 33 |
35 /** | 34 /** |
36 * @param title The tile title. | 35 * @param title The tile title. |
37 * @param url The site URL. | 36 * @param url The site URL. |
38 * @param whitelistIconPath The path to the icon image file, if this is a wh
itelisted tile. | 37 * @param whitelistIconPath The path to the icon image file, if this is a wh
itelisted tile. |
39 * Empty otherwise. | 38 * Empty otherwise. |
40 * @param index The index of this tile in the list of tiles. | 39 * @param index The index of this tile in the list of tiles. |
41 * @param source The {@code NTPTileSource} that generated this tile. | 40 * @param source The {@code TileSource} that generated this tile. |
42 */ | 41 */ |
43 public Tile(String title, String url, String whitelistIconPath, int index, | 42 public Tile(String title, String url, String whitelistIconPath, int index, |
44 @NTPTileSourceEnum int source) { | 43 @TileSourceEnum int source) { |
45 mTitle = title; | 44 mTitle = title; |
46 mUrl = url; | 45 mUrl = url; |
47 mWhitelistIconPath = whitelistIconPath; | 46 mWhitelistIconPath = whitelistIconPath; |
48 mIndex = index; | 47 mIndex = index; |
49 mSource = source; | 48 mSource = source; |
50 } | 49 } |
51 | 50 |
52 /** | 51 /** |
53 * Imports transient data from an old tile, and reports whether there is a s
ignificant | 52 * Imports transient data from an old tile, and reports whether there is a s
ignificant |
54 * difference between the two that would require a redraw. | 53 * difference between the two that would require a redraw. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 117 |
119 /** | 118 /** |
120 * @return The index of this tile in the list of tiles. | 119 * @return The index of this tile in the list of tiles. |
121 */ | 120 */ |
122 public int getIndex() { | 121 public int getIndex() { |
123 return mIndex; | 122 return mIndex; |
124 } | 123 } |
125 | 124 |
126 /** | 125 /** |
127 * @return The source of this tile. Used for metrics tracking. Valid values
are listed in | 126 * @return The source of this tile. Used for metrics tracking. Valid values
are listed in |
128 * {@code NTPTileSource}. | 127 * {@code TileSource}. |
129 */ | 128 */ |
130 @NTPTileSourceEnum | 129 @TileSourceEnum |
131 public int getSource() { | 130 public int getSource() { |
132 return mSource; | 131 return mSource; |
133 } | 132 } |
134 | 133 |
135 /** | 134 /** |
136 * @return The visual type of this tile. Valid values are listed in | 135 * @return The visual type of this tile. Valid values are listed in {@link T
ileVisualType}. |
137 * {@link MostVisitedTileType}. | |
138 */ | 136 */ |
139 @MostVisitedTileTypeEnum | 137 @TileVisualTypeEnum |
140 public int getType() { | 138 public int getType() { |
141 return mType; | 139 return mType; |
142 } | 140 } |
143 | 141 |
144 /** | 142 /** |
145 * Sets the visual type of this tile. Valid values are listed in | 143 * Sets the visual type of this tile. Valid values are listed in |
146 * {@link MostVisitedTileType}. | 144 * {@link TileVisualType}. |
147 */ | 145 */ |
148 public void setType(@MostVisitedTileTypeEnum int type) { | 146 public void setType(@TileVisualTypeEnum int type) { |
149 mType = type; | 147 mType = type; |
150 } | 148 } |
151 | 149 |
152 /** | 150 /** |
153 * @return The icon, may be null. | 151 * @return The icon, may be null. |
154 */ | 152 */ |
155 @Nullable | 153 @Nullable |
156 public Drawable getIcon() { | 154 public Drawable getIcon() { |
157 return mIcon; | 155 return mIcon; |
158 } | 156 } |
159 | 157 |
160 /** | 158 /** |
161 * Updates the icon drawable. | 159 * Updates the icon drawable. |
162 */ | 160 */ |
163 public void setIcon(@Nullable Drawable icon) { | 161 public void setIcon(@Nullable Drawable icon) { |
164 mIcon = icon; | 162 mIcon = icon; |
165 } | 163 } |
166 } | 164 } |
OLD | NEW |