fixed cache key generation for messages w/o full jid

This commit is contained in:
Daniel Gultsch 2018-03-22 15:10:29 +01:00
parent dccd3f1c8e
commit 255dd9674e
1 changed files with 26 additions and 8 deletions

View File

@ -8,6 +8,7 @@ import android.graphics.PorterDuffXfermode;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.net.Uri; import android.net.Uri;
import android.support.annotation.Nullable;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.util.LruCache; import android.util.LruCache;
@ -141,8 +142,13 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
this.sizes.add(size); this.sizes.add(size);
} }
} }
return PREFIX_CONTACT + "_" + contact.getAccount().getJid().asBareJid() + "_" return PREFIX_CONTACT +
+ contact.getJid() + "_" + String.valueOf(size); '\0' +
contact.getAccount().getJid().asBareJid() +
'\0' +
emptyOnNull(contact.getJid()) +
'\0' +
size;
} }
private String key(MucOptions.User user, int size) { private String key(MucOptions.User user, int size) {
@ -151,8 +157,15 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
this.sizes.add(size); this.sizes.add(size);
} }
} }
return PREFIX_CONTACT + "_" + user.getAccount().getJid().asBareJid() + "_" return PREFIX_CONTACT +
+ user.getFullJid() + "_" + String.valueOf(size); '\0' +
user.getAccount().getJid().asBareJid() +
'\0' +
emptyOnNull(user.getFullJid()) +
'\0' +
emptyOnNull(user.getRealJid()) +
'\0' +
size;
} }
public Bitmap get(ListItem item, int size) { public Bitmap get(ListItem item, int size) {
@ -294,10 +307,12 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
for(MucOptions.User user : users) { for(MucOptions.User user : users) {
builder.append("\0"); builder.append("\0");
builder.append(user.getRealJid() == null ? "" : user.getRealJid().asBareJid().toString()); builder.append(emptyOnNull(user.getRealJid()));
builder.append("\0"); builder.append("\0");
builder.append(user.getFullJid() == null ? "" : user.getFullJid().toString()); builder.append(emptyOnNull(user.getFullJid()));
} }
builder.append('\0');
builder.append(size);
final String key = builder.toString(); final String key = builder.toString();
synchronized (this.conversationDependentKeys) { synchronized (this.conversationDependentKeys) {
Set<String> keys; Set<String> keys;
@ -437,8 +452,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
return true; return true;
} }
private boolean drawTile(Canvas canvas, MucOptions.User user, int left, private boolean drawTile(Canvas canvas, MucOptions.User user, int left, int top, int right, int bottom) {
int top, int right, int bottom) {
Contact contact = user.getContact(); Contact contact = user.getContact();
if (contact != null) { if (contact != null) {
Uri uri = null; Uri uri = null;
@ -528,4 +542,8 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
} }
} }
} }
private static String emptyOnNull(@Nullable Jid value) {
return value == null ? "" : value.toString();
}
} }