Skip to content

Commit

Permalink
Merge pull request #1933 from pantasystem/hotfix/#1932/large-emoji-cr…
Browse files Browse the repository at this point in the history
…ush-bug

長すぎるカスタム絵文字を表示しようとするとクラッシュする不具合を修正
  • Loading branch information
pantasystem authored Oct 27, 2023
2 parents 4035b42 + ccaf046 commit a2ef018
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,26 @@ object MFMDecorator {
null -> height
else -> height * aspectRatio
}
val windowWidthSize = textView.resources.displayMetrics.widthPixels
val finalEmojiWidth: Int
val finalEmojiHeight: Int
if ((width * customEmojiScale).toInt() > windowWidthSize && windowWidthSize > 0) {
val scale = (windowWidthSize.toFloat() / (width * customEmojiScale))
finalEmojiWidth = windowWidthSize
finalEmojiHeight = (height * customEmojiScale * scale).toInt()
} else {
finalEmojiWidth = (width * customEmojiScale).toInt()
finalEmojiHeight = (height * customEmojiScale).toInt()
}

GlideApp.with(textView)
.load(emojiElement.emoji.cachePath)
.error(
GlideApp.with(textView)
.load(emojiElement.emoji.url ?: emojiElement.emoji.uri)
.override((width * customEmojiScale).toInt(), (height * customEmojiScale).toInt())
.override(finalEmojiWidth, finalEmojiHeight)
)
.override((width * customEmojiScale).toInt(), (height * customEmojiScale).toInt())
.override(finalEmojiWidth, finalEmojiHeight)
.into(emojiSpan.target)
}
}
Expand Down

0 comments on commit a2ef018

Please sign in to comment.