use of org.telegram.messenger.MessageObject in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method updateTextureViewPosition.
public void updateTextureViewPosition(boolean needScroll) {
if (fragmentView == null || paused) {
return;
}
boolean foundTextureViewMessage = false;
int count = chatListView.getChildCount();
for (int a = 0; a < count; a++) {
View view = chatListView.getChildAt(a);
if (view instanceof ChatMessageCell) {
ChatMessageCell messageCell = (ChatMessageCell) view;
MessageObject messageObject = messageCell.getMessageObject();
if (videoPlayerContainer != null && (messageObject.isRoundVideo() || messageObject.isVideo()) && MediaController.getInstance().isPlayingMessage(messageObject)) {
ImageReceiver imageReceiver = messageCell.getPhotoImage();
videoPlayerContainer.setTranslationX(imageReceiver.getImageX() + messageCell.getX());
float translationY = messageCell.getY() + imageReceiver.getImageY() + chatListView.getY() - videoPlayerContainer.getTop();
videoPlayerContainer.setTranslationY(translationY);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) videoPlayerContainer.getLayoutParams();
if (messageObject.isRoundVideo()) {
videoPlayerContainer.setTag(R.id.parent_tag, null);
if (layoutParams.width != AndroidUtilities.roundPlayingMessageSize || layoutParams.height != AndroidUtilities.roundPlayingMessageSize) {
layoutParams.width = layoutParams.height = AndroidUtilities.roundPlayingMessageSize;
aspectRatioFrameLayout.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT);
videoPlayerContainer.setLayoutParams(layoutParams);
}
float scale = (AndroidUtilities.roundPlayingMessageSize + AndroidUtilities.roundMessageInset * 2) / (float) AndroidUtilities.roundPlayingMessageSize;
float transitionScale = messageCell.getPhotoImage().getImageWidth() / AndroidUtilities.roundPlayingMessageSize;
if (videoPlayerContainer.getScaleX() != transitionScale) {
videoPlayerContainer.invalidate();
fragmentView.invalidate();
}
videoPlayerContainer.setPivotX(0);
videoPlayerContainer.setPivotY(0);
videoPlayerContainer.setScaleX(transitionScale);
videoPlayerContainer.setScaleY(transitionScale);
videoTextureView.setScaleX(scale);
videoTextureView.setScaleY(scale);
} else {
videoPlayerContainer.setTag(R.id.parent_tag, imageReceiver);
if (layoutParams.width != imageReceiver.getImageWidth() || layoutParams.height != imageReceiver.getImageHeight()) {
aspectRatioFrameLayout.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
layoutParams.width = (int) imageReceiver.getImageWidth();
layoutParams.height = (int) imageReceiver.getImageHeight();
videoPlayerContainer.setLayoutParams(layoutParams);
}
videoTextureView.setScaleX(1f);
videoTextureView.setScaleY(1f);
}
fragmentView.invalidate();
videoPlayerContainer.invalidate();
foundTextureViewMessage = true;
break;
}
}
}
if (needScroll && videoPlayerContainer != null) {
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (messageObject != null && messageObject.eventId == 0) {
if (!foundTextureViewMessage) {
if (checkTextureViewPosition && messageObject.isVideo()) {
MediaController.getInstance().cleanupPlayer(true, true);
} else {
videoPlayerContainer.setTranslationY(-AndroidUtilities.roundPlayingMessageSize - 100);
fragmentView.invalidate();
if (messageObject.isRoundVideo() || messageObject.isVideo()) {
if (checkTextureViewPosition || PipRoundVideoView.getInstance() != null) {
MediaController.getInstance().setCurrentVideoVisible(false);
} else {
scrollToMessageId(messageObject.getId(), 0, false, 0, true, 0);
}
}
}
} else {
MediaController.getInstance().setCurrentVideoVisible(true);
if (messageObject.isRoundVideo() || scrollToVideo) {
// scrollToMessageId(messageObject.getId(), 0, false, 0, true, 0);
} else {
chatListView.invalidate();
}
}
}
}
}
use of org.telegram.messenger.MessageObject in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method addSponsoredMessages.
private void addSponsoredMessages(boolean animated) {
if (sponsoredMessagesAdded || chatMode != 0 || !ChatObject.isChannel(currentChat) || !forwardEndReached[0]) {
return;
}
ArrayList<MessageObject> arrayList = getMessagesController().getSponsoredMessages(dialog_id);
if (arrayList == null) {
return;
}
for (int i = 0; i < arrayList.size(); i++) {
MessageObject messageObject = arrayList.get(i);
messageObject.resetLayout();
long dialogId = MessageObject.getPeerId(messageObject.messageOwner.from_id);
int messageId = 0;
if (messageObject.sponsoredChannelPost != 0) {
messageId = messageObject.sponsoredChannelPost;
}
getMessagesController().ensureMessagesLoaded(dialogId, messageId, null);
}
sponsoredMessagesAdded = true;
processNewMessages(arrayList);
}
use of org.telegram.messenger.MessageObject in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method getMessageCaption.
private CharSequence getMessageCaption(MessageObject messageObject, MessageObject.GroupedMessages group) {
String restrictionReason = MessagesController.getRestrictionReason(messageObject.messageOwner.restriction_reason);
if (!TextUtils.isEmpty(restrictionReason)) {
return restrictionReason;
}
if (messageObject.caption != null) {
return messageObject.caption;
}
if (group == null) {
return null;
}
CharSequence caption = null;
for (int a = 0, N = group.messages.size(); a < N; a++) {
MessageObject message = group.messages.get(a);
if (message.caption != null) {
if (caption != null) {
return null;
}
caption = message.caption;
}
}
return caption;
}
use of org.telegram.messenger.MessageObject in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method updateChatListViewTopPadding.
private void updateChatListViewTopPadding() {
if (!invalidateChatListViewTopPadding || chatListView == null || fixedKeyboardHeight > 0) {
return;
}
float topPanelViewH = Math.max(0, AndroidUtilities.dp(48) + topChatPanelViewOffset);
float pinnedViewH = 0;
if (pinnedMessageView != null && pinnedMessageView.getVisibility() == View.VISIBLE) {
pinnedViewH = Math.max(0, AndroidUtilities.dp(48) + pinnedMessageEnterOffset);
}
float pendingViewH = 0;
View pendingRequestsView = pendingRequestsDelegate != null ? pendingRequestsDelegate.getView() : null;
if (pendingRequestsView != null && pendingRequestsView.getVisibility() == View.VISIBLE) {
pendingViewH = Math.max(0, pendingRequestsView.getHeight() + pendingRequestsDelegate.getViewEnterOffset());
}
float oldPadding = chatListViewPaddingTop;
chatListViewPaddingTopOnlyTopViews = topPanelViewH + pinnedViewH;
chatListViewPaddingTop = AndroidUtilities.dp(4) + contentPaddingTop + topPanelViewH + pinnedViewH + pendingViewH;
chatListViewPaddingTop += blurredViewTopOffset;
chatListViewPaddingVisibleOffset = 0;
chatListViewPaddingTop += contentPanTranslation + bottomPanelTranslationY;
if (bottomPanelTranslationY == 0 && !chatActivityEnterView.pannelAniamationInProgress() && (contentView.getLayoutParams().height < 0 || (contentView.getKeyboardHeight() <= AndroidUtilities.dp(20) && chatActivityEnterView.isPopupShowing()))) {
chatListViewPaddingTop += contentView.getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !inBubbleMode ? chatActivityEnterView.getEmojiPadding() : contentView.getKeyboardHeight();
}
if (!inPreviewMode && chatActivityEnterView != null) {
if (chatActivityEnterView.getAnimatedTop() != 0) {
chatListViewPaddingTop += chatActivityEnterView.getHeightWithTopView() - AndroidUtilities.dp(51) - chatActivityEnterView.getAnimatedTop();
} else if (!chatActivityEnterView.pannelAniamationInProgress()) {
chatListViewPaddingTop += chatActivityEnterView.getHeightWithTopView() - AndroidUtilities.dp(51);
if (chatActivityEnterView.currentTopViewAnimation == null) {
chatListViewPaddingTop -= chatListView.getTranslationY();
}
}
}
if (infoTopView != null) {
infoTopView.setTranslationY(chatListViewPaddingTop - AndroidUtilities.dp(30) + topViewOffset);
chatListViewPaddingTop += topViewOffset;
chatListViewPaddingVisibleOffset += topViewOffset;
}
if (floatingDateView != null) {
floatingDateView.setTranslationY(chatListView.getTranslationY() + chatListViewPaddingTop + floatingDateViewOffset - AndroidUtilities.dp(4));
}
int p = chatListView.getMeasuredHeight() * 2 / 3;
if (chatListView != null && chatLayoutManager != null && chatAdapter != null) {
if (chatListView.getPaddingTop() != p) {
int firstVisPos = chatLayoutManager.findFirstVisibleItemPosition();
int lastVisPos = chatLayoutManager.findLastVisibleItemPosition();
int top = 0;
MessageObject scrollToMessageObject = null;
if (firstVisPos != RecyclerView.NO_POSITION) {
for (int i = firstVisPos; i <= lastVisPos; i++) {
View v = chatLayoutManager.findViewByPosition(i);
if (v instanceof ChatMessageCell) {
scrollToMessageObject = ((ChatMessageCell) v).getMessageObject();
top = chatListView.getMeasuredHeight() - v.getBottom() - chatListView.getPaddingBottom();
break;
} else if (v instanceof ChatActionCell) {
scrollToMessageObject = ((ChatActionCell) v).getMessageObject();
top = chatListView.getMeasuredHeight() - v.getBottom() - chatListView.getPaddingBottom();
break;
}
}
}
chatListView.setPadding(0, p, 0, AndroidUtilities.dp(3) + blurredViewBottomOffset);
if (firstVisPos != RecyclerView.NO_POSITION && scrollToMessageObject != null) {
chatAdapter.updateRowsSafe();
int index = messages.indexOf(scrollToMessageObject);
if (index >= 0) {
chatLayoutManager.scrollToPositionWithOffset(chatAdapter.messagesStartRow + index, top);
}
}
invalidateMessagesVisiblePart();
}
chatListView.setTopGlowOffset((int) (chatListViewPaddingTop - chatListViewPaddingVisibleOffset - AndroidUtilities.dp(4)));
if (oldPadding != chatListViewPaddingTop) {
int n = chatListView.getChildCount();
for (int i = 0; i < n; i++) {
View child = chatListView.getChildAt(i);
int adapterPosition = chatListView.getChildAdapterPosition(child);
if (adapterPosition == chatAdapter.getItemCount() - 1) {
float padding = chatListViewPaddingTop;
if (isThreadChat() && pinnedMessageView != null && pinnedMessageView.getVisibility() == View.VISIBLE) {
padding -= Math.max(0, AndroidUtilities.dp(48) + pinnedMessageEnterOffset);
}
if (child.getTop() > padding) {
chatListView.scrollBy(0, (int) (child.getTop() - padding));
}
break;
}
}
}
if (!isThreadChat() && !wasManualScroll && unreadMessageObject != null && chatListView != null) {
chatListView.scrollBy(0, (int) (oldPadding - chatListViewPaddingTop));
}
}
invalidateChatListViewTopPadding = false;
}
use of org.telegram.messenger.MessageObject in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method deleteHistory.
public void deleteHistory(int dateSelectedStart, int dateSelectedEnd, boolean forAll) {
chatAdapter.frozenMessages.clear();
for (int i = 0; i < messages.size(); i++) {
MessageObject messageObject = messages.get(i);
if (messageObject.messageOwner.date <= dateSelectedStart || messageObject.messageOwner.date >= dateSelectedEnd) {
chatAdapter.frozenMessages.add(messageObject);
}
}
if (chatListView != null) {
chatListView.setEmptyView(null);
}
if (chatAdapter.frozenMessages.isEmpty()) {
showProgressView(true);
}
chatAdapter.isFrozen = true;
chatAdapter.notifyDataSetChanged(true);
getUndoView().showWithAction(dialog_id, UndoView.ACTION_CLEAR_DATES, () -> {
getMessagesController().deleteMessagesRange(dialog_id, ChatObject.isChannel(currentChat) ? dialog_id : 0, dateSelectedStart, dateSelectedEnd, forAll, () -> {
chatAdapter.frozenMessages.clear();
chatAdapter.isFrozen = false;
chatAdapter.notifyDataSetChanged(true);
showProgressView(false);
});
}, () -> {
chatAdapter.frozenMessages.clear();
chatAdapter.isFrozen = false;
chatAdapter.notifyDataSetChanged(true);
showProgressView(false);
});
}
Aggregations