Android Open Source - DroidDesignGuide Content Cache






From Project

Back to project page DroidDesignGuide.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project DroidDesignGuide listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * Copyright (c) 2012 Acrylic Goat Software
 * // ww  w  . j  a  v  a 2s. c o  m
 * This software is subject to the provisions of the GNU Lesser General
 * Public License Version 3 (LGPL).  See LICENSE.txt for details.
 */
package com.acrylicgoat.droiddesign.util;

import java.util.HashMap;

public class ContentCache
{
    /**
     * HashMap to hold objects
     */
    private static HashMap<String,Object> objMap = new HashMap<String,Object>();
    
    /**
     * Access item for the given key.
     * Removes item from map if it is found.
     * @param key - String key for object
     * @return Object
     */
    public static Object getObject(String key)
    {
        Object o = objMap.get(key);
        objMap.remove(key);
        return o;
    }
    
    /**
     * Set item using the given key
     * @param key - String key for object
     * @param obj - te object to cache
     */
    public static void setObject(String key, Object obj)
    {
        objMap.put(key, obj);
    }
    
    /**
     * Removes object with the given key if the key exists
     * @param key String - the key of the object to remove
     */
    public static void removeObject(String key)
    {
        if(objMap.containsKey(key))
        {
            objMap.remove(key);
        }
    }

}




Java Source Code List

com.acrylicgoat.droiddesign.activity.DDGViewActivity.java
com.acrylicgoat.droiddesign.activity.MainActivity.java
com.acrylicgoat.droiddesign.activity.SublistActivity.java
com.acrylicgoat.droiddesign.adapters.LandscapeListAdapter.java
com.acrylicgoat.droiddesign.adapters.ListAdapter.java
com.acrylicgoat.droiddesign.fragments.DDGListFragment.java
com.acrylicgoat.droiddesign.fragments.DDGViewFragment.java
com.acrylicgoat.droiddesign.util.ContentCache.java
com.acrylicgoat.droiddesign.util.DDGUtil.java