private static boolean qualifies(Bitmap candidate, BitmapFactory.Options targetOptions) {
    if (!candidate.isMutable()) {
      return false;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      int width = targetOptions.outWidth / targetOptions.inSampleSize;
      int height = targetOptions.outHeight / targetOptions.inSampleSize;
      int byteCount = width * height * getBytesPerPixel(candidate.getConfig());
      return byteCount <= candidate.getAllocationByteCount();
    }
    return candidate.getWidth() == targetOptions.outWidth
        && candidate.getHeight() == targetOptions.outHeight
        && targetOptions.inSampleSize == 1;
  }
Implementation of LRU cache (String to Bitmap) with a method to grab the oldest Bitmap.
tileview/src/main/java/com/moagrius/tileview/MemoryCache.java