Code example for WeakHashMap

Methods: get, put

0
         * @param file The name of the type face asset. 
         * @param context The {@link Context} to use. 
         * @return A new type face. 
         */ 
        public Typeface getTypeface(final String file, final Context context) {
            Typeface result = MAP.get(file);
            if (result == null) {
                result = Typeface.createFromAsset(context.getAssets(), file);
                MAP.put(file, result);
            } 
            return result;
        } 
    } 
}