use of org.telegram.ui.Components.AnimatedFileDrawable in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatActivity method openPhotoViewerForMessage.
void openPhotoViewerForMessage(ChatMessageCell cell, MessageObject message) {
if (cell == null) {
int count = chatListView.getChildCount();
for (int a = 0; a < count; a++) {
View child = chatListView.getChildAt(a);
if (child instanceof ChatMessageCell) {
ChatMessageCell messageCell = (ChatMessageCell) child;
if (messageCell.getMessageObject().equals(message)) {
cell = messageCell;
break;
}
}
}
}
if (message.isVideo()) {
sendSecretMessageRead(message, true);
}
PhotoViewer.getInstance().setParentActivity(getParentActivity(), themeDelegate);
MessageObject playingObject = MediaController.getInstance().getPlayingMessageObject();
if (cell != null && playingObject != null && playingObject.isVideo()) {
getFileLoader().setLoadingVideoForPlayer(playingObject.getDocument(), false);
if (playingObject.equals(message)) {
AnimatedFileDrawable animation = cell.getPhotoImage().getAnimation();
if (animation != null && videoTextureView != null && videoPlayerContainer.getTag() != null) {
Bitmap bitmap = animation.getAnimatedBitmap();
if (bitmap != null) {
try {
Bitmap src = videoTextureView.getBitmap(bitmap.getWidth(), bitmap.getHeight());
Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap(src, 0, 0, null);
src.recycle();
} catch (Throwable e) {
FileLog.e(e);
}
}
}
}
MediaController.getInstance().cleanupPlayer(true, true, false, playingObject.equals(message));
}
if (chatMode == MODE_SCHEDULED && (message.isVideo() || message.type == 1)) {
PhotoViewer.getInstance().setParentChatActivity(ChatActivity.this);
ArrayList<MessageObject> arrayList = new ArrayList<>();
for (int a = 0, N = messages.size(); a < N; a++) {
MessageObject m = messages.get(a);
if (m.isVideo() || m.type == 1) {
arrayList.add(0, m);
}
}
PhotoViewer.getInstance().openPhoto(arrayList, arrayList.indexOf(message), dialog_id, 0, photoViewerProvider);
} else {
PhotoViewer.getInstance().openPhoto(message, ChatActivity.this, message.type != 0 ? dialog_id : 0, message.type != 0 ? mergeDialogId : 0, photoViewerProvider);
}
hideHints(false);
MediaController.getInstance().resetGoingToShowMessageObject();
}
Aggregations