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 custom reader tag header view #8083

Merged
merged 1 commit into from
Jul 25, 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 @@ -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