notifications: fix Kotlin null-safety in resolveInlineImage (?.takeIf on nullable receivers)
This commit is contained in:
@@ -698,8 +698,8 @@ class MatrixSyncService : Service() {
|
|||||||
): Bitmap? {
|
): Bitmap? {
|
||||||
val info = content.optJSONObject("info")
|
val info = content.optJSONObject("info")
|
||||||
val thumbnailMxc =
|
val thumbnailMxc =
|
||||||
info?.optString("thumbnail_url").takeIf { it.startsWith("mxc://") }
|
info?.optString("thumbnail_url")?.takeIf { it.startsWith("mxc://") }
|
||||||
?: info?.optJSONObject("thumbnail_file")?.optString("url").takeIf { it.startsWith("mxc://") }
|
?: info?.optJSONObject("thumbnail_file")?.optString("url")?.takeIf { it.startsWith("mxc://") }
|
||||||
if (thumbnailMxc != null) {
|
if (thumbnailMxc != null) {
|
||||||
for (url in mxcToThumbnailUrls(thumbnailMxc, homeserver, 512)) {
|
for (url in mxcToThumbnailUrls(thumbnailMxc, homeserver, 512)) {
|
||||||
downloadBitmap(url, token)?.let { return it }
|
downloadBitmap(url, token)?.let { return it }
|
||||||
@@ -707,7 +707,7 @@ class MatrixSyncService : Service() {
|
|||||||
}
|
}
|
||||||
val fullMxc =
|
val fullMxc =
|
||||||
content.optString("url").takeIf { it.startsWith("mxc://") }
|
content.optString("url").takeIf { it.startsWith("mxc://") }
|
||||||
?: content.optJSONObject("file")?.optString("url").takeIf { it.startsWith("mxc://") }
|
?: content.optJSONObject("file")?.optString("url")?.takeIf { it.startsWith("mxc://") }
|
||||||
if (fullMxc != null) {
|
if (fullMxc != null) {
|
||||||
for (url in mxcToDownloadUrls(fullMxc, homeserver)) {
|
for (url in mxcToDownloadUrls(fullMxc, homeserver)) {
|
||||||
downloadBitmap(url, token)?.let { return it }
|
downloadBitmap(url, token)?.let { return it }
|
||||||
|
|||||||
Reference in New Issue
Block a user