mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Don't regenerate static layout if content isn't changed
This commit is contained in:
parent
62739a86cd
commit
34f7f314f6
1 changed files with 29 additions and 19 deletions
|
@ -1049,6 +1049,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||||
private int commentUnreadX;
|
private int commentUnreadX;
|
||||||
private boolean commentDrawUnread;
|
private boolean commentDrawUnread;
|
||||||
private int commentWidth;
|
private int commentWidth;
|
||||||
|
private CharSequence currentComment;
|
||||||
private int commentX;
|
private int commentX;
|
||||||
private int totalCommentWidth;
|
private int totalCommentWidth;
|
||||||
private int commentNumberWidth;
|
private int commentNumberWidth;
|
||||||
|
@ -4143,7 +4144,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||||
messageObject.translated != lastTranslated;
|
messageObject.translated != lastTranslated;
|
||||||
boolean groupChanged = groupedMessages != currentMessagesGroup;
|
boolean groupChanged = groupedMessages != currentMessagesGroup;
|
||||||
boolean pollChanged = false;
|
boolean pollChanged = false;
|
||||||
|
boolean captionChanged = currentCaption != messageObject.caption;
|
||||||
if (!messageIdChanged && currentMessageObject != null) {
|
if (!messageIdChanged && currentMessageObject != null) {
|
||||||
messageObject.copyStableParams(currentMessageObject);
|
messageObject.copyStableParams(currentMessageObject);
|
||||||
}
|
}
|
||||||
|
@ -4512,7 +4513,12 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
commentWidth = totalCommentWidth = (int) Math.ceil(Theme.chat_commentTextPaint.measureText(comment));
|
commentWidth = totalCommentWidth = (int) Math.ceil(Theme.chat_commentTextPaint.measureText(comment));
|
||||||
commentLayout = new StaticLayout(comment, Theme.chat_commentTextPaint, commentWidth + AndroidUtilities.dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
boolean commentChanged = currentComment == null || !currentComment.equals(comment);
|
||||||
|
if (commentLayout == null || commentChanged) {
|
||||||
|
commentLayout = new StaticLayout(comment, Theme.chat_commentTextPaint, commentWidth + AndroidUtilities.dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||||
|
currentComment = comment;
|
||||||
|
}
|
||||||
|
|
||||||
if (commentCount != 0 && !LocaleController.isRTL) {
|
if (commentCount != 0 && !LocaleController.isRTL) {
|
||||||
drawCommentNumber = true;
|
drawCommentNumber = true;
|
||||||
if (commentNumberLayout == null) {
|
if (commentNumberLayout == null) {
|
||||||
|
@ -6180,7 +6186,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||||
int width = backgroundWidth - AndroidUtilities.dp(31);
|
int width = backgroundWidth - AndroidUtilities.dp(31);
|
||||||
widthForCaption = width - AndroidUtilities.dp(10) - getExtraTextX() * 2;
|
widthForCaption = width - AndroidUtilities.dp(10) - getExtraTextX() * 2;
|
||||||
|
|
||||||
if (!messageObject.isRestrictedMessage && !TextUtils.isEmpty(messageObject.caption)) {
|
if (captionChanged && !messageObject.isRestrictedMessage && !TextUtils.isEmpty(messageObject.caption)) {
|
||||||
try {
|
try {
|
||||||
currentCaption = messageObject.caption;
|
currentCaption = messageObject.caption;
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
@ -6984,14 +6990,16 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||||
if (currentCaption != null) {
|
if (currentCaption != null) {
|
||||||
try {
|
try {
|
||||||
widthForCaption -= getExtraTextX() * 2;
|
widthForCaption -= getExtraTextX() * 2;
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (captionLayout == null || captionChanged) {
|
||||||
captionLayout = StaticLayout.Builder.obtain(currentCaption, 0, currentCaption.length(), Theme.chat_msgTextPaint, widthForCaption)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
.setBreakStrategy(StaticLayout.BREAK_STRATEGY_HIGH_QUALITY)
|
captionLayout = StaticLayout.Builder.obtain(currentCaption, 0, currentCaption.length(), Theme.chat_msgTextPaint, widthForCaption)
|
||||||
.setHyphenationFrequency(StaticLayout.HYPHENATION_FREQUENCY_NONE)
|
.setBreakStrategy(StaticLayout.BREAK_STRATEGY_HIGH_QUALITY)
|
||||||
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
|
.setHyphenationFrequency(StaticLayout.HYPHENATION_FREQUENCY_NONE)
|
||||||
.build();
|
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
|
||||||
} else {
|
.build();
|
||||||
captionLayout = new StaticLayout(currentCaption, Theme.chat_msgTextPaint, widthForCaption, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
} else {
|
||||||
|
captionLayout = new StaticLayout(currentCaption, Theme.chat_msgTextPaint, widthForCaption, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateCaptionSpoilers();
|
updateCaptionSpoilers();
|
||||||
int lineCount = captionLayout.getLineCount();
|
int lineCount = captionLayout.getLineCount();
|
||||||
|
@ -7362,14 +7370,16 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
||||||
width -= AndroidUtilities.dp(24);
|
width -= AndroidUtilities.dp(24);
|
||||||
}
|
}
|
||||||
int widthForCaption = width - AndroidUtilities.dp(31 + (currentMessageObject.type != MessageObject.TYPE_ROUND_VIDEO ? 10 : 0)) - getExtraTextX() * 2;
|
int widthForCaption = width - AndroidUtilities.dp(31 + (currentMessageObject.type != MessageObject.TYPE_ROUND_VIDEO ? 10 : 0)) - getExtraTextX() * 2;
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (captionLayout == null || captionChanged) {
|
||||||
captionLayout = StaticLayout.Builder.obtain(currentCaption, 0, currentCaption.length(), Theme.chat_msgTextPaint, widthForCaption)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
.setBreakStrategy(StaticLayout.BREAK_STRATEGY_HIGH_QUALITY)
|
captionLayout = StaticLayout.Builder.obtain(currentCaption, 0, currentCaption.length(), Theme.chat_msgTextPaint, widthForCaption)
|
||||||
.setHyphenationFrequency(StaticLayout.HYPHENATION_FREQUENCY_NONE)
|
.setBreakStrategy(StaticLayout.BREAK_STRATEGY_HIGH_QUALITY)
|
||||||
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
|
.setHyphenationFrequency(StaticLayout.HYPHENATION_FREQUENCY_NONE)
|
||||||
.build();
|
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
|
||||||
} else {
|
.build();
|
||||||
captionLayout = new StaticLayout(currentCaption, Theme.chat_msgTextPaint, widthForCaption, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
} else {
|
||||||
|
captionLayout = new StaticLayout(currentCaption, Theme.chat_msgTextPaint, widthForCaption, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateSeekBarWaveformWidth(null);
|
updateSeekBarWaveformWidth(null);
|
||||||
updateCaptionSpoilers();
|
updateCaptionSpoilers();
|
||||||
|
|
Loading…
Reference in a new issue