Java Code Examples for java.util.LinkedHashMap#Entry
The following examples show how to use
java.util.LinkedHashMap#Entry .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CloudFlarePasser.java From Dashchan with Apache License 2.0 | 6 votes |
private void handleNextJavaScript() { handler.removeMessages(MESSAGE_HANDLE_NEXT_JAVASCRIPT); Iterator<LinkedHashMap.Entry<String, CloudFlareClient>> iterator = clientHandlers.entrySet().iterator(); CloudFlareClient client = null; if (iterator.hasNext()) { iterator.next(); iterator.remove(); if (iterator.hasNext()) { client = iterator.next().getValue(); } } if (client != null) { handleJavaScript(client); handler.sendEmptyMessageDelayed(MESSAGE_HANDLE_NEXT_JAVASCRIPT, WEB_VIEW_TIMEOUT); } }
Example 2
Source File: AboutFragment.java From Dashchan with Apache License 2.0 | 5 votes |
public RestoreFragment(LinkedHashMap<File, String> filesMap) { Bundle args = new Bundle(); ArrayList<String> files = new ArrayList<>(filesMap.size()); ArrayList<String> names = new ArrayList<>(filesMap.size()); for (LinkedHashMap.Entry<File, String> pair : filesMap.entrySet()) { files.add(pair.getKey().getAbsolutePath()); names.add(pair.getValue()); } args.putStringArrayList(EXTRA_FILES, files); args.putStringArrayList(EXTRA_NAMES, names); setArguments(args); }
Example 3
Source File: ExpandedScreen.java From Dashchan with Apache License 2.0 | 5 votes |
public void updatePaddings() { if (listView != null && (expandingEnabled || fullScreenLayoutEnabled)) { int actionBarHeight = obtainActionBarHeight(activity); int statusBarHeight = statusBar.getHeight(); int bottomNavigationBarHeight = navigationBar.getBottom(); int rightNavigationBarHeight = navigationBar.getRight(); setNewPadding((View) listView.getParent(), 0, 0, rightNavigationBarHeight, 0); setNewPadding(listView, KEEP, statusBarHeight + actionBarHeight, KEEP, bottomNavigationBarHeight); if (actionModeView != null) { ((ViewGroup.MarginLayoutParams) actionModeView.getLayoutParams()).rightMargin = rightNavigationBarHeight; } if (additionalViews != null) { for (LinkedHashMap.Entry<View, Boolean> additional : additionalViews.entrySet()) { additional.getKey().setPadding(0, statusBarHeight + (additional.getValue() ? actionBarHeight : 0), rightNavigationBarHeight, bottomNavigationBarHeight); } } if (drawerListView != null) { int paddingTop = C.API_LOLLIPOP && drawerOverToolbarEnabled && toolbarView != null ? statusBarHeight : statusBarHeight + actionBarHeight; if (drawerHeader != null) { setNewPadding(drawerHeader, KEEP, paddingTop, KEEP, KEEP); setNewPadding(drawerListView, KEEP, 0, KEEP, bottomNavigationBarHeight); } else { setNewPadding(drawerListView, KEEP, paddingTop, KEEP, bottomNavigationBarHeight); } } if (contentForeground != null) { contentForeground.invalidateSelf(); } if (statusBarContentForeground != null) { statusBarContentForeground.invalidateSelf(); } if (statusBarDrawerForeground != null) { statusBarDrawerForeground.invalidateSelf(); } } }
Example 4
Source File: ChanLocator.java From Dashchan with Apache License 2.0 | 5 votes |
public final ArrayList<String> getChanHosts(boolean confiruableOnly) { if (confiruableOnly) { ArrayList<String> hosts = new ArrayList<>(); for (LinkedHashMap.Entry<String, Integer> entry : this.hosts.entrySet()) { if (entry.getValue() == HOST_TYPE_CONFIGURABLE) { hosts.add(entry.getKey()); } } return hosts; } else { return new ArrayList<>(hosts.keySet()); } }
Example 5
Source File: ChanLocator.java From Dashchan with Apache License 2.0 | 5 votes |
public final String getPreferredHost() { String host = Preferences.getDomainUnhandled(getChanName()); if (StringUtils.isEmpty(host)) { for (LinkedHashMap.Entry<String, Integer> entry : hosts.entrySet()) { if (entry.getValue() == HOST_TYPE_CONFIGURABLE) { host = entry.getKey(); break; } } } return host; }
Example 6
Source File: CountingLruMap.java From fresco with MIT License | 5 votes |
/** Gets the all matching elements. */ public synchronized ArrayList<LinkedHashMap.Entry<K, V>> getMatchingEntries( @Nullable Predicate<K> predicate) { ArrayList<LinkedHashMap.Entry<K, V>> matchingEntries = new ArrayList<>(mMap.entrySet().size()); for (LinkedHashMap.Entry<K, V> entry : mMap.entrySet()) { if (predicate == null || predicate.apply(entry.getKey())) { matchingEntries.add(entry); } } return matchingEntries; }
Example 7
Source File: CountingLruMap.java From fresco with MIT License | 5 votes |
/** Removes all the matching elements from the map. */ public synchronized ArrayList<V> removeAll(@Nullable Predicate<K> predicate) { ArrayList<V> oldValues = new ArrayList<>(); Iterator<LinkedHashMap.Entry<K, V>> iterator = mMap.entrySet().iterator(); while (iterator.hasNext()) { LinkedHashMap.Entry<K, V> entry = iterator.next(); if (predicate == null || predicate.apply(entry.getKey())) { oldValues.add(entry.getValue()); mSizeInBytes -= getValueSizeInBytes(entry.getValue()); iterator.remove(); } } return oldValues; }
Example 8
Source File: CountingLruMapTest.java From fresco with MIT License | 5 votes |
@Test public void testGetMatchingEntries() { mCountingLruMap.put("key1", 110); mCountingLruMap.put("key2", 120); mCountingLruMap.put("key3", 130); mCountingLruMap.put("key4", 140); List<LinkedHashMap.Entry<String, Integer>> entries = mCountingLruMap.getMatchingEntries( new Predicate<String>() { @Override public boolean apply(String key) { return key.equals("key2") || key.equals("key3"); } }); assertNotNull(entries); assertEquals(2, entries.size()); assertEquals("key2", entries.get(0).getKey()); assertEquals(120, (int) entries.get(0).getValue()); assertEquals("key3", entries.get(1).getKey()); assertEquals(130, (int) entries.get(1).getValue()); // getting entries should not affect the order nor the size assertEquals(4, mCountingLruMap.getCount()); assertEquals(500, mCountingLruMap.getSizeInBytes()); assertKeyOrder("key1", "key2", "key3", "key4"); assertValueOrder(110, 120, 130, 140); }