use of org.telegram.messenger.MessageObject in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method createVoiceMessagesPlaylist.
private ArrayList<MessageObject> createVoiceMessagesPlaylist(MessageObject startMessageObject, boolean playingUnreadMedia) {
ArrayList<MessageObject> messageObjects = new ArrayList<>();
messageObjects.add(startMessageObject);
int messageId = startMessageObject.getId();
long startDialogId = startMessageObject.getDialogId();
if (messageId != 0) {
boolean started = false;
for (int a = messages.size() - 1; a >= 0; a--) {
MessageObject messageObject = messages.get(a);
if (messageObject.getDialogId() == mergeDialogId && startMessageObject.getDialogId() != mergeDialogId) {
continue;
}
if ((currentEncryptedChat == null && messageObject.getId() > messageId || currentEncryptedChat != null && messageObject.getId() < messageId) && (messageObject.isVoice() || messageObject.isRoundVideo()) && (!playingUnreadMedia || messageObject.isContentUnread() && !messageObject.isOut())) {
messageObjects.add(messageObject);
}
}
}
return messageObjects;
}
use of org.telegram.messenger.MessageObject in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method updateMessagesVisiblePart.
public void updateMessagesVisiblePart(boolean inLayout) {
if (chatListView == null) {
return;
}
int count = chatListView.getChildCount();
int height = chatListView.getMeasuredHeight();
int minPositionHolder = Integer.MAX_VALUE;
int minPositionDateHolder = Integer.MAX_VALUE;
View minDateChild = null;
View minChild = null;
View minMessageChild = null;
boolean foundTextureViewMessage = false;
boolean previousThreadMessageVisible = threadMessageVisible;
int previousPinnedMessageId = currentPinnedMessageId;
int maxVisibleId = Integer.MIN_VALUE;
MessageObject maxVisibleMessageObject = null;
threadMessageVisible = firstLoading;
Integer currentReadMaxId = null;
int threadId = threadMessageId;
if (threadId != 0 && currentChat != null) {
currentReadMaxId = replyMaxReadId;
} else {
currentReadMaxId = getMessagesController().dialogs_read_inbox_max.get(dialog_id_Long);
}
if (currentReadMaxId == null) {
currentReadMaxId = 0;
}
int maxPositiveUnreadId = Integer.MIN_VALUE;
int maxNegativeUnreadId = Integer.MAX_VALUE;
int maxUnreadDate = Integer.MIN_VALUE;
int recyclerChatViewHeight = (contentView.getHeightWithKeyboard() - (inPreviewMode ? 0 : AndroidUtilities.dp(48)) - chatListView.getTop());
pollsToCheck.clear();
float clipTop = chatListViewPaddingTop;
long currentTime = System.currentTimeMillis();
int maxAdapterPosition = -1;
int minAdapterPosition = -1;
for (int a = 0; a < count; a++) {
View view = chatListView.getChildAt(a);
MessageObject messageObject = null;
int adapterPosition = chatListView.getChildAdapterPosition(view);
if (adapterPosition >= 0) {
if (adapterPosition > maxAdapterPosition || maxAdapterPosition == -1) {
maxAdapterPosition = adapterPosition;
}
if (adapterPosition < minAdapterPosition || minAdapterPosition == -1) {
minAdapterPosition = adapterPosition;
}
}
int top = (int) view.getY();
int bottom = top + view.getMeasuredHeight();
ChatMessageCell messageCell = null;
if (view instanceof ChatMessageCell) {
messageCell = (ChatMessageCell) view;
}
if (messageCell != null) {
messageCell.isBlurred = view.getY() < clipTop || view.getY() + view.getMeasuredHeight() > AndroidUtilities.dp(203);
}
if (bottom <= clipTop - chatListViewPaddingVisibleOffset || top > chatListView.getMeasuredHeight()) {
continue;
}
int viewTop = top >= 0 ? 0 : -top;
int viewBottom = view.getMeasuredHeight();
if (viewBottom > height) {
viewBottom = viewTop + height;
}
int keyboardOffset = contentView.getKeyboardHeight();
if (keyboardOffset < AndroidUtilities.dp(20) && chatActivityEnterView.isPopupShowing() || chatActivityEnterView.pannelAniamationInProgress()) {
keyboardOffset = chatActivityEnterView.getEmojiPadding();
}
if (messageCell != null) {
messageObject = messageCell.getMessageObject();
if (messageObject.getDialogId() == dialog_id && messageObject.getId() > maxVisibleId) {
maxVisibleId = messageObject.getId();
maxVisibleMessageObject = messageObject;
}
messageCell.setVisiblePart(viewTop, viewBottom - viewTop, recyclerChatViewHeight, keyboardOffset, view.getY() + (isKeyboardVisible() ? chatListView.getTop() : actionBar.getMeasuredHeight()) - contentView.getBackgroundTranslationY(), contentView.getMeasuredWidth(), contentView.getBackgroundSizeY());
markSponsoredAsRead(messageObject);
if (!threadMessageVisible && threadMessageObject != null && messageObject == threadMessageObject && messageCell.getBottom() > chatListViewPaddingTop) {
threadMessageVisible = true;
}
if (videoPlayerContainer != null && (messageObject.isVideo() || messageObject.isRoundVideo()) && MediaController.getInstance().isPlayingMessage(messageObject)) {
ImageReceiver imageReceiver = messageCell.getPhotoImage();
if (top + imageReceiver.getImageY2() < 0) {
foundTextureViewMessage = false;
} else {
videoPlayerContainer.setTranslationX(imageReceiver.getImageX() + messageCell.getX());
float translationY = messageCell.getY() + imageReceiver.getImageY() + chatListView.getY() - videoPlayerContainer.getTop();
videoPlayerContainer.setTranslationY(translationY);
fragmentView.invalidate();
videoPlayerContainer.invalidate();
foundTextureViewMessage = true;
}
}
if (startFromVideoTimestamp >= 0 && fragmentOpened && !chatListView.isFastScrollAnimationRunning() && startFromVideoMessageId == messageObject.getId() && (messageObject.isVideo() || messageObject.isRoundVideo() || messageObject.isVoice() || messageObject.isMusic())) {
messageObject.forceSeekTo = startFromVideoTimestamp / (float) messageObject.getDuration();
MessageObject finalMessage = messageObject;
AndroidUtilities.runOnUIThread(() -> {
if (finalMessage.isVideo()) {
openPhotoViewerForMessage(null, finalMessage);
} else {
MediaController.getInstance().playMessage(finalMessage);
}
}, 40);
startFromVideoTimestamp = -1;
}
if (fragmentOpened && openAnimationEnded && (chatListItemAnimator == null || !chatListItemAnimator.isRunning()) && messageCell.checkUnreadReactions(clipTop, chatListView.getMeasuredHeight() - blurredViewBottomOffset)) {
reactionsMentionCount--;
getMessagesStorage().markMessageReactionsAsRead(getDialogId(), messageCell.getMessageObject().getId(), true);
if (reactionsMentionCount <= 0) {
getMessagesController().markReactionsAsRead(dialog_id);
}
if (reactionsMentionCount >= 0) {
TLRPC.TL_messagePeerReaction reaction = messageCell.getMessageObject().getRandomUnreadReaction();
if (reaction != null) {
ReactionsEffectOverlay.show(ChatActivity.this, null, messageCell, 0, 0, reaction.reaction, currentAccount, reaction.big ? ReactionsEffectOverlay.LONG_ANIMATION : ReactionsEffectOverlay.SHORT_ANIMATION);
ReactionsEffectOverlay.startAnimation();
}
messageCell.markReactionsAsRead();
} else {
reactionsMentionCount = 0;
}
updateReactionsMentionButton(true);
}
} else if (view instanceof ChatActionCell) {
ChatActionCell cell = (ChatActionCell) view;
messageObject = cell.getMessageObject();
if (messageObject != null && messageObject.getDialogId() == dialog_id && messageObject.getId() > maxVisibleId) {
maxVisibleId = Math.max(maxVisibleId, messageObject.getId());
}
cell.setVisiblePart(view.getY() + (isKeyboardVisible() ? chatListView.getTop() : actionBar.getMeasuredHeight()) - contentView.getBackgroundTranslationY(), contentView.getBackgroundSizeY());
} else if (view instanceof BotHelpCell) {
view.invalidate();
}
if (chatMode != MODE_SCHEDULED && messageObject != null) {
int id = messageObject.getId();
if (!isThreadChat() && (!messageObject.isOut() && messageObject.isUnread() || messageObject.messageOwner.from_scheduled && id > currentReadMaxId) || id > 0 && isThreadChat() && id > currentReadMaxId && id > replyMaxReadId) {
if (id > 0) {
maxPositiveUnreadId = Math.max(maxPositiveUnreadId, messageObject.getId());
}
if (id < 0 && !isThreadChat()) {
maxNegativeUnreadId = Math.min(maxNegativeUnreadId, messageObject.getId());
}
maxUnreadDate = Math.max(maxUnreadDate, messageObject.messageOwner.date);
}
if (messageObject.type == MessageObject.TYPE_POLL && messageObject.getId() > 0) {
pollsToCheck.add(messageObject);
}
}
if (bottom <= clipTop) {
if (view instanceof ChatActionCell && messageObject.isDateObject) {
view.setAlpha(0);
}
continue;
}
int position = view.getBottom();
if (position < minPositionHolder) {
minPositionHolder = position;
if (view instanceof ChatMessageCell || view instanceof ChatActionCell) {
minMessageChild = view;
}
minChild = view;
}
if (chatListItemAnimator == null || (!chatListItemAnimator.willRemoved(view) && !chatListItemAnimator.willAddedFromAlpha(view))) {
if (view instanceof ChatActionCell && messageObject.isDateObject) {
if (view.getAlpha() != 1.0f) {
view.setAlpha(1.0f);
}
if (position < minPositionDateHolder) {
minPositionDateHolder = position;
minDateChild = view;
}
}
}
}
currentPinnedMessageId = 0;
if (!pinnedMessageIds.isEmpty()) {
if (maxVisibleId == Integer.MIN_VALUE) {
if (startLoadFromMessageId != 0) {
maxVisibleId = startLoadFromMessageId;
} else if (!pinnedMessageIds.isEmpty()) {
maxVisibleId = pinnedMessageIds.get(0) + 1;
}
} else if (maxVisibleId < 0) {
int idx = messages.indexOf(maxVisibleMessageObject);
if (idx >= 0) {
for (int a = idx - 1; a >= 0; a--) {
MessageObject object = messages.get(a);
if (object.getId() > 0) {
maxVisibleId = object.getId();
break;
}
}
if (maxVisibleId < 0) {
for (int a = idx + 1, N = messages.size(); a < N; a++) {
MessageObject object = messages.get(a);
if (object.getId() > 0) {
maxVisibleId = object.getId();
break;
}
}
}
}
}
currentPinnedMessageId = findClosest(pinnedMessageIds, forceNextPinnedMessageId != 0 ? forceNextPinnedMessageId : maxVisibleId, currentPinnedMessageIndex);
if (!inMenuMode && !loadingPinnedMessagesList && !pinnedEndReached && !pinnedMessageIds.isEmpty() && currentPinnedMessageIndex[0] > pinnedMessageIds.size() - 2) {
getMediaDataController().loadPinnedMessages(dialog_id, pinnedMessageIds.get(pinnedMessageIds.size() - 1), 0);
loadingPinnedMessagesList = true;
}
}
getMessagesController().addToPollsQueue(dialog_id, pollsToCheck);
if (maxAdapterPosition >= 0 && minAdapterPosition >= 0) {
int from = minAdapterPosition - chatAdapter.messagesStartRow - 10;
int to = maxAdapterPosition - chatAdapter.messagesStartRow + 10;
if (from < 0) {
from = 0;
}
if (to > messages.size()) {
to = messages.size();
}
reactionsToCheck.clear();
for (int i = from; i < to; i++) {
MessageObject messageObject = messages.get(i);
if (threadMessageObject != messageObject && messageObject.getId() > 0 && messageObject.messageOwner.action == null && (currentTime - messageObject.reactionsLastCheckTime) > 15000L) {
messageObject.reactionsLastCheckTime = currentTime;
reactionsToCheck.add(messageObject);
}
}
getMessagesController().loadReactionsForMessages(dialog_id, reactionsToCheck);
}
if (videoPlayerContainer != null) {
if (!foundTextureViewMessage) {
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (messageObject != null) {
if (checkTextureViewPosition && messageObject.isVideo()) {
MediaController.getInstance().cleanupPlayer(true, true);
} else {
videoPlayerContainer.setTranslationY(-AndroidUtilities.roundPlayingMessageSize - 100);
fragmentView.invalidate();
if ((messageObject.isRoundVideo() || messageObject.isVideo()) && messageObject.eventId == 0 && checkTextureViewPosition && !chatListView.isFastScrollAnimationRunning()) {
MediaController.getInstance().setCurrentVideoVisible(false);
}
}
}
} else {
MediaController.getInstance().setCurrentVideoVisible(true);
}
}
if (minMessageChild != null) {
MessageObject messageObject;
if (minMessageChild instanceof ChatMessageCell) {
messageObject = ((ChatMessageCell) minMessageChild).getMessageObject();
} else {
messageObject = ((ChatActionCell) minMessageChild).getMessageObject();
}
floatingDateView.setCustomDate(messageObject.messageOwner.date, chatMode == MODE_SCHEDULED, true);
}
currentFloatingDateOnScreen = false;
currentFloatingTopIsNotMessage = !(minChild instanceof ChatMessageCell || minChild instanceof ChatActionCell);
if (minDateChild != null) {
boolean showFloatingView = false;
if (minDateChild.getY() > clipTop || currentFloatingTopIsNotMessage) {
if (minDateChild.getAlpha() != 1.0f) {
minDateChild.setAlpha(1.0f);
}
if (chatListView.getChildAdapterPosition(minDateChild) == chatAdapter.messagesStartRow + messages.size() - 1) {
if (minDateChild.getAlpha() != 1.0f) {
minDateChild.setAlpha(1.0f);
}
if (floatingDateAnimation != null) {
floatingDateAnimation.cancel();
floatingDateAnimation = null;
}
floatingDateView.setTag(null);
floatingDateView.setAlpha(0);
currentFloatingDateOnScreen = false;
} else {
hideFloatingDateView(!currentFloatingTopIsNotMessage);
}
} else {
if (minDateChild.getAlpha() != 0.0f) {
minDateChild.setAlpha(0.0f);
}
showFloatingView = true;
}
float offset = minDateChild.getY() + minDateChild.getMeasuredHeight() - clipTop;
if (offset > floatingDateView.getMeasuredHeight() && offset < floatingDateView.getMeasuredHeight() * 2) {
if (chatListView.getChildAdapterPosition(minDateChild) == chatAdapter.messagesStartRow + messages.size() - 1) {
showFloatingView = false;
if (minDateChild.getAlpha() != 1.0f) {
minDateChild.setAlpha(1.0f);
}
if (floatingDateAnimation != null) {
floatingDateAnimation.cancel();
floatingDateAnimation = null;
}
floatingDateView.setTag(null);
floatingDateView.setAlpha(0);
} else {
floatingDateViewOffset = -floatingDateView.getMeasuredHeight() * 2 + offset;
}
} else {
floatingDateViewOffset = 0;
}
if (showFloatingView) {
if (floatingDateAnimation != null) {
floatingDateAnimation.cancel();
floatingDateAnimation = null;
}
if (floatingDateView.getTag() == null) {
floatingDateView.setTag(1);
}
if (floatingDateView.getAlpha() != 1.0f) {
floatingDateView.setAlpha(1.0f);
}
currentFloatingDateOnScreen = true;
}
} else {
hideFloatingDateView(true);
floatingDateViewOffset = 0;
}
if (isThreadChat()) {
if (previousThreadMessageVisible != threadMessageVisible) {
updatePinnedMessageView(openAnimationStartTime != 0 && SystemClock.elapsedRealtime() >= openAnimationStartTime + 150);
}
} else {
if (currentPinnedMessageId != 0) {
MessageObject object = pinnedMessageObjects.get(currentPinnedMessageId);
if (object == null) {
object = messagesDict[0].get(currentPinnedMessageId);
}
if (object == null) {
if (loadingPinnedMessages.indexOfKey(currentPinnedMessageId) < 0) {
loadingPinnedMessages.put(currentPinnedMessageId, true);
ArrayList<Integer> ids = new ArrayList<>();
ids.add(currentPinnedMessageId);
getMediaDataController().loadPinnedMessages(dialog_id, ChatObject.isChannel(currentChat) ? currentChat.id : 0, ids, true);
}
currentPinnedMessageId = previousPinnedMessageId;
}
} else if (previousPinnedMessageId != 0 && !pinnedMessageIds.isEmpty()) {
currentPinnedMessageId = previousPinnedMessageId;
}
boolean animated = (fromPullingDownTransition && fragmentView.getVisibility() == View.VISIBLE) || (openAnimationStartTime != 0 && SystemClock.elapsedRealtime() >= openAnimationStartTime + 150);
if (previousPinnedMessageId != currentPinnedMessageId) {
int animateToNext;
if (previousPinnedMessageId == 0) {
animateToNext = 0;
} else if (previousPinnedMessageId > currentPinnedMessageId) {
animateToNext = 1;
} else {
animateToNext = 2;
}
updatePinnedMessageView(animated, animateToNext);
} else {
updatePinnedListButton(animated);
}
}
if (floatingDateView != null) {
floatingDateView.setTranslationY(chatListView.getTranslationY() + chatListViewPaddingTop + floatingDateViewOffset - AndroidUtilities.dp(4));
}
invalidateChatListViewTopPadding();
if (!firstLoading && !paused && !inPreviewMode && chatMode == 0 && !getMessagesController().ignoreSetOnline) {
int scheduledRead = 0;
if ((maxPositiveUnreadId != Integer.MIN_VALUE || maxNegativeUnreadId != Integer.MAX_VALUE)) {
int counterDecrement = 0;
for (int a = 0; a < messages.size(); a++) {
MessageObject messageObject = messages.get(a);
int id = messageObject.getId();
if (maxPositiveUnreadId != Integer.MIN_VALUE) {
if (id > 0 && id <= maxPositiveUnreadId && (messageObject.messageOwner.from_scheduled && id > currentReadMaxId || messageObject.isUnread() && !messageObject.isOut())) {
if (messageObject.messageOwner.from_scheduled) {
scheduledRead++;
} else {
messageObject.setIsRead();
}
counterDecrement++;
}
}
if (maxNegativeUnreadId != Integer.MAX_VALUE) {
if (id < 0 && id >= maxNegativeUnreadId && messageObject.isUnread()) {
messageObject.setIsRead();
counterDecrement++;
}
}
}
if (forwardEndReached[0] && maxPositiveUnreadId == minMessageId[0] || maxNegativeUnreadId == minMessageId[0]) {
newUnreadMessageCount = 0;
} else {
newUnreadMessageCount -= counterDecrement;
if (newUnreadMessageCount < 0) {
newUnreadMessageCount = 0;
}
}
if (inLayout) {
AndroidUtilities.runOnUIThread(this::inlineUpdate1);
} else {
inlineUpdate1();
}
getMessagesController().markDialogAsRead(dialog_id, maxPositiveUnreadId, maxNegativeUnreadId, maxUnreadDate, false, threadId, counterDecrement, maxPositiveUnreadId == minMessageId[0] || maxNegativeUnreadId == minMessageId[0], scheduledRead);
firstUnreadSent = true;
} else if (!firstUnreadSent && currentEncryptedChat == null) {
if (chatLayoutManager.findFirstVisibleItemPosition() == 0) {
newUnreadMessageCount = 0;
if (inLayout) {
AndroidUtilities.runOnUIThread(this::inlineUpdate2);
} else {
inlineUpdate2();
}
getMessagesController().markDialogAsRead(dialog_id, minMessageId[0], minMessageId[0], maxDate[0], false, threadId, 0, true, scheduledRead);
firstUnreadSent = true;
}
}
if (threadId != 0 && maxPositiveUnreadId > 0 && replyMaxReadId != maxPositiveUnreadId) {
replyMaxReadId = maxPositiveUnreadId;
getMessagesStorage().updateRepliesMaxReadId(replyOriginalChat.id, replyOriginalMessageId, replyMaxReadId, true);
getNotificationCenter().postNotificationName(NotificationCenter.commentsRead, replyOriginalChat.id, replyOriginalMessageId, replyMaxReadId);
}
}
}
use of org.telegram.messenger.MessageObject in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method updateVisibleRows.
private void updateVisibleRows() {
if (chatListView == null) {
return;
}
int lastVisibleItem = RecyclerView.NO_POSITION;
int top = 0;
if (!wasManualScroll && unreadMessageObject != null) {
int n = chatListView.getChildCount();
for (int i = 0; i < n; i++) {
View child = chatListView.getChildAt(i);
if (child instanceof ChatMessageCell && ((ChatMessageCell) child).getMessageObject() == unreadMessageObject) {
int unreadMessageIndex = messages.indexOf(unreadMessageObject);
if (unreadMessageIndex >= 0) {
lastVisibleItem = chatAdapter.messagesStartRow + messages.indexOf(unreadMessageObject);
top = chatListView.getMeasuredHeight() - child.getBottom() - chatListView.getPaddingBottom();
}
break;
}
}
}
int count = chatListView.getChildCount();
MessageObject editingMessageObject = chatActivityEnterView != null ? chatActivityEnterView.getEditingMessageObject() : null;
long linkedChatId = chatInfo != null ? chatInfo.linked_chat_id : 0;
for (int a = 0; a < count; a++) {
View view = chatListView.getChildAt(a);
if (view instanceof ChatMessageCell) {
ChatMessageCell cell = (ChatMessageCell) view;
MessageObject messageObject = cell.getMessageObject();
boolean disableSelection = false;
boolean selected = false;
if (actionBar.isActionModeShowed() || reportType >= 0) {
cell.setCheckBoxVisible(threadMessageObjects == null || !threadMessageObjects.contains(messageObject), true);
int idx = messageObject.getDialogId() == dialog_id ? 0 : 1;
if (selectedMessagesIds[idx].indexOfKey(messageObject.getId()) >= 0) {
setCellSelectionBackground(messageObject, cell, idx, true);
selected = true;
} else {
cell.setDrawSelectionBackground(false);
cell.setChecked(false, false, true);
}
disableSelection = true;
} else {
cell.setDrawSelectionBackground(false);
cell.setCheckBoxVisible(false, true);
cell.setChecked(false, false, true);
}
if (!cell.getMessageObject().deleted || cell.linkedChatId != linkedChatId) {
cell.setIsUpdating(true);
cell.linkedChatId = chatInfo != null ? chatInfo.linked_chat_id : 0;
cell.setMessageObject(cell.getMessageObject(), cell.getCurrentMessagesGroup(), cell.isPinnedBottom(), cell.isPinnedTop());
cell.setIsUpdating(false);
}
if (cell != scrimView) {
cell.setCheckPressed(!disableSelection, disableSelection && selected);
}
cell.setHighlighted(highlightMessageId != Integer.MAX_VALUE && messageObject != null && messageObject.getId() == highlightMessageId);
if (highlightMessageId != Integer.MAX_VALUE) {
startMessageUnselect();
}
if (searchContainer != null && searchContainer.getVisibility() == View.VISIBLE && getMediaDataController().isMessageFound(messageObject.getId(), messageObject.getDialogId() == mergeDialogId) && getMediaDataController().getLastSearchQuery() != null) {
cell.setHighlightedText(getMediaDataController().getLastSearchQuery());
} else {
cell.setHighlightedText(null);
}
cell.setSpoilersSuppressed(chatListView.getScrollState() != RecyclerView.SCROLL_STATE_IDLE);
} else if (view instanceof ChatActionCell) {
ChatActionCell cell = (ChatActionCell) view;
cell.setMessageObject(cell.getMessageObject());
cell.setSpoilersSuppressed(chatListView.getScrollState() != RecyclerView.SCROLL_STATE_IDLE);
}
}
if (lastVisibleItem != RecyclerView.NO_POSITION) {
// chatLayoutManager.scrollToPositionWithOffset(lastVisibleItem, top);
}
}
use of org.telegram.messenger.MessageObject in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method maybePlayVisibleVideo.
public boolean maybePlayVisibleVideo() {
if (chatListView == null) {
return false;
}
MessageObject playingMessage = MediaController.getInstance().getPlayingMessageObject();
if (playingMessage != null && !playingMessage.isVideo()) {
return false;
}
MessageObject visibleMessage = null;
AnimatedFileDrawable visibleAnimation = null;
if (noSoundHintView != null && noSoundHintView.getTag() != null) {
ChatMessageCell cell = noSoundHintView.getMessageCell();
ImageReceiver imageReceiver = cell.getPhotoImage();
visibleAnimation = imageReceiver.getAnimation();
if (visibleAnimation != null) {
visibleMessage = cell.getMessageObject();
scrollToVideo = cell.getTop() + imageReceiver.getImageY2() > chatListView.getMeasuredHeight();
}
}
if (visibleMessage == null) {
int count = chatListView.getChildCount();
for (int a = 0; a < count; a++) {
View child = chatListView.getChildAt(a);
if (!(child instanceof ChatMessageCell)) {
continue;
}
ChatMessageCell messageCell = (ChatMessageCell) child;
MessageObject messageObject = messageCell.getMessageObject();
boolean isRoundVideo = messageObject.isRoundVideo();
if ((!messageObject.isVideo() && !isRoundVideo) || messageObject.videoEditedInfo != null) {
continue;
}
ImageReceiver imageReceiver = messageCell.getPhotoImage();
AnimatedFileDrawable animation = imageReceiver.getAnimation();
if (animation == null) {
continue;
}
float top = child.getTop() + imageReceiver.getImageY();
float bottom = top + imageReceiver.getImageHeight();
if (bottom < 0 || top > chatListView.getMeasuredHeight()) {
continue;
}
if (visibleMessage != null && top < 0) {
break;
}
visibleMessage = messageObject;
visibleAnimation = animation;
scrollToVideo = top < 0 || bottom > chatListView.getMeasuredHeight();
if (top >= 0 && bottom <= chatListView.getMeasuredHeight()) {
break;
}
}
}
if (visibleMessage != null) {
if (MediaController.getInstance().isPlayingMessage(visibleMessage)) {
return false;
}
hideHints(true);
if (visibleMessage.isRoundVideo()) {
boolean result = MediaController.getInstance().playMessage(visibleMessage);
MediaController.getInstance().setVoiceMessagesPlaylist(result ? createVoiceMessagesPlaylist(visibleMessage, false) : null, false);
return result;
} else {
SharedConfig.setNoSoundHintShowed(true);
visibleMessage.audioProgress = visibleAnimation.getCurrentProgress();
visibleMessage.audioProgressMs = visibleAnimation.getCurrentProgressMs();
visibleAnimation.stop();
if (PhotoViewer.isPlayingMessageInPip(visibleMessage)) {
PhotoViewer.getPipInstance().destroyPhotoViewer();
}
return MediaController.getInstance().playMessage(visibleMessage);
}
}
return false;
}
use of org.telegram.messenger.MessageObject in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method restartSticker.
public void restartSticker(ChatMessageCell cell) {
MessageObject message = cell.getMessageObject();
TLRPC.Document document = message.getDocument();
boolean isEmoji;
if ((isEmoji = message.isAnimatedEmoji()) || MessageObject.isAnimatedStickerDocument(document, currentEncryptedChat == null || message.isOut()) && !SharedConfig.loopStickers) {
ImageReceiver imageReceiver = cell.getPhotoImage();
RLottieDrawable drawable = imageReceiver.getLottieAnimation();
if (drawable != null) {
if (isEmoji) {
String emoji = message.getStickerEmoji();
if (EmojiData.isHeartEmoji(emoji)) {
HashMap<Integer, Integer> pattern = new HashMap<>();
pattern.put(1, 1);
pattern.put(13, 0);
pattern.put(59, 1);
pattern.put(71, 0);
pattern.put(128, 1);
pattern.put(140, 0);
drawable.setVibrationPattern(pattern);
} else if (EmojiData.isPeachEmoji(emoji)) {
HashMap<Integer, Integer> pattern = new HashMap<>();
pattern.put(34, 1);
drawable.setVibrationPattern(pattern);
} else if (EmojiData.isCofinEmoji(emoji)) {
HashMap<Integer, Integer> pattern = new HashMap<>();
pattern.put(24, 0);
pattern.put(36, 0);
drawable.setVibrationPattern(pattern);
}
if (!drawable.isRunning() && emoji != null) {
MessagesController.EmojiSound sound = getMessagesController().emojiSounds.get(emoji.replace("\uFE0F", ""));
if (sound != null) {
getMediaController().playEmojiSound(getAccountInstance(), emoji, sound, false);
}
}
}
drawable.restart();
}
}
}
Aggregations