I use Volleyto make internet requests. I think the method onResponseshould only be called once when you get the answer, but I found it twice.
here is my code:
YVolley.getInstance(context).getImageLoader().get(category.child.get(i).icon, new ImageLoader.ImageListener() {
@Override
public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
Drawable drawable = new BitmapDrawable(context.getResources(), response.getBitmap());
drawable.setBounds(0, 0, GeneralUtil.dip2px(context, 45), GeneralUtil.dip2px(context, 45));
button.setCompoundDrawables(null, drawable, null, null);
Log.i("swifter", "get icon ... success == "+url);
}
@Override
public void onErrorResponse(VolleyError error) {
Log.i("swifter", "get drawable icon error...");
}
});
A success magazine has been successfully printed twice.
Is something wrong with my code, or should it be like that?
source
share