English 中文(简体)
可在Aston Downloader上班:SHardBitmapCache NOT在何时静态? [闭门]
原标题:Possible BUG in Android ImageDownloader class : sHardBitmapCache NOT static when it should be? [closed]

我尽量了解安乐斯的发展,并特别注重业绩,因为今天在“游戏仓库”中有许多人 app。 我发现/认为许多文章/录像。

一篇关于图像剪辑的具体文章是:

提交人的代码如下:

Which Google seemed to take a version of into and put into their sample classes at: http://developer.android.com/resources/samples/XmlAdapters/src/com/example/android/xmladapters/ImageDownloader.html

总的来说,这固然是可靠的,但我认为这在ach中是一种缺陷。 它使用软的/硬的海滩,将事情带进/带入硬的海滩,因为安乐系统经常使用软的切身。

Looking at the code though, one starts to wonder if the hard cache would get accidentally reset every time the parent class is instantiated.

第一,软滩:

    // Soft cache for bitmaps kicked out of hard cache
    private final static ConcurrentHashMap<String, SoftReference<Bitmap>> sSoftBitmapCache =
        new ConcurrentHashMap<String, SoftReference<Bitmap>>(HARD_CACHE_CAPACITY / 2);

现在看看着困难的海滩:

    // Hard cache, with a fixed maximum capacity and a life duration
    private final HashMap<String, Bitmap> sHardBitmapCache =
        new LinkedHashMap<String, Bitmap>(HARD_CACHE_CAPACITY / 2, 0.75f, true) {
        @Override
        protected boolean removeEldestEntry(LinkedHashMap.Entry<String, Bitmap> eldest) {
            if (size() > HARD_CACHE_CAPACITY) {
                // Entries push-out of hard reference cache are transferred to soft reference cache
                sSoftBitmapCache.put(eldest.getKey(), new SoftReference<Bitmap>(eldest.getValue()));
                return true;
            } else
                return false;
        }
    };

<hard cache,notstatic,而软切身为静态。 因此,在班级的生下,硬ache子和物品已经清除。

我认为,这确实是,我用一份清单来注意到我的申请,每次都下载图像,永远不会打断。 这一切都是同步进行的,但每次仍打着网。 页: 1

www.un.org/spanish/ecosoc 加上静态关键词确定了这个问题,而我的申请则更有成效。

我不敢肯定,为什么情况如此,因为正如以下例子所示,在我的适应者中,只有一例图像Downloader级:

private final ImageDownloader imageDownloader = new ImageDownloader();

问题

既然如此,是否有其他人经历过吗? 或者,我是一夫一妻。 我不是Java/Android/JVM/Dalvik/WeakReference/SoftReference专家,但有些专家似乎不喜欢。 我不知道为什么<代码>sHardBitmapCache不是静态的,但当我提出修改意见时,我停止对网站进行如此大的点击(节省数据费用/排水/改进性能)

最佳回答

你是正确的,这是我的一个典型。

我已将该代码固定在 and树中。 感谢这些反馈。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签