Skip to content

Commit

Permalink
fix #64
Browse files Browse the repository at this point in the history
  • Loading branch information
ChadCym committed Jun 8, 2016
1 parent 39b622d commit 4bdb41a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 36 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ dependencies {
compile project(':material-spinner-1.0.5')
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.baserecyclerviewadapterhelper.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
Expand Down Expand Up @@ -46,7 +48,7 @@ protected void onBindDefViewHolder(BaseViewHolder holder, String item) {

@Override
protected void convert(BaseViewHolder helper, String item) {
helper.setImageUrl(R.id.iv, item);
Glide.with(mContext).load(item).crossFade().into((ImageView) helper.getView(R.id.iv));
}

public class TextViewHolder extends BaseViewHolder {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.chad.baserecyclerviewadapterhelper.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.baserecyclerviewadapterhelper.R;
import com.chad.baserecyclerviewadapterhelper.data.DataServer;
import com.chad.baserecyclerviewadapterhelper.entity.Status;
Expand All @@ -26,11 +28,11 @@ protected void convert(BaseViewHolder helper, Status item) {
helper.setText(R.id.tweetName, item.getUserName())
.setText(R.id.tweetText, item.getText())
.setText(R.id.tweetDate, item.getCreatedAt())
.setImageUrl(R.id.tweetAvatar, item.getUserAvatar(), R.mipmap.def_head, new GlideCircleTransform(mContext))
.setVisible(R.id.tweetRT, item.isRetweet())
.setOnClickListener(R.id.tweetAvatar, new OnItemChildClickListener())
.setOnClickListener(R.id.tweetName, new OnItemChildClickListener())
.linkify(R.id.tweetText);
Glide.with(mContext).load(item.getUserAvatar()).crossFade().placeholder(R.mipmap.def_head).transform(new GlideCircleTransform(mContext)).into((ImageView) helper.getView(R.id.tweetAvatar));
}


Expand Down
1 change: 0 additions & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ dependencies {

compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
import android.widget.RatingBar;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;


/**
* https://github.com/CymChad/BaseRecyclerViewAdapterHelper
Expand Down Expand Up @@ -149,35 +145,6 @@ public BaseViewHolder setImageDrawable(int viewId, Drawable drawable) {
return this;
}

/**
* Will download an image from a URL and put it in an ImageView.<br/>
* It uses Square's Picasso library to download the image asynchronously and put the result into the ImageView.<br/>
* Picasso manages recycling of views in a ListView.<br/>
* If you need more control over the Picasso settings, use {BaseViewHolder#setImageBuilder}.
*
* @param viewId The view id.
* @param imageUrl The image URL.
* @return The BaseViewHolder for chaining.
*/
public BaseViewHolder setImageUrl(int viewId, String imageUrl) {
ImageView view = getView(viewId);
Glide.with(context).load(imageUrl).crossFade().into(view);
return this;
}

public BaseViewHolder setImageUrl(int viewId, String imageUrl, int defResourceId) {
ImageView view = getView(viewId);
Glide.with(context).load(imageUrl).crossFade().placeholder(defResourceId).into(view);
return this;
}

public BaseViewHolder setImageUrl(int viewId, String imageUrl, int defResourceId, BitmapTransformation... transformations) {
ImageView view = getView(viewId);
Glide.with(context).load(imageUrl).crossFade().placeholder(defResourceId).transform(transformations).into(view);
return this;
}


/**
* Add an action to set the image of an image view. Can be called multiple times.
*/
Expand Down

0 comments on commit 4bdb41a

Please sign in to comment.