问题标签 [android-lru-cache]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
android - Android: LruCache issue with Bitmap
I have a global bitmap cache using LruCache class. when loading thumbnails for the listview, the cache is used first. It works just OK.
But one issue is: sometimes the Bitmap instance from the cache cannot be displayed on the listview. it seems such bitmap from cache is not valid any more. I have checked the bitmap from cache if it is not null and if it is not recycled, but it still seems such bitmap cannot be displayed (even it is not null and it is not recycled).
The cache class:
and the code to use the cache is in the Adapter class which is subclass of CursorAdapter:
the code of DownloadImageTask:
any help will be appreciated. Thanks!
Updates: I have followed the link suggested by greywolf82: section "Handle Configuration Changes". I put the following attribute in my activity class and the two fragment classes:
public LruCache mMemoryCache;
In the activity class, I try to initialize the cache when calling the fragment:
in the fragment class: setRetainInstance(true);
and I pass the cache instance to the adapter constructor so that the adapter can use the cache.
but I still got the same issue.
Update 2:
the two adapter classes with changes to accept the LruCache instance:
NewsCursorAdapter:
the list adapter, NewsTopicItemAdapter:
Update 3: I have attached the debug information from eclipse: the 1st picture is the working bitmap, and the 2nd one is the non-working bitmap from cache. I didn't find anything suspicious.
The debug information of the working bitmap from the cache:
The debug information of the non-working bitmap from the cache:
android - android LruCache 真机
我正在尝试使用 RestFull Web 服务创建 android 应用程序,并在使用和使用 Lrucahe 保存图像时完成所有应用程序工作,但是当在真实设备上安装应用程序时抛出异常:java.lang.noclassdeffounderror android.util.lrucache 我的设备目标是 2.3 .6
android - LruCache 为指定的键返回错误的位图
我对 Android 开发非常陌生。
我遇到了从 LruBitmapCache 获取正确位图的问题。我使用 UUID 生成唯一 ID,我不使用 URL,因为我在画布上生成位图。(我getDrawingCache()
从我的视图复制到一个新的位图(使用副本),然后将副本存储到缓存中)。
出于某种原因,在我存储位图后,当我访问它时,它最终成为另一个 id 的位图......有时会发生这种情况。有任何想法吗?
我使用 currentIndex 来跟踪我在 cachedKeys 数组中的位置(我想按顺序保存并浏览画布上的 bitamp)。我想我正在更新缓存中的条目错误...
android - 从活动的上下文中初始化 ImageCache
我试图理解这个样本与我的匹配:(DisplayingBitmaps)
http://developer.android.com/downloads/samples/DisplayingBitmaps.zip
此代码使用管理位图缓存的类 ImageCache:
}
在示例中,缓存 (LRUCache) 使用片段 (ImageGridFragment) 中的以下代码进行初始化:
ImageWorker 使用片段上下文初始化 ImageCache 中的缓存的方法:
如何使用此类从活动上下文中“实例化”和初始化 cahe?
谢谢
android - 是否可以更改毕加索用于图像的缓存大小?
我正在使用 Picasso 从 URL (http://) 加载图像。有时当我尝试使用毕加索的fetch()
方法“预加载”图像时,图像不会被缓存。我猜是因为它的尺寸太大了。
阅读这个问题的答案,但setCache()
我似乎无法识别,我什至在毕加索文档中都找不到。
有没有办法改变毕加索用于位图的缓存大小?
android - 如何使用 RoboSpice 缓存类型
注意:这是 Android 缓存机制新手的一般问题。
为什么 RS 在FlickrSpiceService示例中使用 LRU 缓存?
有LruCacheBitmapObjectPersister
:
为什么不删除它并InFileBitmapObjectPersister
像这样使用:
android - 使用 Volley 和 ListView 的磁盘缓存真的很慢
我正在尝试将此库https://github.com/JakeWharton/DiskLruCache用于磁盘缓存,但是当我的 ListView 中有很多图像时我遇到了问题。滞后有时真的很糟糕。
我使用了以下 GitHub 存储库中的方法:https ://github.com/rdrobinson3/VolleyImageCacheExample
问题是对于更大的图像,有很大的滞后,没有很好的滚动体验。
我该如何改进这种方法?
我可以public Bitmap putBitmap( String key )
将位图保存在后台线程中,但存在public Bitmap getBitmap( String key )
无法在后台线程中完成的问题。
谢谢你。
android - 实现 LruCache 以缓存位图图像
在我的应用程序中,我正在从 Internet 获取提要。feed 包含一些文本信息和图像。我必须将图像存储在LruCache中,因为我参考了Google 开发者网站并按照那里所示的方式实现。这个实现工作正常。但由于我的应用程序支持 api 级别 10,它显示一些错误分配缓存大小,我无法声明缓存正弦的大小我正在使用 bitmap.getByteCount() 它显示添加@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
符号,并且当我在 android 2.3 中打开应用程序时应用程序停止回应
代码
我如何也支持 api 级别 10,有什么办法吗?
java - 获取 LRUCache Android 中使用的当前内存
为了测试,我想查看我的 LRU 缓存中当前使用了多少 kB / MB。我将总大小设置为 4096。
有没有这样的功能:
或者