~singpolyma/cheogram-android

1b01881ff94d117ce2ec03ddfe565f924092eea4 — Stephen Paul Weber 10 months ago 466cbac
Fix NPE
M src/main/java/eu/siacs/conversations/persistance/FileBackend.java => src/main/java/eu/siacs/conversations/persistance/FileBackend.java +3 -2
@@ 1755,7 1755,8 @@ public class FileBackend {
                return null;
            }
        } else {
            return new BitmapDrawable(cropCenterSquare(image, size));
            Bitmap bitmap = cropCenterSquare(image, size);
            return bitmap == null ? null : new BitmapDrawable(bitmap);
        }
    }



@@ 2091,7 2092,7 @@ public class FileBackend {
            }
        } else {
            Bitmap bm = cropCenter(getAvatarUri(avatar), size, size);
            return new BitmapDrawable(bm);
            return bm == null ? null : new BitmapDrawable(bm);
        }
    }


M src/main/java/eu/siacs/conversations/services/AvatarService.java => src/main/java/eu/siacs/conversations/services/AvatarService.java +1 -1
@@ 121,7 121,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
		if (avatar == null) {
			avatar = get(contact.getDisplayName(), contact.getJid().asBareJid().toString(), size, false);
		}
		this.mXmppConnectionService.getDrawableCache().put(KEY, avatar);
		if (avatar != null) this.mXmppConnectionService.getDrawableCache().put(KEY, avatar);
		return avatar;
	}


M src/main/java/eu/siacs/conversations/services/XmppConnectionService.java => src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +4 -1
@@ 1268,7 1268,10 @@ public class XmppConnectionService extends Service {
            @Override
            protected int sizeOf(final String key, final Drawable drawable) {
                if (drawable instanceof BitmapDrawable) {
                    return ((BitmapDrawable) drawable).getBitmap().getByteCount() / 1024;
                    Bitmap bitmap =  ((BitmapDrawable) drawable).getBitmap();
                    if (bitmap == null) return 1024;

                    return bitmap.getByteCount() / 1024;
                } else {
                    return drawable.getIntrinsicWidth() * drawable.getIntrinsicHeight() * 40 / 1024;
                }