Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.lang.ref.SoftReference;

import java.util.WeakHashMap;

import android.content.Context;

import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;

public class Main {
    private static WeakHashMap<String, SoftReference<BitmapDrawable>> mCache = new WeakHashMap<String, SoftReference<BitmapDrawable>>();

    public static BitmapDrawable getBitmapDrawableFromCache(Context context, Uri uri) {
        String path = uri.getPath();
        if (mCache.containsKey(path)) {
            BitmapDrawable d = mCache.get(path).get();
            if (d != null) {
                System.out.println("getBitmapDrawableFromCache path = " + path);
                return d;
            }
        }
        return null;
    }
}