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