summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/util/MultiMap.java
diff options
context:
space:
mode:
authorWilhelm Fitzpatrick <rafial@cyngn.com>2014-11-14 16:31:35 -0800
committerChippa-a <vusal1372@gmail.com>2019-10-25 15:55:25 +0300
commit84b2ffbcf4360332691379a7249a811d3e7c5bb0 (patch)
tree13e3808b2411f560a5c3291f6070f325f8993920 /src/com/android/camera/util/MultiMap.java
parent5c9ac149ede33a7999ad3a90ef76235ba77e8106 (diff)
downloadandroid_packages_apps_Snap-84b2ffbcf4360332691379a7249a811d3e7c5bb0.tar.gz
android_packages_apps_Snap-84b2ffbcf4360332691379a7249a811d3e7c5bb0.tar.bz2
android_packages_apps_Snap-84b2ffbcf4360332691379a7249a811d3e7c5bb0.zip
CameraNext: dynamically generate available photo resolutions
Instead of depending on a large matching table, generated the list of picture sizes to show to the user directly from the supported list returned by the camera. The list is filtered to remove uselessly small resolutions on modern devices, to group resolutions by aspect ratio, and to filter out fairly similar sizes. Change-Id: I47a67a89786543baec133cf7e71df9819793ebac Signed-off-by: Chippa-a <vusal1372@gmail.com>
Diffstat (limited to 'src/com/android/camera/util/MultiMap.java')
-rw-r--r--src/com/android/camera/util/MultiMap.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/com/android/camera/util/MultiMap.java b/src/com/android/camera/util/MultiMap.java
new file mode 100644
index 000000000..b2e9003fe
--- /dev/null
+++ b/src/com/android/camera/util/MultiMap.java
@@ -0,0 +1,45 @@
+package com.android.camera.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class MultiMap<K,V> {
+ Map<K,List<V>> map = new HashMap<K,List<V>>();
+
+ public void put(K key, V value) {
+ List<V> l = map.get(key);
+ if(l == null) {
+ l = new ArrayList<V>();
+ map.put(key, l);
+ }
+ l.add(value);
+ }
+
+ public List<V> get(K key) {
+ List<V> l = map.get(key);
+ if(l == null) { return Collections.emptyList(); }
+ else return l;
+ }
+
+ public List<V> remove(K key) {
+ List<V> l = map.remove(key);
+ if(l == null) { return Collections.emptyList(); }
+ else return l;
+ }
+
+ public Set<K> keySet() { return map.keySet(); }
+
+ public int size() {
+ int total = 0;
+ for(List<V> l : map.values()) {
+ total += l.size();
+ }
+ return total;
+ }
+
+ public boolean isEmpty() { return map.isEmpty(); }
+} \ No newline at end of file