headlines: use flavor image tag for a slight performance improvement, hopefully
This commit is contained in:
parent
3b37e33d6b
commit
79f4b94a34
@ -657,6 +657,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
private ColorGenerator m_colorGenerator = ColorGenerator.DEFAULT;
|
private ColorGenerator m_colorGenerator = ColorGenerator.DEFAULT;
|
||||||
private TextDrawable.IBuilder m_drawableBuilder = TextDrawable.builder().round();
|
private TextDrawable.IBuilder m_drawableBuilder = TextDrawable.builder().round();
|
||||||
|
private final DisplayImageOptions displayImageOptions;
|
||||||
|
|
||||||
public ArticleListAdapter(Context context, int textViewResourceId, ArrayList<Article> items) {
|
public ArticleListAdapter(Context context, int textViewResourceId, ArrayList<Article> items) {
|
||||||
super(context, textViewResourceId, items);
|
super(context, textViewResourceId, items);
|
||||||
@ -666,6 +667,12 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
TypedValue tv = new TypedValue();
|
TypedValue tv = new TypedValue();
|
||||||
theme.resolveAttribute(R.attr.headlineTitleHighScoreUnreadTextColor, tv, true);
|
theme.resolveAttribute(R.attr.headlineTitleHighScoreUnreadTextColor, tv, true);
|
||||||
titleHighScoreUnreadColor = tv.data;
|
titleHighScoreUnreadColor = tv.data;
|
||||||
|
|
||||||
|
displayImageOptions = new DisplayImageOptions.Builder()
|
||||||
|
.cacheInMemory(true)
|
||||||
|
.resetViewBeforeLoading(true)
|
||||||
|
.cacheOnDisk(true)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getViewTypeCount() {
|
public int getViewTypeCount() {
|
||||||
@ -908,7 +915,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
boolean showFlavorImage = "HL_DEFAULT".equals(m_prefs.getString("headline_mode", "HL_DEFAULT"));
|
boolean showFlavorImage = "HL_DEFAULT".equals(m_prefs.getString("headline_mode", "HL_DEFAULT"));
|
||||||
|
|
||||||
if (showFlavorImage && holder.flavorImageView != null) {
|
if (showFlavorImage && holder.flavorImageView != null) {
|
||||||
|
|
||||||
holder.flavorImageArrow.setVisibility(View.GONE);
|
holder.flavorImageArrow.setVisibility(View.GONE);
|
||||||
|
|
||||||
if (article.noValidFlavorImage) {
|
if (article.noValidFlavorImage) {
|
||||||
@ -935,7 +941,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (article.flavorImage != null) {
|
if (article.flavorImage != null) {
|
||||||
|
|
||||||
String imgSrc = article.flavorImage.attr("src");
|
String imgSrc = article.flavorImage.attr("src");
|
||||||
final String imgSrcFirst = imgSrc;
|
final String imgSrcFirst = imgSrc;
|
||||||
|
|
||||||
@ -943,12 +948,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
if (imgSrc.indexOf("//") == 0)
|
if (imgSrc.indexOf("//") == 0)
|
||||||
imgSrc = "http:" + imgSrc;
|
imgSrc = "http:" + imgSrc;
|
||||||
|
|
||||||
DisplayImageOptions options = new DisplayImageOptions.Builder()
|
|
||||||
.cacheInMemory(true)
|
|
||||||
.resetViewBeforeLoading(true)
|
|
||||||
.cacheOnDisk(true)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
ViewCompat.setTransitionName(holder.flavorImageView, "TRANSITION:ARTICLE_IMAGES_PAGER");
|
ViewCompat.setTransitionName(holder.flavorImageView, "TRANSITION:ARTICLE_IMAGES_PAGER");
|
||||||
|
|
||||||
holder.flavorImageView.setOnClickListener(new OnClickListener() {
|
holder.flavorImageView.setOnClickListener(new OnClickListener() {
|
||||||
@ -974,9 +973,13 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
final ViewGroup flavorImageHolder = holder.flavorImageHolder;
|
final ViewGroup flavorImageHolder = holder.flavorImageHolder;
|
||||||
final ProgressBar flavorImageLoadingBar = holder.flavorImageLoadingBar;
|
final ProgressBar flavorImageLoadingBar = holder.flavorImageLoadingBar;
|
||||||
|
|
||||||
|
if (holder.flavorImageView.getTag() == null || !holder.flavorImageView.getTag().equals(imgSrc)) {
|
||||||
|
|
||||||
|
holder.flavorImageView.setTag(imgSrc);
|
||||||
|
|
||||||
ImageAware imageAware = new ImageViewAware(holder.flavorImageView, false);
|
ImageAware imageAware = new ImageViewAware(holder.flavorImageView, false);
|
||||||
|
|
||||||
ImageLoader.getInstance().displayImage(imgSrc, imageAware, options, new ImageLoadingListener() {
|
ImageLoader.getInstance().displayImage(imgSrc, imageAware, displayImageOptions, new ImageLoadingListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadingCancelled(String arg0,
|
public void onLoadingCancelled(String arg0,
|
||||||
@ -1015,6 +1018,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} else{
|
} else{
|
||||||
article.noValidFlavorImage = true;
|
article.noValidFlavorImage = true;
|
||||||
holder.flavorImageHolder.setVisibility(View.GONE);
|
holder.flavorImageHolder.setVisibility(View.GONE);
|
||||||
|
Loading…
Reference in New Issue
Block a user