- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图在我的应用程序中的 Volley 类的 NetworkImageView 中禁用缓存。我试过这段代码,但它没有删除缓存。
mNetworkImageView = (NetworkImageView) getView().findViewById(R.id.networkImageView);
mImageLoader = VolleySingleton.getInstance().getImageLoader();
mNetworkImageView.setImageUrl(IMAGE_URL, mImageLoader);
VolleySingleton.getInstance().getRequestQueue().getCache().remove(IMAGE_URL);
最佳答案
您可以尝试以下方法(在 VolleySingleton
类中):
mImageLoader = new ImageLoader(mRequestQueue, new ImageLoader.ImageCache() {
@Override
public Bitmap getBitmap(String url) {
return null;
}
@Override
public void putBitmap(String url, Bitmap bitmap) {
}
});
调试的时候可以查看一下,在ImageLoader.java
里面的Bitmap cachedBitmap = mCache.getBitmap(cacheKey);
行设置断点,可以找到cachedBitmap
空。
或者把 Log.w("cachedBitmap", "Bitmap cached!");
作为我下面的代码来检查:
public ImageContainer get(String requestUrl, ImageListener imageListener,
int maxWidth, int maxHeight, ScaleType scaleType) {
// only fulfill requests that were initiated from the main thread.
throwIfNotOnMainThread();
final String cacheKey = getCacheKey(requestUrl, maxWidth, maxHeight, scaleType);
// Try to look up the request in the cache of remote images.
Bitmap cachedBitmap = mCache.getBitmap(cacheKey);
if (cachedBitmap != null) {
Log.w("cachedBitmap", "Bitmap cached!");
// Return the cached bitmap.
ImageContainer container = new ImageContainer(cachedBitmap, requestUrl, null, null);
imageListener.onResponse(container, true);
return container;
}
// The bitmap did not exist in the cache, fetch it!
ImageContainer imageContainer =
new ImageContainer(null, requestUrl, cacheKey, imageListener);
// Update the caller to let them know that they should use the default bitmap.
imageListener.onResponse(imageContainer, true);
// Check to see if a request is already in-flight.
BatchedImageRequest request = mInFlightRequests.get(cacheKey);
if (request != null) {
// If it is, add this request to the list of listeners.
request.addContainer(imageContainer);
return imageContainer;
}
// The request is not already in flight. Send the new request to the network and
// track it.
Request<Bitmap> newRequest = makeImageRequest(requestUrl, maxWidth, maxHeight, scaleType,
cacheKey);
mRequestQueue.add(newRequest);
mInFlightRequests.put(cacheKey,
new BatchedImageRequest(newRequest, imageContainer));
return imageContainer;
}
希望对您有所帮助!
关于android - 禁用或删除 NetworkImageView 中的缓存 - Volley,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34755109/
我有一个NetworkImageView,它从 URL 加载其内容,但在特定情况下,我还希望能够从用户的图库加载图像(甚至用相机捕获图像) . 我正在使用Image Chooser Library从图
CircularNetworkImageView thumbNail = ((CircularNetworkImageView) convertView.findViewById(R.id.UserI
我正在动态创建 Imageview 并显示它。但是我在滚动时遇到了重新加载问题所以我决定使用 NetworkImageView 但在这里我无法设置位图。它没有显示任何错误,但没有显示任何图像。在我的代
我正在尝试从我的 API 上传图像以将其显示为个人资料图片,问题是从用户第一次打开抽屉导航开始,图像就不会加载,这会使整个布局消失,但是从第二次一切正常,我注意到当图像的宽度小于高度时会发生这种情况。
我正在尝试在 ViewPager 内的 NetworkImageView 上实现缩放和双击功能。我引用了本教程:http://www.androidhive.info/2013/09/android-
我试图从 ListView 中获取 NetworkImageView 的图像路径,但它返回 null。在我的 MainActivity.java 中,我使用以下内容: listView.setO
所以我决定试用新的 Volley library如 Google IO 2013 所示. 我尝试过使用 NetworkImageView 的简单解决方案在 GridView 上显示多个图像。 它运行良
我对这个出色的库怀念的是它不会在 NetworkImageView 中回收位图。如果在方法 NetworkImageView.onDetachedFromWindow 中某处调用回收将是完美的。目前,
有人知道是否可以使用 Google 的 Volley 库从单个 NetworkImageView 中清除缓存的图像吗? 我在 NetworkImageView 中有一张头像图片,我想在将其上传到服务器
我有一个 ListView 显示的东西,其中许多有说明性图像,有些没有。 ViewHolder 使用 NetworkImageView 来显示插图。 问题是即使设置了默认图像,它也不会显示,直到调用
我通过调用 setImageUrl 使用 Volley 的 NetworkImageView: mANetworkImageView.setImageUrl(url, getImageLoader()
我在尝试将 Volley 的 NetworkImageView 与 Google Maps API v2 的 InfoWindow 结合使用时遇到问题。 我的标记显示了一个信息窗口,其中包含从互联网上
我想从资源中设置 NetworkImageView 的图像。 我目前使用的配置是,如果有与内容关联的图片,则图片是从网络上下载的。如果没有图像,则使用预定义的资源。 final NetworkImag
我填充了一个 ListView,其中每行中的一项是 NetworkImageView。现在我通过 Intent putExtra() 将每一行传递给 detail_product Activity 。
我试图在我的应用程序中的 Volley 类的 NetworkImageView 中禁用缓存。我试过这段代码,但它没有删除缓存。 mNetworkImageView = (NetworkImageVie
我使用 Volley NetworkImageView 从互联网下载图像并显示在我的 listview 中。现在我想让 Volley NetworkImageView 在没有可用网络时显示保存的图像。
因此,我将 MVVM、数据绑定(bind)、RecyclerView 和 Volley ImageLoader 与 NetworkImageView 结合使用。 我主要是尝试显示包含 NetworkI
我有一个包含 NetworkImageView 项目的列表,我遇到了一个奇怪的错误。我希望能够使用滑动手势删除列表项,所以我使用了 EnhancedListView图书馆。问题是,当我使用滑动手势删除
我在我的项目中使用了 ViewPager,到目前为止,我发现 Volley 非常擅长为各个页面加载图像。 Volley 需要 com.android.volley.toolbox.NetworkIma
我在我的应用程序中使用 Facebook 照片。 Facebook 照片存储在 https 网址后面。 谁能给我一个使用 https 使用 networkimageview 加载图像的示例? 最佳答案
我是一名优秀的程序员,十分优秀!