aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/persistance
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-05-09 21:47:50 +0200
committerChristian Schneppe <christian@pix-art.de>2019-05-18 00:01:57 +0200
commit294144943429503f62675d23b9911d43c0f41ce3 (patch)
tree6ca73458e72a8afe0a148f8971726eeb7311ea71 /src/main/java/de/pixart/messenger/persistance
parent5b75d52d444d6cda368e85f5884163e229451ece (diff)
performance improvements
Diffstat (limited to 'src/main/java/de/pixart/messenger/persistance')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java4
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java13
2 files changed, 12 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
index 6fc6d7569..3bf332c92 100644
--- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
@@ -1097,13 +1097,15 @@ public class DatabaseBackend extends SQLiteOpenHelper {
}
public void expireOldMessages(long timestamp) {
+ long start = SystemClock.elapsedRealtime();
final String[] args = {String.valueOf(timestamp)};
SQLiteDatabase db = this.getReadableDatabase();
db.beginTransaction();
db.delete("messages_index", "uuid in (select uuid from messages where timeSent<?)", args);
- db.delete(Message.TABLENAME, "timeSent<?", args);
+ int num = db.delete(Message.TABLENAME, "timeSent<?", args);
db.setTransactionSuccessful();
db.endTransaction();
+ Log.d(Config.LOGTAG, "deleted " + num + " expired messages in " + (SystemClock.elapsedRealtime() - start) + "ms");
}
public MamReference getLastMessageReceived(Account account) {
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
index 3eaa9e406..33a524894 100644
--- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
@@ -589,12 +589,17 @@ public class FileBackend {
}
public Bitmap getThumbnail(Message message, int size, boolean cacheOnly) throws IOException {
- final String uuid = message.getUuid();
+ // The key for getting a cached thumbnail contains the UUID and the size
+ // since this method is used for thumbnails of (bigger) normal image messages and (smaller) image message references.
+ // If only the UUID were used, the first loaded thumbnail would be cached and the next loading
+ // would get that thumbnail which would have the size of the first cached thumbnail
+ // possibly leading to undesirable appearance of the displayed thumbnail.
+ final String key = message.getUuid() + String.valueOf(size);final String uuid = message.getUuid();
final LruCache<String, Bitmap> cache = mXmppConnectionService.getBitmapCache();
- Bitmap thumbnail = cache.get(uuid);
+ Bitmap thumbnail = cache.get(key );
if ((thumbnail == null) && (!cacheOnly)) {
synchronized (THUMBNAIL_LOCK) {
- thumbnail = cache.get(uuid);
+ thumbnail = cache.get(key );
if (thumbnail != null) {
return thumbnail;
}
@@ -616,7 +621,7 @@ public class FileBackend {
thumbnail = withGifOverlay;
}
}
- cache.put(uuid, thumbnail);
+ cache.put(key , thumbnail);
}
}
return thumbnail;