Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Volley with Glide in Stats #8025

Merged
merged 1 commit into from
Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.wordpress.android.ui.stats.service.StatsServiceStarter;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.SiteUtils;
import org.wordpress.android.util.image.ImageManager;

import javax.inject.Inject;

Expand Down Expand Up @@ -48,6 +49,7 @@ public abstract class StatsAbstractFragment extends Fragment {

@Inject AccountStore mAccountStore;
@Inject SiteStore mSiteStore;
@Inject ImageManager mImageManager;

/**
* Wheter or not previous data is available.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.wordpress.android.ui.stats.service.StatsServiceLogic;
import org.wordpress.android.util.FormatUtils;
import org.wordpress.android.util.GravatarUtils;
import org.wordpress.android.widgets.WPNetworkImageView;
import org.wordpress.android.util.image.ImageType;

import java.util.List;

Expand Down Expand Up @@ -254,8 +254,9 @@ public View getGroupView(int groupPosition, boolean isExpanded,

// icon
// holder.showNetworkImage(icon);
holder.networkImageView.setImageUrl(GravatarUtils.fixGravatarUrl(icon, mResourceVars.mHeaderAvatarSizePx),
WPNetworkImageView.ImageType.AVATAR);
mImageManager.loadIntoCircle(holder.networkImageView, ImageType.AVATAR,
GravatarUtils.fixGravatarUrl(icon, mResourceVars.mHeaderAvatarSizePx));

holder.networkImageView.setVisibility(View.VISIBLE);

final FollowDataModel followData = group.getFollowData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -14,8 +13,6 @@
import org.wordpress.android.ui.stats.models.SingleItemModel;
import org.wordpress.android.ui.stats.service.StatsServiceLogic;
import org.wordpress.android.util.FormatUtils;
import org.wordpress.android.util.GravatarUtils;
import org.wordpress.android.widgets.WPNetworkImageView;

import java.util.List;

Expand Down Expand Up @@ -249,12 +246,6 @@ public View getGroupView(int groupPosition, boolean isExpanded,

// Site icon
holder.networkImageView.setVisibility(View.GONE);
if (!TextUtils.isEmpty(icon)) {
holder.networkImageView.setImageUrl(
GravatarUtils.fixGravatarUrl(icon, mResourceVars.mHeaderAvatarSizePx),
WPNetworkImageView.ImageType.GONE_UNTIL_AVAILABLE
);
}

if (children == 0) {
holder.showLinkIcon();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.wordpress.android.util.FormatUtils;
import org.wordpress.android.util.GravatarUtils;
import org.wordpress.android.util.StringUtils;
import org.wordpress.android.widgets.WPNetworkImageView;
import org.wordpress.android.util.image.ImageType;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -234,9 +234,8 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
currentRowData.getViews()));

// avatar
holder.networkImageView.setImageUrl(
GravatarUtils.fixGravatarUrl(currentRowData.getAvatar(), mResourceVars.mHeaderAvatarSizePx),
WPNetworkImageView.ImageType.AVATAR);
mImageManager.loadIntoCircle(holder.networkImageView, ImageType.AVATAR,
GravatarUtils.fixGravatarUrl(currentRowData.getAvatar(), mResourceVars.mHeaderAvatarSizePx));
holder.networkImageView.setVisibility(View.VISIBLE);

final FollowDataModel followData = currentRowData.getFollowData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.wordpress.android.util.FormatUtils;
import org.wordpress.android.util.GravatarUtils;
import org.wordpress.android.util.UrlUtils;
import org.wordpress.android.widgets.WPNetworkImageView;
import org.wordpress.android.util.image.ImageType;

import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -389,9 +389,8 @@ public void onClick(View view) {
holder.totalsTextView.getText()));

// Avatar
holder.networkImageView.setImageUrl(
GravatarUtils.fixGravatarUrl(currentRowData.getAvatar(), mResourceVars.mHeaderAvatarSizePx),
WPNetworkImageView.ImageType.AVATAR);
mImageManager.loadIntoCircle(holder.networkImageView, ImageType.AVATAR,
GravatarUtils.fixGravatarUrl(currentRowData.getAvatar(), mResourceVars.mHeaderAvatarSizePx));
holder.networkImageView.setVisibility(View.VISIBLE);

if (followData == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.wordpress.android.util.FormatUtils;
import org.wordpress.android.util.GravatarUtils;
import org.wordpress.android.util.StringUtils;
import org.wordpress.android.widgets.WPNetworkImageView;
import org.wordpress.android.util.image.ImageType;

import java.util.List;

Expand Down Expand Up @@ -283,9 +283,8 @@ public View getView(int position, View convertView, ViewGroup parent) {
holder.alternativeImage.setVisibility(View.VISIBLE);
} else {
// On other Android versions, use the Gravatar image
holder.networkImageView.setImageUrl(
GravatarUtils.fixGravatarUrl(imageUrl, mResourceVars.mHeaderAvatarSizePx),
WPNetworkImageView.ImageType.BLAVATAR);
mImageManager.load(holder.networkImageView, ImageType.BLAVATAR,
GravatarUtils.fixGravatarUrl(imageUrl, mResourceVars.mHeaderAvatarSizePx));
holder.networkImageView.setVisibility(View.VISIBLE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.wordpress.android.util.FormatUtils;
import org.wordpress.android.util.GravatarUtils;
import org.wordpress.android.util.StringUtils;
import org.wordpress.android.widgets.WPNetworkImageView;
import org.wordpress.android.util.image.ImageType;

import java.util.List;

Expand Down Expand Up @@ -120,8 +120,6 @@ public View getView(int position, View convertView, ViewGroup parent) {
rowView = mInflater.inflate(R.layout.stats_list_cell, parent, false);
// configure view holder
holder = new StatsViewHolder(rowView);
holder.networkImageView.setErrorImageResId(R.drawable.ic_placeholder_blavatar_grey_lighten_20_32dp);
holder.networkImageView.setDefaultImageResId(R.drawable.ic_placeholder_blavatar_grey_lighten_20_32dp);
rowView.setTag(holder);
} else {
holder = (StatsViewHolder) rowView.getTag();
Expand All @@ -145,9 +143,8 @@ public View getView(int position, View convertView, ViewGroup parent) {
currentRowData.getTotals()));

// image
holder.networkImageView.setImageUrl(
GravatarUtils.fixGravatarUrl(getServiceImage(serviceName), mResourceVars.mHeaderAvatarSizePx),
WPNetworkImageView.ImageType.BLAVATAR);
mImageManager.load(holder.networkImageView, ImageType.BLAVATAR,
GravatarUtils.fixGravatarUrl(getServiceImage(serviceName), mResourceVars.mHeaderAvatarSizePx));
holder.networkImageView.setVisibility(View.VISIBLE);

return rowView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
import org.wordpress.android.ui.stats.models.SingleItemModel;
import org.wordpress.android.ui.stats.service.StatsServiceLogic;
import org.wordpress.android.util.FormatUtils;
import org.wordpress.android.util.GravatarUtils;
import org.wordpress.android.util.StringUtils;
import org.wordpress.android.widgets.WPNetworkImageView;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -233,11 +231,6 @@ public View getChildView(int groupPosition, final int childPosition,

// site icon
holder.networkImageView.setVisibility(View.GONE);
if (!TextUtils.isEmpty(currentChild.icon)) {
holder.networkImageView.setImageUrl(
GravatarUtils.fixGravatarUrl(currentChild.icon, mResourceVars.mHeaderAvatarSizePx),
WPNetworkImageView.ImageType.GONE_UNTIL_AVAILABLE);
}

// no more btm
holder.imgMore.setVisibility(View.GONE);
Expand Down Expand Up @@ -307,13 +300,7 @@ public View getGroupView(final int groupPosition, boolean isExpanded,
R.string.stats_views_many_desc,
total));

// Site icon
holder.networkImageView.setVisibility(View.GONE);
if (!TextUtils.isEmpty(icon)) {
holder.networkImageView.setImageUrl(
GravatarUtils.fixGravatarUrl(icon, mResourceVars.mHeaderAvatarSizePx),
WPNetworkImageView.ImageType.GONE_UNTIL_AVAILABLE);
}

if (children == 0) {
holder.showLinkIcon();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ public View getChildView(int groupPosition, final int childPosition,

// icon.
holder.networkImageView.setVisibility(View.VISIBLE);
holder.networkImageView.setImageDrawable(getResources().getDrawable(R.drawable.ic_tag_blue_wordpress_12dp));

mImageManager
.load(holder.networkImageView, getResources().getDrawable(R.drawable.ic_tag_blue_wordpress_12dp));
return convertView;
}

Expand Down Expand Up @@ -269,7 +269,9 @@ public View getGroupView(int groupPosition, boolean isExpanded,
int drawableResource = groupName.toString().equalsIgnoreCase("uncategorized")
? R.drawable.ic_folder_blue_wordpress_12dp
: R.drawable.ic_tag_blue_wordpress_12dp;
holder.networkImageView.setImageDrawable(getResources().getDrawable(drawableResource));
mImageManager.load(holder.networkImageView, getResources().getDrawable(drawableResource));
} else {
mImageManager.cancelRequestAndClearImageView(holder.networkImageView);
}

return convertView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,29 @@
import org.wordpress.android.ui.stats.models.StatsPostModel;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.UrlUtils;
import org.wordpress.android.widgets.WPNetworkImageView;

/**
* View holder for stats_list_cell layout
*/
public class StatsViewHolder {
public final TextView entryTextView;
public final TextView totalsTextView;
public final WPNetworkImageView networkImageView;
public final ImageView networkImageView;
public final TextView alternativeImage;
public final ImageView chevronImageView;
public final ImageView linkImageView;
public final ImageView imgMore;
public final LinearLayout rowContent;

public StatsViewHolder(View view) {
rowContent = (LinearLayout) view.findViewById(R.id.layout_content);
entryTextView = (TextView) view.findViewById(R.id.stats_list_cell_entry);
totalsTextView = (TextView) view.findViewById(R.id.stats_list_cell_total);
chevronImageView = (ImageView) view.findViewById(R.id.stats_list_cell_chevron);
linkImageView = (ImageView) view.findViewById(R.id.stats_list_cell_link);
networkImageView = (WPNetworkImageView) view.findViewById(R.id.stats_list_cell_image);
alternativeImage = (TextView) view.findViewById(R.id.stats_list_cell_image_alt);
imgMore = (ImageView) view.findViewById(R.id.image_more);
rowContent = view.findViewById(R.id.layout_content);
entryTextView = view.findViewById(R.id.stats_list_cell_entry);
totalsTextView = view.findViewById(R.id.stats_list_cell_total);
chevronImageView = view.findViewById(R.id.stats_list_cell_chevron);
linkImageView = view.findViewById(R.id.stats_list_cell_link);
networkImageView = view.findViewById(R.id.stats_list_cell_image);
alternativeImage = view.findViewById(R.id.stats_list_cell_image_alt);
imgMore = view.findViewById(R.id.image_more);
}

/*
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/res/layout/stats_list_cell.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
android:contentDescription="@string/stats_list_cell_chevron_expand_desc"
app:srcCompat="@drawable/ic_chevron_right_blue_wordpress_24dp" />

<org.wordpress.android.widgets.WPNetworkImageView
<ImageView
android:id="@+id/stats_list_cell_image"
android:layout_width="@dimen/avatar_sz_small"
android:layout_height="@dimen/avatar_sz_small"
Expand Down