aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main
diff options
context:
space:
mode:
authormar-v-in <github@rvin.mooo.com>2014-08-01 12:24:26 +0200
committermar-v-in <github@rvin.mooo.com>2014-08-01 12:24:26 +0200
commit1ebb92b33638e427befa37fd2b6eef67ed3e4b88 (patch)
treefeb979caac2fcf24ed87d6dcb2aa793eb777fa1e /OpenKeychain/src/main
parent3a13cd5e4deebe283f8bfbc5122951e0a77b339d (diff)
downloadopen-keychain-1ebb92b33638e427befa37fd2b6eef67ed3e4b88.tar.gz
open-keychain-1ebb92b33638e427befa37fd2b6eef67ed3e4b88.tar.bz2
open-keychain-1ebb92b33638e427befa37fd2b6eef67ed3e4b88.zip
Cache contact photos to make UI more fluid
Diffstat (limited to 'OpenKeychain/src/main')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java
index 5d1bd1bb5..8fed40a86 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/helper/ContactHelper.java
@@ -63,6 +63,8 @@ public class ContactHelper {
ContactsContract.Data.RAW_CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "=?";
public static final String ID_SELECTION = ContactsContract.RawContacts._ID + "=?";
+ private static final Map<String, Bitmap> photoCache = new HashMap<String, Bitmap>();
+
public static List<String> getPossibleUserEmails(Context context) {
Set<String> accountMails = getAccountEmails(context);
accountMails.addAll(getMainProfileContactEmails(context));
@@ -237,6 +239,14 @@ public class ContactHelper {
public static Bitmap photoFromFingerprint(ContentResolver contentResolver, String fingerprint) {
if (fingerprint == null) return null;
+ if (!photoCache.containsKey(fingerprint)) {
+ photoCache.put(fingerprint, loadPhotoFromFingerprint(contentResolver, fingerprint));
+ }
+ return photoCache.get(fingerprint);
+ }
+
+ private static Bitmap loadPhotoFromFingerprint(ContentResolver contentResolver, String fingerprint) {
+ if (fingerprint == null) return null;
try {
int rawContactId = findRawContactId(contentResolver, fingerprint);
if (rawContactId == -1) return null;