From 4bdb41aea1ed7b4294b752ba6a50277cfd0b1f2c Mon Sep 17 00:00:00 2001
From: chad <54050520@qq.com>
Date: Wed, 8 Jun 2016 09:16:38 +0800
Subject: [PATCH] fix #64
---
app/build.gradle | 1 +
.../adapter/MultipleItemAdapter.java | 4 ++-
.../adapter/QuickAdapter.java | 4 ++-
library/build.gradle | 1 -
.../library/adapter/base/BaseViewHolder.java | 33 -------------------
5 files changed, 7 insertions(+), 36 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index 10bbe5f73..d0728a04f 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -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'
}
diff --git a/app/src/main/java/com/chad/baserecyclerviewadapterhelper/adapter/MultipleItemAdapter.java b/app/src/main/java/com/chad/baserecyclerviewadapterhelper/adapter/MultipleItemAdapter.java
index bc1ade515..410f74470 100644
--- a/app/src/main/java/com/chad/baserecyclerviewadapterhelper/adapter/MultipleItemAdapter.java
+++ b/app/src/main/java/com/chad/baserecyclerviewadapterhelper/adapter/MultipleItemAdapter.java
@@ -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;
@@ -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 {
diff --git a/app/src/main/java/com/chad/baserecyclerviewadapterhelper/adapter/QuickAdapter.java b/app/src/main/java/com/chad/baserecyclerviewadapterhelper/adapter/QuickAdapter.java
index b583e96e5..f057d425d 100644
--- a/app/src/main/java/com/chad/baserecyclerviewadapterhelper/adapter/QuickAdapter.java
+++ b/app/src/main/java/com/chad/baserecyclerviewadapterhelper/adapter/QuickAdapter.java
@@ -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;
@@ -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));
}
diff --git a/library/build.gradle b/library/build.gradle
index 3d359a404..50bdd877a 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -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'
}
diff --git a/library/src/main/java/com/chad/library/adapter/base/BaseViewHolder.java b/library/src/main/java/com/chad/library/adapter/base/BaseViewHolder.java
index a398f5754..b40a6d4ee 100755
--- a/library/src/main/java/com/chad/library/adapter/base/BaseViewHolder.java
+++ b/library/src/main/java/com/chad/library/adapter/base/BaseViewHolder.java
@@ -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
@@ -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.
- * It uses Square's Picasso library to download the image asynchronously and put the result into the ImageView.
- * Picasso manages recycling of views in a ListView.
- * 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.
*/