Commit 8552baff authored by 委座-江's avatar 委座-江

性能优化

parent 6743ccd8
package com.widget.imagevideobanner.view;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatImageView;
......@@ -38,6 +37,18 @@ public class VpImageView extends AppCompatImageView implements IPlayTarget {
}
};
private RequestListener requestListener = new RequestListener() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
Log.e(TAG,ThrowableUtils.getFullStackTrace(e));
return false;
}
@Override
public boolean onResourceReady(Object resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
return false;
}
};
public VpImageView(Context context) {
super(context);
......@@ -50,24 +61,11 @@ public class VpImageView extends AppCompatImageView implements IPlayTarget {
}
private void setImageUrl(String url) {
//todo 待确定是否一定会使用缓存 缺失加载前&加载失败的备用图
Log.e(TAG,url);
Glide.with(getContext()).load(url)
.error(R.drawable.load_fail)
.placeholder(R.drawable.load_fail)
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
Log.e(TAG,ThrowableUtils.getFullStackTrace(e));
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
Log.e(TAG,"onResourceReady");
return false;
}
}).into(this);
.listener(requestListener).into(this);
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment