Search in sources :

Example 31 with AnimatedFileDrawable

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();
}
Also used : Bitmap(android.graphics.Bitmap) ChatMessageCell(org.telegram.ui.Cells.ChatMessageCell) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) Canvas(android.graphics.Canvas) ArrayList(java.util.ArrayList) HorizontalScrollView(android.widget.HorizontalScrollView) PinnedLineView(org.telegram.ui.Components.PinnedLineView) BotCommandsMenuView(org.telegram.ui.Components.BotCommandsMenuView) ReactedHeaderView(org.telegram.ui.Components.ReactedHeaderView) PipRoundVideoView(org.telegram.ui.Components.PipRoundVideoView) SimpleTextView(org.telegram.ui.ActionBar.SimpleTextView) RecyclerView(androidx.recyclerview.widget.RecyclerView) BluredView(org.telegram.ui.Components.BluredView) InstantCameraView(org.telegram.ui.Components.InstantCameraView) ChatActivityEnterView(org.telegram.ui.Components.ChatActivityEnterView) ChatActivityEnterTopView(org.telegram.ui.Components.ChatActivityEnterTopView) ChatBigEmptyView(org.telegram.ui.Components.ChatBigEmptyView) BackupImageView(org.telegram.ui.Components.BackupImageView) TextureView(android.view.TextureView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) ImageView(android.widget.ImageView) RadialProgressView(org.telegram.ui.Components.RadialProgressView) ChatGreetingsView(org.telegram.ui.Components.ChatGreetingsView) UndoView(org.telegram.ui.Components.UndoView) CounterView(org.telegram.ui.Components.CounterView) HintView(org.telegram.ui.Components.HintView) FragmentContextView(org.telegram.ui.Components.FragmentContextView) ClippingImageView(org.telegram.ui.Components.ClippingImageView) EmojiView(org.telegram.ui.Components.EmojiView) ChecksHintView(org.telegram.ui.Components.ChecksHintView) ThemeEditorView(org.telegram.ui.Components.ThemeEditorView) View(android.view.View) SearchCounterView(org.telegram.ui.Components.SearchCounterView) ForwardingPreviewView(org.telegram.ui.Components.ForwardingPreviewView) ReactionTabHolderView(org.telegram.ui.Components.ReactionTabHolderView) TextView(android.widget.TextView) ReactedUsersListView(org.telegram.ui.Components.ReactedUsersListView) NumberTextView(org.telegram.ui.Components.NumberTextView) MessageObject(org.telegram.messenger.MessageObject) Paint(android.graphics.Paint) TextSelectionHint(org.telegram.ui.Components.TextSelectionHint) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint)

Aggregations

AnimatedFileDrawable (org.telegram.ui.Components.AnimatedFileDrawable)31 RLottieDrawable (org.telegram.ui.Components.RLottieDrawable)17 Paint (android.graphics.Paint)14 Bitmap (android.graphics.Bitmap)11 Drawable (android.graphics.drawable.Drawable)11 BitmapDrawable (android.graphics.drawable.BitmapDrawable)10 SuppressLint (android.annotation.SuppressLint)9 TextPaint (android.text.TextPaint)9 MessageObject (org.telegram.messenger.MessageObject)6 ClippingImageView (org.telegram.ui.Components.ClippingImageView)6 LoadingStickerDrawable (org.telegram.ui.Components.LoadingStickerDrawable)6 TextureView (android.view.TextureView)5 View (android.view.View)5 HorizontalScrollView (android.widget.HorizontalScrollView)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 RecyclerView (androidx.recyclerview.widget.RecyclerView)5 ImageReceiver (org.telegram.messenger.ImageReceiver)5 Canvas (android.graphics.Canvas)3 StaticLayout (android.text.StaticLayout)3