Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.HashMap;
import java.util.Map;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class Main {
    private static final Map<Integer, Bitmap> BITMAP_CACHE = new HashMap();

    public static Bitmap decodeResourcesBitmap(Context context, int res) {
        boolean bool = BITMAP_CACHE.containsKey(Integer.valueOf(res));
        Bitmap localBitmap = null;
        if (bool) {
            localBitmap = (Bitmap) BITMAP_CACHE.get(Integer.valueOf(res));
        }
        if ((localBitmap == null) || (localBitmap.isRecycled())) {
            localBitmap = BitmapFactory.decodeStream(context.getResources().openRawResource(res));
            BITMAP_CACHE.put(Integer.valueOf(res), localBitmap);
        }
        return localBitmap;
    }
}