summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/util
diff options
context:
space:
mode:
authorWilhelm Fitzpatrick <rafial@cyngn.com>2014-11-14 16:31:35 -0800
committerMichael Bestas <mikeioannina@gmail.com>2017-01-04 22:00:34 +0200
commit7b7c3f3c08b733fdc09f166ec864c5c22aee2db3 (patch)
tree31a375011eac5cd743677b4f967292019d77afab /src/com/android/camera/util
parentbf686cbf2fce8382eff5f15bfb968e189259c81c (diff)
downloadandroid_packages_apps_Snap-7b7c3f3c08b733fdc09f166ec864c5c22aee2db3.tar.gz
android_packages_apps_Snap-7b7c3f3c08b733fdc09f166ec864c5c22aee2db3.tar.bz2
android_packages_apps_Snap-7b7c3f3c08b733fdc09f166ec864c5c22aee2db3.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
Diffstat (limited to 'src/com/android/camera/util')
-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