This is a part of a cache system in Android. As normal it tries to get Bitmap from memory cache and if result is null, tries disk cache and if find related Bitmap, add it to memory cache:
public Bitmap getBitmap(String key) {
Bitmap rendered = memoryCache.get ( key );
if (rendered == null) {
rendered = diskCache.getBitmap ( key );
if (rendered != null) {
memoryCache.add ( key, rendered );
}
}
return rendered;
}
So when memoryCache.get ( key ) is not null, the outer if and its nested if must not execute. But when I suddenly put a breakpoint, saw memoryCache.add ( key, rendered ); line was executed even when rendered was set by memoryCache.get ( key ), although rendered = diskCache.getBitmap ( key ); line was not executed. Am I mistaking or doing some things wrong?
Aucun commentaire:
Enregistrer un commentaire