Glide加载图片查看报错信息
作者:互联网
Glide为我们提供了listener()方法,加上它就能看到报错信息了,查看log:
package com.kite.imageloader;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = (ImageView) findViewById(R.id.image);
Toast.makeText(this, "kkk", Toast.LENGTH_SHORT).show();
Glide.with(this).load("http://7xi8d6.com1.z0.glb.clouddn.com/16124047_121657248344062_4191645221970247680_n.jpg")
.listener(mRequestListener)
.into(imageView);
RequestListener mRequestListener = new RequestListener() {
@Override
public boolean onl oadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
Log.d(TAG, "onException: " + e.toString()+" model:"+model+" isFirstResource: "+isFirstResource);
imageView.setImageResource(R.mipmap.ic_launcher);
return false;
}
@Override
public boolean onResourceReady(Object resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) {
Log.e(TAG, "model:"+model+" isFirstResource: "+isFirstResource);
return false;
}
};
}
标签:glide,Glide,报错,isFirstResource,import,model,com,android,加载 来源: https://blog.csdn.net/rabbit_ding0810/article/details/122506795