зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1390356 - review: getMetadataSlow -> getImageUrl in Item interface. r=mcomella
MozReview-Commit-ID: 8pFmBQf4fzp --HG-- extra : rebase_source : 6a004bb45a1d88d8f0c028a5304042a31eca52d3
This commit is contained in:
Родитель
5d0af9f992
Коммит
0ff9993c78
|
@ -89,7 +89,7 @@ import java.net.URISyntaxException;
|
|||
pageIconLayout.setLayoutParams(layoutParams);
|
||||
|
||||
// We're matching the specific icon behavior for highlights and top sites.
|
||||
final String overrideIconURL = !shouldOverrideIconWithImageProvider ? null : item.getMetadataSlow().getImageUrl();
|
||||
final String overrideIconURL = !shouldOverrideIconWithImageProvider ? null : item.getImageUrl();
|
||||
pageIconLayout.updateIcon(item.getUrl(), overrideIconURL);
|
||||
|
||||
navigationView = (NavigationView) content.findViewById(R.id.menu);
|
||||
|
|
|
@ -138,6 +138,21 @@ public class Highlight implements Item {
|
|||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image URL associated with this Highlight.
|
||||
*
|
||||
* This implementation may be slow: see {@link #getMetadataSlow()}.
|
||||
*
|
||||
* @return the image URL, or the empty String if there is none.
|
||||
*/
|
||||
@NonNull
|
||||
@Override
|
||||
public String getImageUrl() {
|
||||
final Metadata metadata = getMetadataSlow();
|
||||
final String imageUrl = metadata.getImageUrl();
|
||||
return imageUrl != null ? imageUrl : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image url in the highlight's metadata. This value does not provide valid image url but is
|
||||
* consistent across invocations and can be used to compare against other Highlight's fast image urls.
|
||||
|
|
|
@ -12,13 +12,14 @@ public interface Item {
|
|||
String getUrl();
|
||||
|
||||
/**
|
||||
* Returns the metadata associated with this stream item.
|
||||
* Returns the image URL associated with this stream item.
|
||||
*
|
||||
* This operation could be slow in some implementations (see {@link Highlight#getMetadataSlow()}), hence the name.
|
||||
* imo, it is better to expose this possibility in the interface for all implementations rather than hide this fact.
|
||||
* Some implementations may be slow due to lazy loading: see {@link Highlight#getImageUrl()}.
|
||||
*
|
||||
* @return the image URL, or the empty String when there is none.
|
||||
*/
|
||||
@NonNull
|
||||
Metadata getMetadataSlow();
|
||||
String getImageUrl();
|
||||
|
||||
/**
|
||||
* @return True if the item is bookmarked, false otherwise. Might return 'null' if the bookmark
|
||||
|
|
|
@ -75,10 +75,11 @@ public class TopSite implements Item {
|
|||
return isPinned;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Metadata getMetadataSlow() {
|
||||
return metadata;
|
||||
@Override
|
||||
public String getImageUrl() {
|
||||
final String imageUrl = metadata.getImageUrl();
|
||||
return imageUrl != null ? imageUrl : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -111,7 +111,7 @@ public class HighlightItem extends StreamItem {
|
|||
|
||||
updateUiForSource(highlight.getSource());
|
||||
updatePageDomain();
|
||||
pageIconLayout.updateIcon(highlight.getUrl(), highlight.getMetadataSlow().getImageUrl());
|
||||
pageIconLayout.updateIcon(highlight.getUrl(), highlight.getImageUrl());
|
||||
}
|
||||
|
||||
private void updateUiForSource(Utils.HighlightSource source) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче