Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android截击ImageListener响应行为_Android_Caching_Request_Response_Android Volley - Fatal编程技术网

Android截击ImageListener响应行为

Android截击ImageListener响应行为,android,caching,request,response,android-volley,Android,Caching,Request,Response,Android Volley,我使用的是安卓截击库,如果您知道的话,我的问题应该很容易回答;) 我需要知道com.android.volley.toolbox.ImageLoader.ImageListener在 处理成功的响应。医生说 The call flow is this: 1. Upon being attached to a request, onResponse(response, true) will be invoked to reflect any cached data that was alrea

我使用的是安卓截击库,如果您知道的话,我的问题应该很容易回答;)

我需要知道
com.android.volley.toolbox.ImageLoader.ImageListener
在 处理成功的响应。医生说

The call flow is this: 1. Upon being attached to a request, 
onResponse(response, true) will be invoked to reflect any cached data 
that was already available. If the data was available, response.getBitmap() will 
be non-null. 2. After a network response returns, only one of the following 
cases will happen: - onResponse(response, false) will be called if the 
image was loaded. or - onErrorResponse will be called if there was an error 
loading the image.
我想知道的是:这是否意味着我可以调用两次
onResponse
(首先使用
isImmediate
设置为
false
,然后设置为
true
)?我可以相信吗?我的意思是,它是否总是这样(如果图像加载成功)

我正试着做这样的事情

imageLoader.get(image.getUrl(), new ImageListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        callback.call(null, error);
                    }

                    @Override
                    public void onResponse(ImageContainer response,
                            boolean isImmediate) {
                        if (response.getBitmap() != null) {
                            callback.call(response.getBitmap(), null);
                        }
                    }
                });
当图像可以成功加载时,我需要调用
callback.call()
,我还需要
response.getBitmap()
返回实际位图,而不是
null

提前谢谢

我想知道的是:这是否意味着我可以调用onResponse两次(首先将isImmediate设置为false,然后设置为true)?我可以相信吗?我的意思是,它是否总是这样(如果图像加载成功)

简短回答:

除非这个类的实现发生了改变(我非常怀疑这种情况会发生),否则您可以相信这个调用顺序会得到尊重

如果有帮助的话,我在这里的另一个答案中给出了三个可能的响应案例的一些细节: