List of usage examples for android.support.v4.util SimpleArrayMap put
public V put(K k, V v)
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. *///from ww w. j ava 2 s. c om 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: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;// w w w. j a v a 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: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 v a 2 s .c o 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: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 w w w .j a v a2s . com*/ 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.bmd.android.collection.example.EnhancedArrayMapTest.java
public void testEquals() { assertThat(mArray).isEqualTo(mArray); assertThat(mArray.equals(mArray)).isTrue(); final EnhancedArrayMap<Integer, String> array = new EnhancedArrayMap<Integer, String>(); for (int i = 0; i < 5; i++) { array.put(i, String.valueOf(i)); }/*from w ww . j a v a2s . co m*/ assertThat(mArray).isEqualTo(array); assertThat(array).isEqualTo(mArray); assertThat(mArray.equals(array)).isTrue(); assertThat(array.equals(mArray)).isTrue(); final SimpleArrayMap<Integer, String> simpleArray = new SimpleArrayMap<Integer, String>(); for (int i = 0; i < 5; i++) { simpleArray.put(i, String.valueOf(i)); } assertThat(mArray.equals(simpleArray)).isTrue(); assertThat(simpleArray.equals(mArray)).isFalse(); }
From source file:android.databinding.testapp.ObservableArrayMapTest.java
public void testPutAllSimpleArrayMap() { SimpleArrayMap<String, String> toAdd = new ArrayMap<>(); toAdd.put("Hello", "World"); toAdd.put("Goodbye", "Cruel World"); mObservable.put("Cruel", "World"); mObservable.addOnMapChangedCallback(mListener); mObservable.putAll(toAdd);//from w w w . j av a 2 s. c o m assertEquals(3, mObservable.size()); assertEquals("World", mObservable.get("Hello")); assertEquals("Cruel World", mObservable.get("Goodbye")); assertEquals(2, mNotifications.size()); // order is not guaranteed assertTrue(mNotifications.contains("Hello")); assertTrue(mNotifications.contains("Goodbye")); }
From source file:com.google.android.gcm.demo.ui.HomeFragment.java
private void doExecuteSelectedTest() { QuickTest test = mQuickTests.get(getValue(R.id.home_quick_test)); SimpleArrayMap<Integer, String> params = new SimpleArrayMap<>(); for (Integer paramsId : test.getRequiredParameters()) { params.put(paramsId, getValue(paramsId)); }//from w w w . j ava 2 s. co m test.execute(mLogger, getActivity(), params); }
From source file:codetoanalyze.java.checkers.ContainerWrapper.java
public void addToSimpleArrayMapBad(SimpleArrayMap<Integer, Integer> map) { map.put(1, 1); }
From source file:net.simno.klingar.data.repository.MusicRepositoryImpl.java
private Single<SimpleArrayMap<Integer, PlexItem>> browseHeaders(MediaType mt) { return media.firstCharacter(mt.uri(), mt.libraryKey(), mt.mediaKey()).flatMap(DIRS).toList().map(dirs -> { SimpleArrayMap<Integer, PlexItem> headers = new SimpleArrayMap<>(); int offset = 0; for (int i = 0; i < dirs.size(); ++i) { headers.put(offset, Header.builder().title(dirs.get(i).title).build()); offset += dirs.get(i).size;/*w ww. j av a2s .c o m*/ } return headers; }); }
From source file:com.appsimobile.appsii.module.apps.AppPageData.java
AppPageData(@Nullable List<? extends AppEntry> allApps, List<HistoryItem> recentApps, List<AppTag> tags) { mAllApps = new ArrayList<>(); if (allApps != null) { mAllApps.addAll(allApps);//w ww .ja v a 2s . c om } mRecentApps = recentApps; mAppTags = tags; SimpleArrayMap<ComponentName, AppEntry> appEntriesByComponent; if (allApps != null) { int N = allApps.size(); appEntriesByComponent = new SimpleArrayMap<>(N); for (int i = 0; i < N; i++) { AppEntry app = allApps.get(i); appEntriesByComponent.put(app.getComponentName(), app); } } else { appEntriesByComponent = new SimpleArrayMap<>(0); } long recentAppsTagId = recentAppsTagId(tags); long allAppsTagId = allAppsTagId(tags); mAppsPerTag.put(allAppsTagId, mAllApps); List<AppEntry> recentAppEntries = new ArrayList<>(recentApps.size()); for (int i = 0; i < recentApps.size(); i++) { HistoryItem item = recentApps.get(i); AppEntry e = appEntriesByComponent.get(item.componentName); if (e != null) { recentAppEntries.add(e); } } mAppsPerTag.put(recentAppsTagId, recentAppEntries); }