Code example for Map

Methods: put

0
import java.util.Map; 
 
public final class DrawableCompat { 
    private static final Map<String, Class<? extends Drawable>> CLASS_MAP = new HashMap<String, Class<? extends Drawable>>();
    private static final LongSparseArray<WeakReference<Drawable.ConstantState>> sDrawableCache = new LongSparseArray<WeakReference<Drawable.ConstantState>>();
 
    static { 
        registerDrawable(RotateDrawable.class, "rotate");
        registerDrawable(LayerDrawable.class, "layer-list");
        registerDrawable(StateListDrawable.class, "selector");
        registerDrawable(ColorDrawable.class, "color");
    } 
 
    private DrawableCompat() { 
    } 
 
    public static void registerDrawable(Class<? extends Drawable> clazz, String name) {
        if (name == null || clazz == null) {
            throw new NullPointerException("Class: " + clazz + ". Name: " + name);
        } 
        CLASS_MAP.put(name, clazz);