package com.example.android.navigationdrawer;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import java.util.Locale;

public class PlanetBitmap {

  private Activity activity;

  public PlanetBitmap(Activity activity) {
    this.activity = activity;
  }

  public Bitmap getBitmap(String planet) {
    int imageId = activity.getResources().getIdentifier(planet.toLowerCase(Locale.getDefault()),
        "drawable", activity.getPackageName());

    return BitmapFactory.decodeResource(activity.getResources(), imageId);
  }
}

@@ -162,45 +162,169 @@
 til.
-Locale;%0A%0Apublic class PlanetBitmap %7B%0A
+HashMap;%0Aimport java.util.Locale;%0Aimport java.util.Map;%0A%0Apublic class PlanetBitmap %7B%0A%0A  private static Map%3CString, Bitmap%3E cache = new HashMap%3CString, Bitmap%3E();
 %0A  p
@@ -467,24 +467,103 @@
 g planet) %7B%0A
+    Bitmap bitmap = cache.get(planet);%0A    if (bitmap != null) return bitmap;%0A%0A
     int imag
@@ -700,22 +700,111 @@
 );%0A%0A    
-return
+try %7B%0A      Thread.sleep(500);%0A    %7D catch (InterruptedException ignored) %7B%0A    %7D%0A%0A    bitmap =
  BitmapF
@@ -860,14 +860,64 @@
 ageId);%0A
+    cache.put(planet, bitmap);%0A    return bitmap;%0A
   %7D%0A%7D%0A

Implement caching of bitmaps