Skip to content

Commit

Permalink
Replace Volley with Glide in custom reader tag header view
Browse files Browse the repository at this point in the history
  • Loading branch information
malinajirka committed Jul 23, 2018
1 parent 7150685 commit 51d9294
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.RelativeLayout;
import android.widget.TextView;

Expand All @@ -18,15 +20,16 @@
import org.wordpress.android.ui.reader.utils.ReaderUtils;
import org.wordpress.android.util.JSONUtils;
import org.wordpress.android.util.PhotonUtils;
import org.wordpress.android.widgets.WPNetworkImageView;
import org.wordpress.android.util.image.ImageManager;
import org.wordpress.android.util.image.ImageType;

import java.util.HashMap;

/**
* topmost view in post adapter when showing tag preview - displays tag name and follow button
*/
public class ReaderTagHeaderView extends RelativeLayout {
private WPNetworkImageView mImageView;
private ImageView mImageView;
private TextView mTxtAttribution;
private ReaderTag mCurrentTag;

Expand All @@ -49,8 +52,8 @@ public ReaderTagHeaderView(Context context, AttributeSet attrs, int defStyleAttr

private void initView(Context context) {
View view = inflate(context, R.layout.reader_tag_header_view, this);
mImageView = (WPNetworkImageView) view.findViewById(R.id.image_tag_header);
mTxtAttribution = (TextView) view.findViewById(R.id.text_attribution);
mImageView = view.findViewById(R.id.image_tag_header);
mTxtAttribution = view.findViewById(R.id.text_attribution);
}

public void setCurrentTag(final ReaderTag tag) {
Expand All @@ -62,11 +65,11 @@ public void setCurrentTag(final ReaderTag tag) {

if (isTagChanged) {
mTxtAttribution.setText(null);
mImageView.resetImage();
ImageManager.getInstance().cancelRequestAndClearImageView(mImageView);
mCurrentTag = tag;
}

TextView txtTagName = (TextView) findViewById(R.id.text_tag);
TextView txtTagName = findViewById(R.id.text_tag);
txtTagName.setText(tag.getLabel());

// use cached info if it's available, otherwise request it if the tag has changed
Expand All @@ -81,7 +84,7 @@ private void setTagHeaderInfo(final ReaderTagHeaderInfo info) {
int imageWidth = mImageView.getWidth();
int imageHeight = getContext().getResources().getDimensionPixelSize(R.dimen.reader_tag_header_image_height);
String photonUrl = PhotonUtils.getPhotonImageUrl(info.getImageUrl(), imageWidth, imageHeight);
mImageView.setImageUrl(photonUrl, WPNetworkImageView.ImageType.PHOTO);
ImageManager.getInstance().load(mImageView, ImageType.PHOTO, photonUrl, ScaleType.CENTER_CROP);

// show attribution line - author name when available, otherwise blog name or nothing
if (info.hasAuthorName()) {
Expand Down
4 changes: 2 additions & 2 deletions WordPress/src/main/res/layout/reader_tag_header_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
android:layout_height="@dimen/reader_tag_header_image_height"
android:layout_marginBottom="@dimen/margin_extra_small">

<org.wordpress.android.widgets.WPNetworkImageView
<ImageView
android:id="@+id/image_tag_header"
android:layout_width="match_parent"
android:layout_height="@dimen/reader_tag_header_image_height"
android:scaleType="centerCrop" />
android:contentDescription="@null"/>

<View
android:id="@+id/view_overlay"
Expand Down

0 comments on commit 51d9294

Please sign in to comment.