Example usage for android.support.v4.util SimpleArrayMap get

List of usage examples for android.support.v4.util SimpleArrayMap get

Introduction

In this page you can find the example usage for android.support.v4.util SimpleArrayMap get.

Prototype

public V get(Object obj) 

Source Link

Usage

From source file:com.appsimobile.appsii.module.apps.AppPageLoader.java

/**
 * Helper method to add items to a list in a map that maps keys to lists.
 */// w ww.  jav  a  2s  .c o m
static <K, V> void addItemToMapList(SimpleArrayMap<K, List<V>> map, K key, V item) {
    List<V> list = map.get(key);
    if (list == null) {
        list = new ArrayList<>();
        map.put(key, list);
    }
    list.add(item);
}

From source file:jahirfiquitiva.iconshowcase.tasks.LoadAppsToRequest.java

private static void showDuplicatedComponentsInLog(ArrayList<String> components, Context context) {

    String[] componentsArray = new String[components.size()];
    componentsArray = components.toArray(componentsArray);

    SimpleArrayMap<String, Integer> occurrences = new SimpleArrayMap<>();

    int count = 0;

    for (String word : componentsArray) {
        count = occurrences.get(word) == null ? 0 : occurrences.get(word);
        occurrences.put(word, count + 1);
    }/*from w  ww.j a va 2s.co  m*/

    for (int i = 0; i < occurrences.size(); i++) {
        String word = occurrences.keyAt(i);
        if (count > 0) {
            Utils.showAppFilterLog(context,
                    "Duplicated component: \'" + word + "\' - " + String.valueOf(count) + " times.");
        }
    }

    Utils.showAppFilterLog(context, "----- END OF APPFILTER DEBUG -----");

}

From source file:com.facebook.litho.ComponentsStethoManagerImpl.java

private static void storeDrawable(StyleAccumulator accumulator, SimpleArrayMap<String, String> overrides,
        String key) {//  w  w  w.  j a  va2  s . c om
    if (overrides.containsKey(key)) {
        accumulator.store(key, overrides.get(key), false);
    } else {
        accumulator.store(key, "<drawable>", false);
    }
}

From source file:com.facebook.litho.ComponentsStethoManagerImpl.java

private static void storeFloat(StyleAccumulator accumulator, SimpleArrayMap<String, String> overrides,
        String key, float value) {
    if (overrides.containsKey(key)) {
        accumulator.store(key, overrides.get(key), false);
    } else {//w  ww . j a  v  a  2 s  .  c  o  m
        accumulator.store(key, Float.toString(value), false);
    }
}

From source file:com.facebook.litho.ComponentsStethoManagerImpl.java

private static void storeEnum(StyleAccumulator accumulator, SimpleArrayMap<String, String> overrides,
        String key, Object value) {
    if (overrides.containsKey(key)) {
        accumulator.store(key, overrides.get(key), false);
    } else {//from  w  w  w  . j  a  v  a2s. co  m
        accumulator.store(key, toCSSString(value), false);
    }
}

From source file:org.bubenheimer.android.preference.SharedPreferencesUtility.java

@UiThread
public static void unregisterOnSharedPreferenceChangeListener(@NonNull final Context context,
        @NonNull final SharedPreferences prefs, @NonNull final OnSharedPreferenceChangeListener listener,
        @StringRes final int... resIds) {
    final SimpleArrayMap<String, Pair<Integer, ? extends List<OnSharedPreferenceChangeListener>>> prefsEntry = masterMap
            .get(prefs);/*w  w w. j a v  a2  s. co m*/
    if (prefsEntry == null) {
        Log.w(TAG, "Shared preferences not registered: ", prefs);
        return;
    }
    final int cnt = resIds.length;
    //noinspection ForLoopReplaceableByForEach
    for (int i = 0; i < cnt; ++i) {
        final int resId = resIds[i];
        final String key = context.getString(resId);
        final Pair<Integer, ? extends List<OnSharedPreferenceChangeListener>> pair = prefsEntry.get(key);
        if (pair == null) {
            Log.w(TAG, "Shared preference not registered: ", key, " - ", prefs);
            return;
        }
        final List<OnSharedPreferenceChangeListener> list = pair.second;
        if (!list.remove(listener)) {
            Log.w(TAG, "Listener not registered: ", key, " - ", prefs);
            return;
        }
        if (list.isEmpty()) {
            prefsEntry.remove(key);
        }
    }
    if (prefsEntry.isEmpty()) {
        masterMap.remove(prefs);
        prefs.unregisterOnSharedPreferenceChangeListener(masterListener);
    }
}

From source file:com.facebook.litho.ComponentsStethoManagerImpl.java

private static void storeYogaValue(StyleAccumulator accumulator, SimpleArrayMap<String, String> overrides,
        String key, YogaValue value) {
    if (overrides.containsKey(key)) {
        accumulator.store(key, overrides.get(key), false);
    } else {/*from  w  ww .j  a  v a 2s .  c  o  m*/
        final String valueString;
        switch (value.unit) {
        case UNDEFINED:
            valueString = "undefined";
            break;
        case POINT:
            valueString = Float.toString(value.value);
            break;
        case PERCENT:
            valueString = value.value + "%";
            break;
        case AUTO:
            valueString = "auto";
            break;
        default:
            throw new IllegalStateException();
        }
        accumulator.store(key, valueString, false);
    }
}

From source file:com.appsimobile.appsii.SimpleJson.java

@Nullable
static SimpleJson getChild(@NonNull SimpleJson parent, String segment) {
    JSONObject object = parent.mJsonObject;
    SimpleArrayMap<String, SimpleJson> map = parent.mParsedChildren;

    if (map == null) {
        JSONObject obj = object.optJSONObject(segment);
        if (obj == null)
            return null;

        parent.mParsedChildren = new SimpleArrayMap<>();
        map = parent.mParsedChildren;//ww  w.  java  2  s.  c om

        map.put(segment, new SimpleJson(obj));
    }

    SimpleJson result;
    if (map.containsKey(segment)) {
        result = map.get(segment);
    } else {
        JSONObject obj = object.optJSONObject(segment);
        if (obj == null)
            return null;

        result = new SimpleJson(obj);
        map.put(segment, result);
    }

    return result;
}

From source file:org.bubenheimer.android.preference.SharedPreferencesUtility.java

@UiThread
public static void registerOnSharedPreferenceChangeListener(@NonNull final Context context,
        @NonNull final SharedPreferences prefs, @NonNull final OnSharedPreferenceChangeListener listener,
        @StringRes final int... resIds) {
    SimpleArrayMap<String, Pair<Integer, ? extends List<OnSharedPreferenceChangeListener>>> prefsEntry = masterMap
            .get(prefs);/*from  www .  ja v a2  s.c o  m*/
    if (prefsEntry == null) {
        prefsEntry = new SimpleArrayMap<>();
        masterMap.put(prefs, prefsEntry);
        prefs.registerOnSharedPreferenceChangeListener(masterListener);
    }
    final int cnt = resIds.length;
    //noinspection ForLoopReplaceableByForEach
    for (int i = 0; i < cnt; ++i) {
        final int resId = resIds[i];
        final String key = context.getString(resId);
        Pair<Integer, ? extends List<OnSharedPreferenceChangeListener>> pair = prefsEntry.get(key);
        if (pair == null) {
            pair = Pair.create(resId, new ArrayList<OnSharedPreferenceChangeListener>());
            prefsEntry.put(key, pair);
        }
        pair.second.add(listener);
    }
}

From source file:com.google.android.gcm.demo.logic.quicktest.GetTokenQuickTest.java

@Override
public void execute(Logger logger, Context context, SimpleArrayMap<Integer, String> params) {
    final String senderId = params.get(R.id.home_sender_id);

    InstanceIdHelper instanceIdHelper = new InstanceIdHelper(context);
    instanceIdHelper.getTokenInBackground(senderId, "GCM", null);
}