Search in sources :

Example 16 with AnimatedFileDrawable

use of org.telegram.ui.Components.AnimatedFileDrawable in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatMessageCell method drawOverlays.

public void drawOverlays(Canvas canvas) {
    if (!drawFromPinchToZoom && delegate != null && delegate.getPinchToZoomHelper() != null && delegate.getPinchToZoomHelper().isInOverlayModeFor(this)) {
        return;
    }
    long newAnimationTime = SystemClock.elapsedRealtime();
    long animationDt = newAnimationTime - lastAnimationTime;
    if (animationDt > 17) {
        animationDt = 17;
    }
    lastAnimationTime = newAnimationTime;
    if (currentMessageObject.hadAnimationNotReadyLoading && photoImage.getVisible() && !currentMessageObject.needDrawBluredPreview() && (documentAttachType == DOCUMENT_ATTACH_TYPE_ROUND || documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF)) {
        AnimatedFileDrawable animation = photoImage.getAnimation();
        if (animation != null && animation.hasBitmap()) {
            currentMessageObject.hadAnimationNotReadyLoading = false;
            updateButtonState(false, true, false);
        }
    }
    if (hasGamePreview) {
    } else if (currentMessageObject.type == MessageObject.TYPE_VIDEO || currentMessageObject.type == MessageObject.TYPE_PHOTO || documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) {
        if (photoImage.getVisible()) {
            if (!currentMessageObject.needDrawBluredPreview()) {
                if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) {
                    int oldAlpha = ((BitmapDrawable) Theme.chat_msgMediaMenuDrawable).getPaint().getAlpha();
                    if (drawMediaCheckBox) {
                        Theme.chat_msgMediaMenuDrawable.setAlpha((int) (oldAlpha * controlsAlpha * (1.0f - checkBoxAnimationProgress)));
                    } else {
                        Theme.chat_msgMediaMenuDrawable.setAlpha((int) (oldAlpha * controlsAlpha));
                    }
                    setDrawableBounds(Theme.chat_msgMediaMenuDrawable, otherX = (int) (photoImage.getImageX() + photoImage.getImageWidth() - AndroidUtilities.dp(14)), otherY = (int) (photoImage.getImageY() + AndroidUtilities.dp(8.1f)));
                    Theme.chat_msgMediaMenuDrawable.draw(canvas);
                    Theme.chat_msgMediaMenuDrawable.setAlpha(oldAlpha);
                }
            }
            boolean playing = MediaController.getInstance().isPlayingMessage(currentMessageObject);
            if (animatingNoSoundPlaying != playing) {
                animatingNoSoundPlaying = playing;
                animatingNoSound = playing ? 1 : 2;
                animatingNoSoundProgress = playing ? 1.0f : 0.0f;
            }
            boolean fullWidth = true;
            if (currentPosition != null) {
                int mask = MessageObject.POSITION_FLAG_LEFT | MessageObject.POSITION_FLAG_RIGHT;
                fullWidth = (currentPosition.flags & mask) == mask;
            }
            if ((documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) && (buttonState == 1 || buttonState == 2 || buttonState == 0 || buttonState == 3 || buttonState == -1 || currentMessageObject.needDrawBluredPreview())) {
                if (autoPlayingMedia) {
                    updatePlayingMessageProgress();
                }
                if ((infoLayout != null || loadingProgressLayout != null) && (!forceNotDrawTime || autoPlayingMedia || drawVideoImageButton || animatingLoadingProgressProgress != 0 || (fullWidth && docTitleLayout != null) || (loadingProgressLayout != null && currentPosition != null && (buttonState == 1 || (buttonState == 3 && miniButtonState == 1))))) {
                    boolean drawLoadingProgress;
                    float alpha = 0;
                    boolean drawDocTitleLayout;
                    float loadingProgressAlpha = 1f;
                    if (!fullWidth) {
                        drawLoadingProgress = true;
                        drawDocTitleLayout = false;
                        loadingProgressAlpha = animatingLoadingProgressProgress;
                    } else {
                        drawLoadingProgress = (buttonState == 1 || miniButtonState == 1 || animatingLoadingProgressProgress != 0) && !currentMessageObject.isSecretMedia() && (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF || documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT);
                        if (currentMessageObject.type == MessageObject.TYPE_VIDEO || currentMessageObject.type == 8 || documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) {
                            alpha = currentMessageObject.needDrawBluredPreview() && docTitleLayout == null ? 0 : animatingDrawVideoImageButtonProgress;
                        }
                        drawDocTitleLayout = alpha > 0 && docTitleLayout != null;
                        if (!drawDocTitleLayout && (drawLoadingProgress || infoLayout == null)) {
                            loadingProgressAlpha = animatingLoadingProgressProgress;
                        }
                    }
                    Theme.chat_infoPaint.setColor(getThemedColor(Theme.key_chat_mediaInfoText));
                    int x1 = (int) (photoImage.getImageX() + AndroidUtilities.dp(4));
                    int y1 = (int) (photoImage.getImageY() + AndroidUtilities.dp(4));
                    int imageW;
                    int infoW;
                    if (autoPlayingMedia && (!playing || animatingNoSound != 0)) {
                        imageW = (int) ((Theme.chat_msgNoSoundDrawable.getIntrinsicWidth() + AndroidUtilities.dp(4)) * animatingNoSoundProgress);
                    } else {
                        imageW = 0;
                    }
                    if (drawLoadingProgress && loadingProgressLayout != null) {
                        imageW = 0;
                        infoW = (int) loadingProgressLayout.getLineWidth(0);
                    } else {
                        infoW = infoWidth;
                    }
                    int w = (int) Math.ceil(infoW + AndroidUtilities.dp(8) + imageW + (Math.max(infoW + (infoWidth == infoW ? imageW : 0), docTitleWidth) + (canStreamVideo ? AndroidUtilities.dp(32) : 0) - infoW - imageW) * alpha);
                    if (alpha != 0 && docTitleLayout == null) {
                        alpha = 0;
                    }
                    canvas.save();
                    canvas.scale(loadingProgressAlpha, loadingProgressAlpha, x1, y1);
                    int oldAlpha = getThemedPaint(Theme.key_paint_chatTimeBackground).getAlpha();
                    getThemedPaint(Theme.key_paint_chatTimeBackground).setAlpha((int) (oldAlpha * controlsAlpha * loadingProgressAlpha));
                    if (drawDocTitleLayout || (drawLoadingProgress && loadingProgressLayout != null) || (!drawLoadingProgress && infoLayout != null)) {
                        rect.set(x1, y1, x1 + w, y1 + AndroidUtilities.dp(16.5f + 15.5f * alpha));
                        int[] rad = photoImage.getRoundRadius();
                        int r = Math.min(AndroidUtilities.dp(8), Math.max(rad[0], rad[1]));
                        canvas.drawRoundRect(rect, r, r, getThemedPaint(Theme.key_paint_chatTimeBackground));
                    }
                    Theme.chat_infoPaint.setAlpha((int) (255 * controlsAlpha * loadingProgressAlpha));
                    canvas.translate(noSoundCenterX = (int) (photoImage.getImageX() + AndroidUtilities.dp(8 + (canStreamVideo ? 30 * alpha : 0))), photoImage.getImageY() + AndroidUtilities.dp(5.5f + 0.2f * alpha));
                    if (infoLayout != null && (!drawLoadingProgress || drawDocTitleLayout)) {
                        infoLayout.draw(canvas);
                    }
                    if (imageW != 0 && (!drawLoadingProgress || drawDocTitleLayout)) {
                        canvas.save();
                        Theme.chat_msgNoSoundDrawable.setAlpha((int) (255 * animatingNoSoundProgress * animatingNoSoundProgress * controlsAlpha));
                        int size = AndroidUtilities.dp(14 * animatingNoSoundProgress);
                        int y = (AndroidUtilities.dp(14) - size) / 2;
                        int offset = infoWidth + AndroidUtilities.dp(4);
                        canvas.translate(offset, 0);
                        Theme.chat_msgNoSoundDrawable.setBounds(0, y, size, y + size);
                        Theme.chat_msgNoSoundDrawable.draw(canvas);
                        noSoundCenterX += offset + size / 2;
                        canvas.restore();
                    }
                    if (drawLoadingProgress && loadingProgressLayout != null) {
                        canvas.save();
                        if (drawDocTitleLayout) {
                            Theme.chat_infoPaint.setAlpha((int) (255 * controlsAlpha * alpha));
                            canvas.translate(0, AndroidUtilities.dp(14.3f * alpha));
                        }
                        loadingProgressLayout.draw(canvas);
                        canvas.restore();
                    } else if (drawDocTitleLayout) {
                        Theme.chat_infoPaint.setAlpha((int) (255 * controlsAlpha * alpha));
                        canvas.translate(0, AndroidUtilities.dp(14.3f * alpha));
                        docTitleLayout.draw(canvas);
                    }
                    canvas.restore();
                    Theme.chat_infoPaint.setAlpha(255);
                    getThemedPaint(Theme.key_paint_chatTimeBackground).setAlpha(oldAlpha);
                }
            }
            if (animatingDrawVideoImageButton == 1) {
                animatingDrawVideoImageButtonProgress -= animationDt / 160.0f;
                if (animatingDrawVideoImageButtonProgress <= 0) {
                    animatingDrawVideoImageButtonProgress = 0;
                    animatingDrawVideoImageButton = 0;
                }
                invalidate();
            } else if (animatingDrawVideoImageButton == 2) {
                animatingDrawVideoImageButtonProgress += animationDt / 160.0f;
                if (animatingDrawVideoImageButtonProgress >= 1) {
                    animatingDrawVideoImageButtonProgress = 1;
                    animatingDrawVideoImageButton = 0;
                }
                invalidate();
            }
            if (animatingNoSound == 1) {
                animatingNoSoundProgress -= animationDt / 180.0f;
                if (animatingNoSoundProgress <= 0.0f) {
                    animatingNoSoundProgress = 0.0f;
                    animatingNoSound = 0;
                }
                invalidate();
            } else if (animatingNoSound == 2) {
                animatingNoSoundProgress += animationDt / 180.0f;
                if (animatingNoSoundProgress >= 1.0f) {
                    animatingNoSoundProgress = 1.0f;
                    animatingNoSound = 0;
                }
                invalidate();
            }
            float animatingToLoadingProgress = (buttonState == 1 || miniButtonState == 1) && loadingProgressLayout != null ? 1f : 0f;
            if (animatingToLoadingProgress == 0f && infoLayout != null && fullWidth) {
                animatingLoadingProgressProgress = 0f;
            }
            if (animatingLoadingProgressProgress < animatingToLoadingProgress) {
                animatingLoadingProgressProgress += animationDt / 160.0f;
                if (animatingLoadingProgressProgress > animatingToLoadingProgress) {
                    animatingLoadingProgressProgress = animatingToLoadingProgress;
                }
                invalidate();
            } else if (animatingLoadingProgressProgress != animatingToLoadingProgress) {
                animatingLoadingProgressProgress -= animationDt / 160.0f;
                if (animatingLoadingProgressProgress < animatingToLoadingProgress) {
                    animatingLoadingProgressProgress = animatingToLoadingProgress;
                }
                invalidate();
            }
        }
    } else if (currentMessageObject.type == MessageObject.TYPE_GEO) {
        if (docTitleLayout != null) {
            if (currentMessageObject.isOutOwner()) {
                Theme.chat_locationTitlePaint.setColor(getThemedColor(Theme.key_chat_messageTextOut));
                Theme.chat_locationAddressPaint.setColor(getThemedColor(isDrawSelectionBackground() ? Theme.key_chat_outVenueInfoSelectedText : Theme.key_chat_outVenueInfoText));
            } else {
                Theme.chat_locationTitlePaint.setColor(getThemedColor(Theme.key_chat_messageTextIn));
                Theme.chat_locationAddressPaint.setColor(getThemedColor(isDrawSelectionBackground() ? Theme.key_chat_inVenueInfoSelectedText : Theme.key_chat_inVenueInfoText));
            }
            if (currentMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeoLive) {
                int cy = (int) (photoImage.getImageY2() + AndroidUtilities.dp(30));
                if (!locationExpired || transitionParams.animateLocationIsExpired) {
                    forceNotDrawTime = true;
                    float progress;
                    String text;
                    StaticLayout docTitleLayout = this.docTitleLayout;
                    StaticLayout infoLayout = this.infoLayout;
                    float alpha = 1f;
                    if (transitionParams.animateLocationIsExpired) {
                        progress = transitionParams.lastDrawLocationExpireProgress;
                        text = transitionParams.lastDrawLocationExpireText;
                        docTitleLayout = transitionParams.lastDrawDocTitleLayout;
                        infoLayout = transitionParams.lastDrawInfoLayout;
                        alpha = 1f - transitionParams.animateChangeProgress;
                    } else {
                        progress = 1.0f - Math.abs(ConnectionsManager.getInstance(currentAccount).getCurrentTime() - currentMessageObject.messageOwner.date) / (float) currentMessageObject.messageOwner.media.period;
                        text = LocaleController.formatLocationLeftTime(Math.abs(currentMessageObject.messageOwner.media.period - (ConnectionsManager.getInstance(currentAccount).getCurrentTime() - currentMessageObject.messageOwner.date)));
                    }
                    rect.set(photoImage.getImageX2() - AndroidUtilities.dp(43), cy - AndroidUtilities.dp(15), photoImage.getImageX2() - AndroidUtilities.dp(13), cy + AndroidUtilities.dp(15));
                    if (currentMessageObject.isOutOwner()) {
                        Theme.chat_radialProgress2Paint.setColor(getThemedColor(Theme.key_chat_outInstant));
                        Theme.chat_livePaint.setColor(getThemedColor(Theme.key_chat_outInstant));
                    } else {
                        Theme.chat_radialProgress2Paint.setColor(getThemedColor(Theme.key_chat_inInstant));
                        Theme.chat_livePaint.setColor(getThemedColor(Theme.key_chat_inInstant));
                    }
                    int docTitleAlpha = Theme.chat_locationTitlePaint.getAlpha();
                    int infoAlpha = Theme.chat_locationAddressPaint.getAlpha();
                    int liveAplha = Theme.chat_livePaint.getAlpha();
                    if (alpha != 1f) {
                        Theme.chat_locationTitlePaint.setAlpha((int) (docTitleAlpha * alpha));
                        Theme.chat_locationAddressPaint.setAlpha((int) (infoAlpha * alpha));
                        Theme.chat_livePaint.setAlpha((int) (liveAplha * alpha));
                        canvas.save();
                        canvas.translate(0, -AndroidUtilities.dp(50) * transitionParams.animateChangeProgress);
                    }
                    Theme.chat_radialProgress2Paint.setAlpha((int) (50 * alpha));
                    canvas.drawCircle(rect.centerX(), rect.centerY(), AndroidUtilities.dp(15), Theme.chat_radialProgress2Paint);
                    Theme.chat_radialProgress2Paint.setAlpha((int) (255 * alpha));
                    canvas.drawArc(rect, -90, -360 * progress, false, Theme.chat_radialProgress2Paint);
                    float w = Theme.chat_livePaint.measureText(text);
                    canvas.drawText(text, rect.centerX() - w / 2, cy + AndroidUtilities.dp(4), Theme.chat_livePaint);
                    if (docTitleLayout != null && infoLayout != null) {
                        canvas.save();
                        canvas.translate(photoImage.getImageX() + AndroidUtilities.dp(10), photoImage.getImageY2() + AndroidUtilities.dp(10));
                        docTitleLayout.draw(canvas);
                        canvas.translate(0, AndroidUtilities.dp(23));
                        infoLayout.draw(canvas);
                        canvas.restore();
                    }
                    if (alpha != 1f) {
                        Theme.chat_locationTitlePaint.setAlpha(docTitleAlpha);
                        Theme.chat_locationAddressPaint.setAlpha(infoAlpha);
                        Theme.chat_livePaint.setAlpha(liveAplha);
                        canvas.restore();
                    }
                    transitionParams.lastDrawLocationExpireProgress = progress;
                    transitionParams.lastDrawLocationExpireText = text;
                    transitionParams.lastDrawDocTitleLayout = docTitleLayout;
                    transitionParams.lastDrawInfoLayout = infoLayout;
                } else {
                    transitionParams.lastDrawLocationExpireText = null;
                    transitionParams.lastDrawDocTitleLayout = null;
                    transitionParams.lastDrawInfoLayout = null;
                }
                int cx = (int) (photoImage.getImageX() + photoImage.getImageWidth() / 2 - AndroidUtilities.dp(31));
                cy = (int) (photoImage.getImageY() + photoImage.getImageHeight() / 2 - AndroidUtilities.dp(38));
                setDrawableBounds(Theme.chat_msgAvatarLiveLocationDrawable, cx, cy);
                Theme.chat_msgAvatarLiveLocationDrawable.draw(canvas);
                locationImageReceiver.setImageCoords(cx + AndroidUtilities.dp(5.0f), cy + AndroidUtilities.dp(5.0f), AndroidUtilities.dp(52), AndroidUtilities.dp(52));
                locationImageReceiver.draw(canvas);
            } else {
                canvas.save();
                canvas.translate(photoImage.getImageX() + AndroidUtilities.dp(6), photoImage.getImageY2() + AndroidUtilities.dp(8));
                docTitleLayout.draw(canvas);
                if (infoLayout != null) {
                    canvas.translate(0, AndroidUtilities.dp(21));
                    infoLayout.draw(canvas);
                }
                canvas.restore();
            }
        }
    } else if (currentMessageObject.type == 16) {
        if (currentMessageObject.isOutOwner()) {
            Theme.chat_audioTitlePaint.setColor(getThemedColor(Theme.key_chat_messageTextOut));
            Theme.chat_contactPhonePaint.setColor(getThemedColor(isDrawSelectionBackground() ? Theme.key_chat_outTimeSelectedText : Theme.key_chat_outTimeText));
        } else {
            Theme.chat_audioTitlePaint.setColor(getThemedColor(Theme.key_chat_messageTextIn));
            Theme.chat_contactPhonePaint.setColor(getThemedColor(isDrawSelectionBackground() ? Theme.key_chat_inTimeSelectedText : Theme.key_chat_inTimeText));
        }
        forceNotDrawTime = true;
        int x;
        if (currentMessageObject.isOutOwner()) {
            x = layoutWidth - backgroundWidth + AndroidUtilities.dp(16);
        } else {
            if (isChat && !isThreadPost && currentMessageObject.needDrawAvatar()) {
                x = AndroidUtilities.dp(74);
            } else {
                x = AndroidUtilities.dp(25);
            }
        }
        otherX = x;
        if (titleLayout != null) {
            canvas.save();
            canvas.translate(x, AndroidUtilities.dp(12) + namesOffset);
            titleLayout.draw(canvas);
            canvas.restore();
        }
        if (docTitleLayout != null) {
            canvas.save();
            canvas.translate(x + AndroidUtilities.dp(19), AndroidUtilities.dp(37) + namesOffset);
            docTitleLayout.draw(canvas);
            canvas.restore();
        }
        Drawable icon;
        Drawable phone;
        int idx = currentMessageObject.isVideoCall() ? 1 : 0;
        if (currentMessageObject.isOutOwner()) {
            icon = Theme.chat_msgCallUpGreenDrawable;
            if (currentMessageObject.isVideoCall()) {
                phone = getThemedDrawable(isDrawSelectionBackground() ? Theme.key_drawable_msgOutCallVideoSelected : Theme.key_drawable_msgOutCallVideo);
            } else {
                phone = getThemedDrawable(isDrawSelectionBackground() ? Theme.key_drawable_msgOutCallAudioSelected : Theme.key_drawable_msgOutCallAudio);
            }
        } else {
            TLRPC.PhoneCallDiscardReason reason = currentMessageObject.messageOwner.action.reason;
            if (reason instanceof TLRPC.TL_phoneCallDiscardReasonMissed || reason instanceof TLRPC.TL_phoneCallDiscardReasonBusy) {
                icon = Theme.chat_msgCallDownRedDrawable;
            } else {
                icon = Theme.chat_msgCallDownGreenDrawable;
            }
            phone = isDrawSelectionBackground() ? Theme.chat_msgInCallSelectedDrawable[idx] : Theme.chat_msgInCallDrawable[idx];
        }
        setDrawableBounds(icon, x - AndroidUtilities.dp(1), AndroidUtilities.dp(37) + namesOffset);
        icon.draw(canvas);
        if (Build.VERSION.SDK_INT >= 21 && selectorDrawable[0] != null && selectorDrawableMaskType[0] == 4) {
            selectorDrawable[0].draw(canvas);
        }
        if (!pinnedBottom && !pinnedTop) {
            otherY = AndroidUtilities.dp(18.5f);
        } else if (pinnedBottom && pinnedTop) {
            otherY = AndroidUtilities.dp(18);
        } else if (!pinnedBottom) {
            otherY = AndroidUtilities.dp(17);
        } else {
            otherY = AndroidUtilities.dp(19);
        }
        setDrawableBounds(phone, x + AndroidUtilities.dp(idx == 0 ? 201 : 200), otherY);
        phone.draw(canvas);
    } else if (currentMessageObject.type == MessageObject.TYPE_POLL) {
        long newTime = System.currentTimeMillis();
        long dt = newTime - voteLastUpdateTime;
        if (dt > 17) {
            dt = 17;
        }
        voteLastUpdateTime = newTime;
        int color1;
        int color2;
        if (currentMessageObject.isOutOwner()) {
            color1 = getThemedColor(Theme.key_chat_messageTextOut);
            color2 = getThemedColor(isDrawSelectionBackground() ? Theme.key_chat_outTimeSelectedText : Theme.key_chat_outTimeText);
        } else {
            color1 = getThemedColor(Theme.key_chat_messageTextIn);
            color2 = getThemedColor(isDrawSelectionBackground() ? Theme.key_chat_inTimeSelectedText : Theme.key_chat_inTimeText);
        }
        Theme.chat_audioTitlePaint.setColor(color1);
        Theme.chat_audioPerformerPaint.setColor(color1);
        Theme.chat_instantViewPaint.setColor(color1);
        Theme.chat_timePaint.setColor(color2);
        Theme.chat_livePaint.setColor(color2);
        Theme.chat_locationAddressPaint.setColor(color2);
        canvas.save();
        if (transitionParams.animateForwardedLayout) {
            float y = namesOffset * transitionParams.animateChangeProgress + transitionParams.animateForwardedNamesOffset * (1f - transitionParams.animateChangeProgress);
            if (currentMessageObject.needDrawForwarded()) {
                y -= namesOffset;
            }
            canvas.translate(0, y);
        }
        int x;
        if (currentMessageObject.isOutOwner()) {
            x = layoutWidth - backgroundWidth + AndroidUtilities.dp(11);
        } else {
            if (isChat && !isThreadPost && currentMessageObject.needDrawAvatar()) {
                x = AndroidUtilities.dp(68);
            } else {
                x = AndroidUtilities.dp(20);
            }
        }
        if (titleLayout != null) {
            canvas.save();
            canvas.translate(x + getExtraTextX(), AndroidUtilities.dp(15) + namesOffset);
            titleLayout.draw(canvas);
            canvas.restore();
        }
        int y = (titleLayout != null ? titleLayout.getHeight() : 0) + AndroidUtilities.dp(20) + namesOffset;
        if (docTitleLayout != null) {
            canvas.save();
            canvas.translate(x + docTitleOffsetX + getExtraTextX(), y);
            docTitleLayout.draw(canvas);
            canvas.restore();
            TLRPC.TL_messageMediaPoll media = (TLRPC.TL_messageMediaPoll) currentMessageObject.messageOwner.media;
            if (lastPoll.quiz && (pollVoted || pollClosed) && !TextUtils.isEmpty(media.results.solution)) {
                Drawable drawable = getThemedDrawable(currentMessageObject.isOutOwner() ? Theme.key_drawable_chat_pollHintDrawableOut : Theme.key_drawable_chat_pollHintDrawableIn);
                if (pollVoteInProgress) {
                    drawable.setAlpha((int) (255 * pollAnimationProgress));
                } else {
                    drawable.setAlpha(255);
                }
                if (docTitleOffsetX < 0 || docTitleOffsetX == 0 && docTitleLayout.getLineLeft(0) == 0) {
                    pollHintX = currentBackgroundDrawable.getBounds().right - drawable.getIntrinsicWidth() - AndroidUtilities.dp(currentMessageObject.isOutOwner() ? 17 : 11);
                } else {
                    pollHintX = getCurrentBackgroundLeft() + AndroidUtilities.dp(11);
                }
                pollHintY = y - AndroidUtilities.dp(6);
                int cx = pollHintX + drawable.getIntrinsicWidth() / 2;
                int cy = pollHintY + drawable.getIntrinsicHeight() / 2;
                float scale = hintButtonVisible && hintButtonProgress < 1 ? AnimationProperties.overshootInterpolator.getInterpolation(hintButtonProgress) : hintButtonProgress;
                int w = (int) (drawable.getIntrinsicWidth() * scale);
                int h = (int) (drawable.getIntrinsicHeight() * scale);
                drawable.setBounds(cx - w / 2, cy - h / 2, cx + w / 2, cy + h / 2);
                drawable.draw(canvas);
            } else {
                pollHintX = -1;
            }
            if (pollAvatarImages != null && !isBot) {
                int toAdd;
                int ax;
                int lineLeft = (int) Math.ceil(docTitleLayout.getLineLeft(0));
                if (docTitleOffsetX != 0 || lineLeft != 0) {
                    toAdd = -AndroidUtilities.dp(13);
                    if (docTitleOffsetX != 0) {
                        ax = x + docTitleOffsetX - AndroidUtilities.dp(7 + 16) - getExtraTextX();
                    } else {
                        ax = x + lineLeft - AndroidUtilities.dp(7 + 16) - getExtraTextX();
                    }
                } else {
                    toAdd = AndroidUtilities.dp(13);
                    ax = x + (int) Math.ceil(docTitleLayout.getLineWidth(0)) + AndroidUtilities.dp(7) + getExtraTextX();
                }
                for (int a = pollAvatarImages.length - 1; a >= 0; a--) {
                    if (!pollAvatarImagesVisible[a] || !pollAvatarImages[a].hasImageSet()) {
                        continue;
                    }
                    pollAvatarImages[a].setImageX(ax + toAdd * a);
                    pollAvatarImages[a].setImageY(y - AndroidUtilities.dp(1));
                    if (a != pollAvatarImages.length - 1) {
                        canvas.drawCircle(pollAvatarImages[a].getCenterX(), pollAvatarImages[a].getCenterY(), AndroidUtilities.dp(9), currentBackgroundDrawable.getPaint());
                    }
                    if (animatePollAvatars && animatePollAnswerAlpha) {
                        float alpha = Math.min(pollUnvoteInProgress ? (1.0f - pollAnimationProgress) / 0.3f : pollAnimationProgress, 1.0f);
                        pollAvatarImages[a].setAlpha(alpha);
                    }
                    pollAvatarImages[a].draw(canvas);
                }
            }
        }
        if ((!pollClosed && !pollVoted || pollVoteInProgress) && lastPoll.quiz && lastPoll.close_period != 0) {
            long currentTime = ConnectionsManager.getInstance(currentAccount).getCurrentTimeMillis();
            long time = Math.max(0, ((long) lastPoll.close_date) * 1000 - currentTime);
            if (closeTimeText == null || lastPollCloseTime != time) {
                closeTimeText = AndroidUtilities.formatDurationNoHours((int) Math.ceil(time / 1000.0f), false);
                closeTimeWidth = (int) Math.ceil(Theme.chat_timePaint.measureText(closeTimeText));
                lastPollCloseTime = time;
            }
            if (time <= 0 && !pollClosed) {
                if (currentMessageObject.pollLastCheckTime + 1000 < SystemClock.elapsedRealtime()) {
                    currentMessageObject.pollLastCheckTime = 0;
                }
                delegate.needReloadPolls();
            }
            int tx = currentBackgroundDrawable.getBounds().right - closeTimeWidth - AndroidUtilities.dp(currentMessageObject.isOutOwner() ? 40 : 34);
            if (time <= 5000) {
                Theme.chat_timePaint.setColor(getThemedColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outPollWrongAnswer : Theme.key_chat_inPollWrongAnswer));
            }
            if (animatePollAnswer) {
                Theme.chat_timePaint.setAlpha((int) (255 * (1.0f - pollAnimationProgress)));
            }
            canvas.drawText(closeTimeText, tx, y + AndroidUtilities.dp(11), Theme.chat_timePaint);
            Theme.chat_pollTimerPaint.setColor(Theme.chat_timePaint.getColor());
            tx += closeTimeWidth + AndroidUtilities.dp(13);
            int rad = AndroidUtilities.dp(5.1f);
            int ty = y + AndroidUtilities.dp(6);
            if (time <= 60000) {
                rect.set(tx - rad, ty - rad, tx + rad, ty + rad);
                float radProgress = -360 * (time / (Math.min(60, lastPoll.close_period) * 1000.0f));
                canvas.drawArc(rect, -90, radProgress, false, Theme.chat_pollTimerPaint);
                timerParticles.draw(canvas, Theme.chat_pollTimerPaint, rect, radProgress, pollVoteInProgress ? (1.0f - pollAnimationProgress) : 1.0f);
            } else {
                canvas.drawCircle(tx, ty, rad, Theme.chat_pollTimerPaint);
            }
            if (time > 60000 || timerTransitionProgress != 0.0f) {
                Theme.chat_pollTimerPaint.setAlpha((int) (255 * timerTransitionProgress));
                canvas.drawLine(tx - AndroidUtilities.dp(2.1f) * timerTransitionProgress, ty - AndroidUtilities.dp(7.5f), tx + AndroidUtilities.dp(2.1f) * timerTransitionProgress, ty - AndroidUtilities.dp(7.5f), Theme.chat_pollTimerPaint);
                canvas.drawLine(tx, ty - AndroidUtilities.dp(3) * timerTransitionProgress, tx, ty, Theme.chat_pollTimerPaint);
                if (time <= 60000) {
                    timerTransitionProgress -= dt / 180.0f;
                    if (timerTransitionProgress < 0) {
                        timerTransitionProgress = 0;
                    }
                }
            }
            invalidate();
        }
        if (Build.VERSION.SDK_INT >= 21 && selectorDrawable[0] != null && (selectorDrawableMaskType[0] == 1 || selectorDrawableMaskType[0] == 3)) {
            if (selectorDrawableMaskType[0] == 3) {
                canvas.save();
                canvas.scale(hintButtonProgress, hintButtonProgress, selectorDrawable[0].getBounds().centerX(), selectorDrawable[0].getBounds().centerY());
            }
            selectorDrawable[0].draw(canvas);
            if (selectorDrawableMaskType[0] == 3) {
                canvas.restore();
            }
        }
        int lastVoteY = 0;
        for (int a = 0, N = pollButtons.size(); a < N; a++) {
            PollButton button = pollButtons.get(a);
            button.x = x;
            canvas.save();
            canvas.translate(x + AndroidUtilities.dp(35), button.y + namesOffset);
            button.title.draw(canvas);
            int alpha = (int) (animatePollAnswerAlpha ? 255 * Math.min((pollUnvoteInProgress ? 1.0f - pollAnimationProgress : pollAnimationProgress) / 0.3f, 1.0f) : 255);
            if (pollVoted || pollClosed || animatePollAnswerAlpha) {
                if (lastPoll.quiz && pollVoted && button.chosen) {
                    String key;
                    if (button.correct) {
                        key = currentMessageObject.isOutOwner() ? Theme.key_chat_outPollCorrectAnswer : Theme.key_chat_inPollCorrectAnswer;
                    } else {
                        key = currentMessageObject.isOutOwner() ? Theme.key_chat_outPollWrongAnswer : Theme.key_chat_inPollWrongAnswer;
                    }
                    if (!currentBackgroundDrawable.hasGradient() || Theme.hasThemeKey(key)) {
                        Theme.chat_docBackPaint.setColor(getThemedColor(key));
                    } else {
                        Theme.chat_docBackPaint.setColor(getThemedColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outAudioSeekbarFill : Theme.key_chat_inAudioSeekbarFill));
                    }
                } else {
                    Theme.chat_docBackPaint.setColor(getThemedColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outAudioSeekbarFill : Theme.key_chat_inAudioSeekbarFill));
                }
                if (animatePollAnswerAlpha) {
                    float oldAlpha = Theme.chat_instantViewPaint.getAlpha() / 255.0f;
                    Theme.chat_instantViewPaint.setAlpha((int) (alpha * oldAlpha));
                    oldAlpha = Theme.chat_docBackPaint.getAlpha() / 255.0f;
                    Theme.chat_docBackPaint.setAlpha((int) (alpha * oldAlpha));
                }
                int currentPercent = (int) Math.ceil(button.prevPercent + (button.percent - button.prevPercent) * pollAnimationProgress);
                String text = String.format("%d%%", currentPercent);
                int width = (int) Math.ceil(Theme.chat_instantViewPaint.measureText(text));
                canvas.drawText(text, -AndroidUtilities.dp(6.5f) - width, AndroidUtilities.dp(14), Theme.chat_instantViewPaint);
                width = backgroundWidth - AndroidUtilities.dp(76);
                float currentPercentProgress = button.prevPercentProgress + (button.percentProgress - button.prevPercentProgress) * pollAnimationProgress;
                rect.set(0, button.height + AndroidUtilities.dp(6), width * currentPercentProgress, button.height + AndroidUtilities.dp(11));
                canvas.drawRoundRect(rect, AndroidUtilities.dp(2), AndroidUtilities.dp(2), Theme.chat_docBackPaint);
                if (button.chosen || button.prevChosen || lastPoll.quiz && button.correct && (pollVoted || pollClosed)) {
                    float cx = rect.left - AndroidUtilities.dp(13.5f);
                    float cy = rect.centerY();
                    canvas.drawCircle(cx, cy, AndroidUtilities.dp(7), Theme.chat_docBackPaint);
                    Drawable drawable;
                    if (lastPoll.quiz && button.chosen && !button.correct) {
                        drawable = Theme.chat_pollCrossDrawable[currentMessageObject.isOutOwner() ? 1 : 0];
                    } else {
                        drawable = Theme.chat_pollCheckDrawable[currentMessageObject.isOutOwner() ? 1 : 0];
                    }
                    drawable.setAlpha(alpha);
                    setDrawableBounds(drawable, cx - drawable.getIntrinsicWidth() / 2, cy - drawable.getIntrinsicHeight() / 2);
                    drawable.draw(canvas);
                }
            }
            if (!pollVoted && !pollClosed || animatePollAnswerAlpha) {
                if (isDrawSelectionBackground()) {
                    Theme.chat_replyLinePaint.setColor(getThemedColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outVoiceSeekbarSelected : Theme.key_chat_inVoiceSeekbarSelected));
                } else {
                    Theme.chat_replyLinePaint.setColor(getThemedColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outVoiceSeekbar : Theme.key_chat_inVoiceSeekbar));
                }
                if (animatePollAnswerAlpha) {
                    float oldAlpha = Theme.chat_replyLinePaint.getAlpha() / 255.0f;
                    Theme.chat_replyLinePaint.setAlpha((int) ((255 - alpha) * oldAlpha));
                }
                canvas.drawLine(-AndroidUtilities.dp(2), button.height + AndroidUtilities.dp(13), backgroundWidth - AndroidUtilities.dp(58), button.height + AndroidUtilities.dp(13), Theme.chat_replyLinePaint);
                if (pollVoteInProgress && a == pollVoteInProgressNum) {
                    Theme.chat_instantViewRectPaint.setColor(getThemedColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outAudioSeekbarFill : Theme.key_chat_inAudioSeekbarFill));
                    if (animatePollAnswerAlpha) {
                        float oldAlpha = Theme.chat_instantViewRectPaint.getAlpha() / 255.0f;
                        Theme.chat_instantViewRectPaint.setAlpha((int) ((255 - alpha) * oldAlpha));
                    }
                    rect.set(-AndroidUtilities.dp(22) - AndroidUtilities.dp(8.5f), AndroidUtilities.dp(9) - AndroidUtilities.dp(8.5f), -AndroidUtilities.dp(23) + AndroidUtilities.dp(8.5f), AndroidUtilities.dp(9) + AndroidUtilities.dp(8.5f));
                    canvas.drawArc(rect, voteRadOffset, voteCurrentCircleLength, false, Theme.chat_instantViewRectPaint);
                } else {
                    if (currentMessageObject.isOutOwner()) {
                        Theme.chat_instantViewRectPaint.setColor(getThemedColor(isDrawSelectionBackground() ? Theme.key_chat_outMenuSelected : Theme.key_chat_outMenu));
                    } else {
                        Theme.chat_instantViewRectPaint.setColor(getThemedColor(isDrawSelectionBackground() ? Theme.key_chat_inMenuSelected : Theme.key_chat_inMenu));
                    }
                    if (animatePollAnswerAlpha) {
                        float oldAlpha = Theme.chat_instantViewRectPaint.getAlpha() / 255.0f;
                        Theme.chat_instantViewRectPaint.setAlpha((int) ((255 - alpha) * oldAlpha));
                    }
                    canvas.drawCircle(-AndroidUtilities.dp(22), AndroidUtilities.dp(9), AndroidUtilities.dp(8.5f), Theme.chat_instantViewRectPaint);
                    if (lastPoll.multiple_choice) {
                        int size = AndroidUtilities.dp(8.5f);
                        String key = Theme.key_checkboxCheck;
                        if (currentMessageObject.isOutOwner()) {
                            if (getThemedColor(key) == 0xffffffff) {
                                key = Theme.key_chat_outBubble;
                            }
                        }
                        pollCheckBox[a].setColor(null, currentMessageObject.isOutOwner() ? Theme.key_chat_outAudioSeekbarFill : Theme.key_chat_inAudioSeekbarFill, key);
                        pollCheckBox[a].setBounds(-AndroidUtilities.dp(22) - size / 2, AndroidUtilities.dp(9) - size / 2, size, size);
                        pollCheckBox[a].draw(canvas);
                    }
                }
            }
            canvas.restore();
            if (a == N - 1) {
                lastVoteY = button.y + namesOffset + button.height;
            }
        }
        if (drawInstantView) {
            int textX = getCurrentBackgroundLeft() + AndroidUtilities.dp(currentMessageObject.isOutOwner() || mediaBackground || drawPinnedBottom ? 2 : 8);
            int instantY = lastVoteY + AndroidUtilities.dp(13);
            if (currentMessageObject.isOutOwner()) {
                Theme.chat_instantViewPaint.setColor(getThemedColor(Theme.key_chat_outPreviewInstantText));
            } else {
                Theme.chat_instantViewPaint.setColor(getThemedColor(Theme.key_chat_inPreviewInstantText));
            }
            instantButtonRect.set(textX, instantY, textX + instantWidth, instantY + AndroidUtilities.dp(44));
            if (selectorDrawable[0] != null && selectorDrawableMaskType[0] == 2) {
                selectorDrawable[0].setBounds(textX, instantY, textX + instantWidth, instantY + AndroidUtilities.dp(44));
                selectorDrawable[0].draw(canvas);
            }
            if (instantViewLayout != null) {
                canvas.save();
                canvas.translate(textX + instantTextX, instantY + AndroidUtilities.dp(14.5f));
                instantViewLayout.draw(canvas);
                canvas.restore();
            }
        } else if (infoLayout != null) {
            if (lastPoll.public_voters || lastPoll.multiple_choice) {
                lastVoteY += AndroidUtilities.dp(6);
            }
            canvas.save();
            canvas.translate(x + infoX, lastVoteY + AndroidUtilities.dp(22));
            infoLayout.draw(canvas);
            canvas.restore();
        }
        updatePollAnimations(dt);
        canvas.restore();
    } else if (currentMessageObject.type == 12) {
        if (currentMessageObject.isOutOwner()) {
            Theme.chat_contactNamePaint.setColor(getThemedColor(Theme.key_chat_outContactNameText));
            Theme.chat_contactPhonePaint.setColor(getThemedColor(isDrawSelectionBackground() ? Theme.key_chat_outContactPhoneSelectedText : Theme.key_chat_outContactPhoneText));
        } else {
            Theme.chat_contactNamePaint.setColor(getThemedColor(Theme.key_chat_inContactNameText));
            Theme.chat_contactPhonePaint.setColor(getThemedColor(isDrawSelectionBackground() ? Theme.key_chat_inContactPhoneSelectedText : Theme.key_chat_inContactPhoneText));
        }
        if (titleLayout != null) {
            canvas.save();
            canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(16) + namesOffset);
            titleLayout.draw(canvas);
            canvas.restore();
        }
        if (docTitleLayout != null) {
            canvas.save();
            canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(39) + namesOffset);
            docTitleLayout.draw(canvas);
            canvas.restore();
        }
        Drawable menuDrawable;
        if (currentMessageObject.isOutOwner()) {
            menuDrawable = getThemedDrawable(isDrawSelectionBackground() ? Theme.key_drawable_msgOutMenuSelected : Theme.key_drawable_msgOutMenu);
        } else {
            menuDrawable = isDrawSelectionBackground() ? Theme.chat_msgInMenuSelectedDrawable : Theme.chat_msgInMenuDrawable;
        }
        setDrawableBounds(menuDrawable, otherX = (int) (photoImage.getImageX() + backgroundWidth - AndroidUtilities.dp(48)), otherY = (int) (photoImage.getImageY() - AndroidUtilities.dp(2)));
        menuDrawable.draw(canvas);
        if (drawInstantView) {
            int textX = (int) (photoImage.getImageX() - AndroidUtilities.dp(2));
            int instantY = layoutHeight - AndroidUtilities.dp(36 + 30);
            if (!reactionsLayoutInBubble.isEmpty && !reactionsLayoutInBubble.isSmall) {
                instantY -= reactionsLayoutInBubble.totalHeight;
            }
            Paint backPaint = Theme.chat_instantViewRectPaint;
            if (currentMessageObject.isOutOwner()) {
                Theme.chat_instantViewPaint.setColor(getThemedColor(Theme.key_chat_outPreviewInstantText));
                backPaint.setColor(getThemedColor(Theme.key_chat_outPreviewInstantText));
            } else {
                Theme.chat_instantViewPaint.setColor(getThemedColor(Theme.key_chat_inPreviewInstantText));
                backPaint.setColor(getThemedColor(Theme.key_chat_inPreviewInstantText));
            }
            instantButtonRect.set(textX, instantY, textX + instantWidth, instantY + AndroidUtilities.dp(36));
            if (Build.VERSION.SDK_INT >= 21) {
                selectorDrawableMaskType[0] = 0;
                selectorDrawable[0].setBounds(textX, instantY, textX + instantWidth, instantY + AndroidUtilities.dp(36));
                selectorDrawable[0].draw(canvas);
            }
            canvas.drawRoundRect(instantButtonRect, AndroidUtilities.dp(6), AndroidUtilities.dp(6), backPaint);
            if (instantViewLayout != null) {
                canvas.save();
                canvas.translate(textX + instantTextX, instantY + AndroidUtilities.dp(10.5f));
                instantViewLayout.draw(canvas);
                canvas.restore();
            }
        }
    }
    if (drawImageButton && photoImage.getVisible()) {
        if (controlsAlpha != 1.0f) {
            radialProgress.setOverrideAlpha(controlsAlpha);
        }
        if (photoImage.hasImageSet()) {
            radialProgress.setBackgroundDrawable(null);
        } else {
            radialProgress.setBackgroundDrawable(isDrawSelectionBackground() ? currentBackgroundSelectedDrawable : currentBackgroundDrawable);
        }
        if (!currentMessageObject.needDrawBluredPreview() || !MediaController.getInstance().isPlayingMessage(currentMessageObject)) {
            radialProgress.draw(canvas);
        }
    }
    if (buttonState == -1 && currentMessageObject.needDrawBluredPreview() && !MediaController.getInstance().isPlayingMessage(currentMessageObject) && photoImage.getVisible() && currentMessageObject.messageOwner.destroyTime != 0) {
        if (!currentMessageObject.isOutOwner()) {
            long msTime = System.currentTimeMillis() + ConnectionsManager.getInstance(currentAccount).getTimeDifference() * 1000;
            float progress = Math.max(0, (long) currentMessageObject.messageOwner.destroyTime * 1000 - msTime) / (currentMessageObject.messageOwner.ttl * 1000.0f);
            Theme.chat_deleteProgressPaint.setAlpha((int) (255 * controlsAlpha));
            canvas.drawArc(deleteProgressRect, -90, -360 * progress, true, Theme.chat_deleteProgressPaint);
            if (progress != 0) {
                int offset = AndroidUtilities.dp(2);
                invalidate((int) deleteProgressRect.left - offset, (int) deleteProgressRect.top - offset, (int) deleteProgressRect.right + offset * 2, (int) deleteProgressRect.bottom + offset * 2);
            }
        }
        updateSecretTimeText(currentMessageObject);
    }
    if ((drawVideoImageButton || animatingDrawVideoImageButton != 0) && photoImage.getVisible()) {
        if (controlsAlpha != 1.0f) {
            videoRadialProgress.setOverrideAlpha(controlsAlpha);
        }
        videoRadialProgress.draw(canvas);
    }
    if (drawMediaCheckBox) {
        if (documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC || documentAttachType == DOCUMENT_ATTACH_TYPE_DOCUMENT && !drawPhotoImage) {
            int size = AndroidUtilities.dp(20);
            mediaCheckBox.setBackgroundType(radialProgress.getMiniIcon() != MediaActionDrawable.ICON_NONE ? 12 : 13);
            mediaCheckBox.setBounds(buttonX + AndroidUtilities.dp(28), buttonY + AndroidUtilities.dp(28), size, size);
            mediaCheckBox.setColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outTimeText : Theme.key_chat_inTimeText, currentMessageObject.isOutOwner() ? Theme.key_chat_outLoader : Theme.key_chat_inLoader, currentMessageObject.isOutOwner() ? Theme.key_chat_outBubble : Theme.key_chat_inBubble);
            mediaCheckBox.setBackgroundDrawable(isDrawSelectionBackground() ? currentBackgroundSelectedDrawable : currentBackgroundDrawable);
        } else {
            int size = AndroidUtilities.dp(21);
            mediaCheckBox.setBackgroundType(0);
            mediaCheckBox.setBounds((int) photoImage.getImageX2() - AndroidUtilities.dp(21 + 4), (int) photoImage.getImageY() + AndroidUtilities.dp(4), size, size);
            mediaCheckBox.setColor(null, null, currentMessageObject.isOutOwner() ? Theme.key_chat_outBubbleSelected : Theme.key_chat_inBubbleSelected);
            mediaCheckBox.setBackgroundDrawable(null);
        }
        mediaCheckBox.draw(canvas);
    }
    if (documentAttachType == DOCUMENT_ATTACH_TYPE_ROUND) {
        float x1, y1;
        boolean playing = MediaController.getInstance().isPlayingMessage(currentMessageObject);
        if (currentMessageObject.type == MessageObject.TYPE_ROUND_VIDEO) {
            float offsetX = 0f;
            if (currentMessageObject.isOutOwner()) {
                float offsetSize = (AndroidUtilities.roundPlayingMessageSize - AndroidUtilities.roundMessageSize) * 0.2f;
                offsetX = isPlayingRound ? offsetSize : 0;
                if (transitionParams.animatePlayingRound) {
                    offsetX = (isPlayingRound ? transitionParams.animateChangeProgress : (1f - transitionParams.animateChangeProgress)) * offsetSize;
                }
            }
            x1 = backgroundDrawableLeft + transitionParams.deltaLeft + AndroidUtilities.dp(8) + roundPlayingDrawableProgress + offsetX;
            y1 = layoutHeight - AndroidUtilities.dp(28 - (drawPinnedBottom ? 2 : 0));
            if (!reactionsLayoutInBubble.isEmpty) {
                y1 -= reactionsLayoutInBubble.totalHeight;
            }
            transitionParams.lastDrawRoundVideoDotY = y1;
            if (transitionParams.animateRoundVideoDotY) {
                y1 = transitionParams.animateFromRoundVideoDotY * (1f - transitionParams.animateChangeProgress) + y1 * transitionParams.animateChangeProgress;
            }
            rect.set(x1, y1, x1 + timeWidthAudio + AndroidUtilities.dp(8 + 12 + 2), y1 + AndroidUtilities.dp(17));
            int oldAlpha = getThemedPaint(Theme.key_paint_chatActionBackground).getAlpha();
            getThemedPaint(Theme.key_paint_chatActionBackground).setAlpha((int) (oldAlpha * timeAlpha));
            applyServiceShaderMatrix(getMeasuredWidth(), backgroundHeight, getX(), viewTop);
            canvas.drawRoundRect(rect, AndroidUtilities.dp(6), AndroidUtilities.dp(6), getThemedPaint(Theme.key_paint_chatActionBackground));
            if (hasGradientService()) {
                int oldAlpha2 = Theme.chat_actionBackgroundGradientDarkenPaint.getAlpha();
                Theme.chat_actionBackgroundGradientDarkenPaint.setAlpha((int) (oldAlpha2 * timeAlpha));
                canvas.drawRoundRect(rect, AndroidUtilities.dp(6), AndroidUtilities.dp(6), Theme.chat_actionBackgroundGradientDarkenPaint);
                Theme.chat_actionBackgroundGradientDarkenPaint.setAlpha(oldAlpha2);
            }
            getThemedPaint(Theme.key_paint_chatActionBackground).setAlpha(oldAlpha);
            boolean showPlayingDrawable = playing || !currentMessageObject.isContentUnread();
            if (showPlayingDrawable && roundPlayingDrawableProgress != 1f) {
                roundPlayingDrawableProgress += 16f / 150f;
                if (roundPlayingDrawableProgress > 1f) {
                    roundPlayingDrawableProgress = 1f;
                } else {
                    invalidate();
                }
            } else if (!showPlayingDrawable && roundPlayingDrawableProgress != 0) {
                roundPlayingDrawableProgress -= 16f / 150f;
                if (roundPlayingDrawableProgress < 0f) {
                    roundPlayingDrawableProgress = 0f;
                } else {
                    invalidate();
                }
            }
            if (showPlayingDrawable) {
                if (playing && !MediaController.getInstance().isMessagePaused()) {
                    roundVideoPlayingDrawable.start();
                } else {
                    roundVideoPlayingDrawable.stop();
                }
            }
            if (roundPlayingDrawableProgress < 1f) {
                float cx = x1 + timeWidthAudio + AndroidUtilities.dp(12);
                float cy = y1 + AndroidUtilities.dp(8.3f);
                canvas.save();
                canvas.scale((1f - roundPlayingDrawableProgress), (1f - roundPlayingDrawableProgress), cx, cy);
                Theme.chat_docBackPaint.setColor(getThemedColor(Theme.key_chat_serviceText));
                Theme.chat_docBackPaint.setAlpha((int) (255 * timeAlpha * (1f - roundPlayingDrawableProgress)));
                canvas.drawCircle(cx, cy, AndroidUtilities.dp(3), Theme.chat_docBackPaint);
                canvas.restore();
            }
            if (roundPlayingDrawableProgress > 0f) {
                setDrawableBounds(roundVideoPlayingDrawable, x1 + timeWidthAudio + AndroidUtilities.dp(6), y1 + AndroidUtilities.dp(2.3f));
                canvas.save();
                canvas.scale(roundPlayingDrawableProgress, roundPlayingDrawableProgress, roundVideoPlayingDrawable.getBounds().centerX(), roundVideoPlayingDrawable.getBounds().centerY());
                roundVideoPlayingDrawable.setAlpha((int) (255 * roundPlayingDrawableProgress));
                roundVideoPlayingDrawable.draw(canvas);
                canvas.restore();
            }
            x1 += AndroidUtilities.dp(4);
            y1 += AndroidUtilities.dp(1.7f);
        } else {
            x1 = backgroundDrawableLeft + AndroidUtilities.dp(currentMessageObject.isOutOwner() || drawPinnedBottom ? 12 : 18);
            y1 = layoutHeight - AndroidUtilities.dp(6.3f - (drawPinnedBottom ? 2 : 0)) - timeLayout.getHeight();
        }
        if (durationLayout != null) {
            Theme.chat_timePaint.setAlpha((int) (255 * timeAlpha));
            canvas.save();
            canvas.translate(x1, y1);
            durationLayout.draw(canvas);
            canvas.restore();
            Theme.chat_timePaint.setAlpha(255);
        }
    }
}
Also used : AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) MediaActionDrawable(org.telegram.ui.Components.MediaActionDrawable) MessageBackgroundDrawable(org.telegram.ui.Components.MessageBackgroundDrawable) SlotsDrawable(org.telegram.ui.Components.SlotsDrawable) BackgroundGradientDrawable(org.telegram.ui.Components.BackgroundGradientDrawable) VideoForwardDrawable(org.telegram.ui.Components.VideoForwardDrawable) RoundVideoPlayingDrawable(org.telegram.ui.Components.RoundVideoPlayingDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) MotionBackgroundDrawable(org.telegram.ui.Components.MotionBackgroundDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable) AudioVisualizerDrawable(org.telegram.ui.Components.AudioVisualizerDrawable) MsgClockDrawable(org.telegram.ui.Components.MsgClockDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) StaticLayout(android.text.StaticLayout) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(org.telegram.ui.Components.Point) TLRPC(org.telegram.tgnet.TLRPC) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable)

Example 17 with AnimatedFileDrawable

use of org.telegram.ui.Components.AnimatedFileDrawable in project Telegram-FOSS by Telegram-FOSS-Team.

the class ChatMessageCell method updateButtonState.

public void updateButtonState(boolean ifSame, boolean animated, boolean fromSet) {
    if (currentMessageObject == null) {
        return;
    }
    if (animated && (PhotoViewer.isShowingImage(currentMessageObject) || !attachedToWindow)) {
        animated = false;
    }
    drawRadialCheckBackground = false;
    String fileName = null;
    boolean fileExists = false;
    if (currentMessageObject.type == MessageObject.TYPE_PHOTO) {
        if (currentPhotoObject == null) {
            radialProgress.setIcon(MediaActionDrawable.ICON_NONE, ifSame, animated);
            return;
        }
        fileName = FileLoader.getAttachFileName(currentPhotoObject);
        fileExists = currentMessageObject.mediaExists;
    } else if (currentMessageObject.type == 8 || documentAttachType == DOCUMENT_ATTACH_TYPE_ROUND || documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_WALLPAPER || currentMessageObject.type == 9 || documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) {
        if (currentMessageObject.useCustomPhoto) {
            buttonState = 1;
            radialProgress.setIcon(getIconForCurrentState(), ifSame, animated);
            return;
        }
        if (currentMessageObject.attachPathExists && !TextUtils.isEmpty(currentMessageObject.messageOwner.attachPath)) {
            fileName = currentMessageObject.messageOwner.attachPath;
            fileExists = true;
        } else if (!currentMessageObject.isSendError() || documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) {
            fileName = currentMessageObject.getFileName();
            fileExists = currentMessageObject.mediaExists;
        }
    } else if (documentAttachType != DOCUMENT_ATTACH_TYPE_NONE) {
        fileName = FileLoader.getAttachFileName(documentAttach);
        fileExists = currentMessageObject.mediaExists;
    } else if (currentPhotoObject != null) {
        fileName = FileLoader.getAttachFileName(currentPhotoObject);
        fileExists = currentMessageObject.mediaExists;
    }
    boolean autoDownload;
    if (documentAttach != null && documentAttach.dc_id == Integer.MIN_VALUE) {
        autoDownload = false;
    } else {
        autoDownload = DownloadController.getInstance(currentAccount).canDownloadMedia(currentMessageObject);
    }
    canStreamVideo = (currentMessageObject.isSent() || currentMessageObject.isForwarded()) && (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_ROUND || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF && autoDownload) && currentMessageObject.canStreamVideo() && !currentMessageObject.needDrawBluredPreview();
    if (SharedConfig.streamMedia && (int) currentMessageObject.getDialogId() != 0 && !currentMessageObject.isSecretMedia() && (documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC || canStreamVideo && currentPosition != null && ((currentPosition.flags & MessageObject.POSITION_FLAG_LEFT) == 0 || (currentPosition.flags & MessageObject.POSITION_FLAG_RIGHT) == 0))) {
        hasMiniProgress = fileExists ? 1 : 2;
        fileExists = true;
    }
    if (currentMessageObject.isSendError() || TextUtils.isEmpty(fileName) && (currentMessageObject.isAnyKindOfSticker() || !currentMessageObject.isSending() && !currentMessageObject.isEditing())) {
        radialProgress.setIcon(MediaActionDrawable.ICON_NONE, ifSame, false);
        radialProgress.setMiniIcon(MediaActionDrawable.ICON_NONE, ifSame, false);
        videoRadialProgress.setIcon(MediaActionDrawable.ICON_NONE, ifSame, false);
        videoRadialProgress.setMiniIcon(MediaActionDrawable.ICON_NONE, ifSame, false);
        return;
    }
    boolean fromBot = currentMessageObject.messageOwner.params != null && currentMessageObject.messageOwner.params.containsKey("query_id");
    if (documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO || documentAttachType == DOCUMENT_ATTACH_TYPE_MUSIC) {
        if (currentMessageObject.isOut() && (currentMessageObject.isSending() && !currentMessageObject.isForwarded() || currentMessageObject.isEditing() && currentMessageObject.isEditingMedia()) || currentMessageObject.isSendError() && fromBot) {
            if (!TextUtils.isEmpty(currentMessageObject.messageOwner.attachPath)) {
                DownloadController.getInstance(currentAccount).addLoadingFileObserver(currentMessageObject.messageOwner.attachPath, currentMessageObject, this);
                wasSending = true;
                buttonState = 4;
                boolean sending = SendMessagesHelper.getInstance(currentAccount).isSendingMessage(currentMessageObject.getId());
                if (currentPosition != null && sending && buttonState == 4) {
                    drawRadialCheckBackground = true;
                    getIconForCurrentState();
                    radialProgress.setIcon(MediaActionDrawable.ICON_CHECK, ifSame, animated);
                } else {
                    radialProgress.setIcon(getIconForCurrentState(), ifSame, animated);
                }
                radialProgress.setMiniIcon(MediaActionDrawable.ICON_NONE, ifSame, animated);
                if (!fromBot) {
                    long[] progress = ImageLoader.getInstance().getFileProgressSizes(currentMessageObject.messageOwner.attachPath);
                    float loadingProgress = 0;
                    if (progress == null && sending) {
                        loadingProgress = 1.0f;
                    } else if (progress != null) {
                        loadingProgress = DownloadController.getProgress(progress);
                    }
                    radialProgress.setProgress(loadingProgress, false);
                } else {
                    radialProgress.setProgress(0, false);
                }
            } else {
                buttonState = -1;
                getIconForCurrentState();
                radialProgress.setIcon(MediaActionDrawable.ICON_CANCEL_NOPROFRESS, ifSame, false);
                radialProgress.setProgress(0, false);
                radialProgress.setMiniIcon(MediaActionDrawable.ICON_NONE, ifSame, false);
            }
        } else {
            if (hasMiniProgress != 0) {
                radialProgress.setMiniProgressBackgroundColor(getThemedColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outLoader : Theme.key_chat_inLoader));
                boolean playing = MediaController.getInstance().isPlayingMessage(currentMessageObject);
                if (!playing || MediaController.getInstance().isMessagePaused()) {
                    buttonState = 0;
                } else {
                    buttonState = 1;
                }
                radialProgress.setIcon(getIconForCurrentState(), ifSame, animated);
                if (hasMiniProgress == 1) {
                    DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
                    miniButtonState = -1;
                } else {
                    DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, currentMessageObject, this);
                    if (!FileLoader.getInstance(currentAccount).isLoadingFile(fileName)) {
                        createLoadingProgressLayout(documentAttach);
                        miniButtonState = 0;
                    } else {
                        miniButtonState = 1;
                        long[] progress = ImageLoader.getInstance().getFileProgressSizes(fileName);
                        if (progress != null) {
                            radialProgress.setProgress(DownloadController.getProgress(progress), animated);
                            createLoadingProgressLayout(progress[0], progress[1]);
                        } else {
                            radialProgress.setProgress(0, animated);
                            createLoadingProgressLayout(0, currentMessageObject.getSize());
                        }
                    }
                }
                radialProgress.setMiniIcon(getMiniIconForCurrentState(), ifSame, animated);
            } else if (fileExists) {
                DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
                boolean playing = MediaController.getInstance().isPlayingMessage(currentMessageObject);
                if (!playing || MediaController.getInstance().isMessagePaused()) {
                    buttonState = 0;
                } else {
                    buttonState = 1;
                }
                radialProgress.setIcon(getIconForCurrentState(), ifSame, animated);
            } else {
                DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, currentMessageObject, this);
                if (!FileLoader.getInstance(currentAccount).isLoadingFile(fileName)) {
                    buttonState = 2;
                } else {
                    buttonState = 4;
                    long[] progress = ImageLoader.getInstance().getFileProgressSizes(fileName);
                    if (progress != null) {
                        radialProgress.setProgress(DownloadController.getProgress(progress), animated);
                        createLoadingProgressLayout(progress[0], progress[1]);
                    } else {
                        createLoadingProgressLayout(documentAttach);
                        radialProgress.setProgress(0, animated);
                    }
                }
                radialProgress.setIcon(getIconForCurrentState(), ifSame, animated);
            }
        }
        updatePlayingMessageProgress();
    } else if (currentMessageObject.type == 0 && documentAttachType != DOCUMENT_ATTACH_TYPE_DOCUMENT && documentAttachType != DOCUMENT_ATTACH_TYPE_GIF && documentAttachType != DOCUMENT_ATTACH_TYPE_ROUND && documentAttachType != DOCUMENT_ATTACH_TYPE_VIDEO && documentAttachType != DOCUMENT_ATTACH_TYPE_WALLPAPER && documentAttachType != DOCUMENT_ATTACH_TYPE_THEME) {
        if (currentPhotoObject == null || !drawImageButton) {
            return;
        }
        if (!fileExists) {
            DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, currentMessageObject, this);
            float setProgress = 0;
            if (!FileLoader.getInstance(currentAccount).isLoadingFile(fileName)) {
                if (!currentMessageObject.loadingCancelled && (documentAttachType == 0 && autoDownload || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF && MessageObject.isGifDocument(documentAttach, currentMessageObject.hasValidGroupId()) && autoDownload)) {
                    buttonState = 1;
                } else {
                    buttonState = 0;
                }
            } else {
                buttonState = 1;
                long[] progress = ImageLoader.getInstance().getFileProgressSizes(fileName);
                setProgress = progress != null ? DownloadController.getProgress(progress) : 0;
                if (progress != null && progress[0] == progress[1]) {
                    createLoadingProgressLayout(progress[0], progress[1]);
                } else {
                    if (currentMessageObject.getDocument() != null) {
                        createLoadingProgressLayout(currentMessageObject.loadedFileSize, currentMessageObject.getSize());
                    }
                }
            }
            radialProgress.setProgress(setProgress, false);
        } else {
            DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
            if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF && !photoImage.isAllowStartAnimation()) {
                buttonState = 2;
            } else {
                buttonState = -1;
            }
        }
        radialProgress.setIcon(getIconForCurrentState(), ifSame, animated);
        invalidate();
    } else {
        if (currentMessageObject.isOut() && (currentMessageObject.isSending() && !currentMessageObject.isForwarded() || currentMessageObject.isEditing() && currentMessageObject.isEditingMedia())) {
            if (!TextUtils.isEmpty(currentMessageObject.messageOwner.attachPath)) {
                DownloadController.getInstance(currentAccount).addLoadingFileObserver(currentMessageObject.messageOwner.attachPath, currentMessageObject, this);
                wasSending = true;
                boolean needProgress = currentMessageObject.messageOwner.attachPath == null || !currentMessageObject.messageOwner.attachPath.startsWith("http");
                HashMap<String, String> params = currentMessageObject.messageOwner.params;
                if (currentMessageObject.messageOwner.message != null && params != null && (params.containsKey("url") || params.containsKey("bot"))) {
                    needProgress = false;
                    buttonState = -1;
                } else {
                    buttonState = 1;
                }
                boolean sending = SendMessagesHelper.getInstance(currentAccount).isSendingMessage(currentMessageObject.getId());
                if (currentPosition != null && sending && buttonState == 1) {
                    drawRadialCheckBackground = true;
                    getIconForCurrentState();
                    radialProgress.setIcon(MediaActionDrawable.ICON_CHECK, ifSame, animated);
                } else {
                    radialProgress.setIcon(getIconForCurrentState(), ifSame, animated);
                }
                if (needProgress) {
                    long[] progress = ImageLoader.getInstance().getFileProgressSizes(currentMessageObject.messageOwner.attachPath);
                    float loadingProgress = 0;
                    if (progress == null && sending) {
                        loadingProgress = 1.0f;
                    } else if (progress != null) {
                        loadingProgress = DownloadController.getProgress(progress);
                        createLoadingProgressLayout(progress[0], progress[1]);
                    }
                    radialProgress.setProgress(loadingProgress, false);
                } else {
                    radialProgress.setProgress(0, false);
                }
                invalidate();
            } else {
                getIconForCurrentState();
                if (currentMessageObject.isSticker() || currentMessageObject.isAnimatedSticker() || currentMessageObject.isLocation() || currentMessageObject.isGif()) {
                    buttonState = -1;
                    radialProgress.setIcon(MediaActionDrawable.ICON_NONE, ifSame, false);
                } else {
                    buttonState = 1;
                    radialProgress.setIcon(MediaActionDrawable.ICON_CANCEL_NOPROFRESS, ifSame, false);
                }
                radialProgress.setProgress(0, false);
            }
            videoRadialProgress.setIcon(MediaActionDrawable.ICON_NONE, ifSame, false);
        } else {
            if (wasSending && !TextUtils.isEmpty(currentMessageObject.messageOwner.attachPath)) {
                DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
            }
            boolean isLoadingVideo = false;
            if ((documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF || documentAttachType == DOCUMENT_ATTACH_TYPE_ROUND) && autoPlayingMedia) {
                isLoadingVideo = FileLoader.getInstance(currentAccount).isLoadingVideo(documentAttach, MediaController.getInstance().isPlayingMessage(currentMessageObject));
                AnimatedFileDrawable animation = photoImage.getAnimation();
                if (animation != null) {
                    if (currentMessageObject.hadAnimationNotReadyLoading) {
                        if (animation.hasBitmap()) {
                            currentMessageObject.hadAnimationNotReadyLoading = false;
                        }
                    } else {
                        currentMessageObject.hadAnimationNotReadyLoading = isLoadingVideo && !animation.hasBitmap();
                    }
                } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF && !fileExists) {
                    currentMessageObject.hadAnimationNotReadyLoading = true;
                }
            }
            if (hasMiniProgress != 0) {
                radialProgress.setMiniProgressBackgroundColor(getThemedColor(Theme.key_chat_inLoaderPhoto));
                buttonState = 3;
                radialProgress.setIcon(getIconForCurrentState(), ifSame, animated);
                if (hasMiniProgress == 1) {
                    DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
                    miniButtonState = -1;
                } else {
                    DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, currentMessageObject, this);
                    if (!FileLoader.getInstance(currentAccount).isLoadingFile(fileName)) {
                        miniButtonState = 0;
                    } else {
                        miniButtonState = 1;
                        long[] progress = ImageLoader.getInstance().getFileProgressSizes(fileName);
                        if (progress != null) {
                            createLoadingProgressLayout(progress[0], progress[1]);
                            radialProgress.setProgress(DownloadController.getProgress(progress), animated);
                        } else {
                            createLoadingProgressLayout(documentAttach);
                            radialProgress.setProgress(0, animated);
                        }
                    }
                }
                radialProgress.setMiniIcon(getMiniIconForCurrentState(), ifSame, animated);
            } else if (fileExists || (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF || documentAttachType == DOCUMENT_ATTACH_TYPE_ROUND) && autoPlayingMedia && !currentMessageObject.hadAnimationNotReadyLoading && !isLoadingVideo) {
                DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
                if (drawVideoImageButton && animated) {
                    if (animatingDrawVideoImageButton != 1 && animatingDrawVideoImageButtonProgress > 0) {
                        if (animatingDrawVideoImageButton == 0) {
                            animatingDrawVideoImageButtonProgress = 1.0f;
                        }
                        animatingDrawVideoImageButton = 1;
                    }
                } else if (animatingDrawVideoImageButton == 0) {
                    animatingDrawVideoImageButton = 1;
                }
                drawVideoImageButton = false;
                drawVideoSize = false;
                if (currentMessageObject.needDrawBluredPreview()) {
                    buttonState = -1;
                } else {
                    if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF && currentMessageObject.gifState == 1) {
                        if (photoImage.isAnimationRunning()) {
                            currentMessageObject.gifState = 0;
                            buttonState = -1;
                        } else {
                            buttonState = 2;
                        }
                    } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO && !hasEmbed) {
                        buttonState = 3;
                    } else {
                        buttonState = -1;
                    }
                }
                videoRadialProgress.setIcon(MediaActionDrawable.ICON_NONE, ifSame, animatingDrawVideoImageButton != 0);
                radialProgress.setIcon(getIconForCurrentState(), ifSame, animated);
                if (!fromSet && photoNotSet) {
                    setMessageObject(currentMessageObject, currentMessagesGroup, pinnedBottom, pinnedTop);
                }
                invalidate();
            } else {
                drawVideoSize = documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF;
                if ((documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF || documentAttachType == DOCUMENT_ATTACH_TYPE_ROUND) && canStreamVideo && !drawVideoImageButton && animated) {
                    if (animatingDrawVideoImageButton != 2 && animatingDrawVideoImageButtonProgress < 1.0f) {
                        if (animatingDrawVideoImageButton == 0) {
                            animatingDrawVideoImageButtonProgress = 0.0f;
                        }
                        animatingDrawVideoImageButton = 2;
                    }
                } else if (animatingDrawVideoImageButton == 0) {
                    animatingDrawVideoImageButtonProgress = 1.0f;
                }
                DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, currentMessageObject, this);
                boolean progressVisible = false;
                if (!FileLoader.getInstance(currentAccount).isLoadingFile(fileName)) {
                    if (!currentMessageObject.loadingCancelled && autoDownload) {
                        buttonState = 1;
                    } else if (currentMessageObject.type == MessageObject.TYPE_GEO) {
                        buttonState = -1;
                    } else {
                        buttonState = 0;
                    }
                    boolean hasDocLayout = currentMessageObject.type == MessageObject.TYPE_VIDEO || currentMessageObject.type == 8 || documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO;
                    boolean fullWidth = true;
                    if (currentPosition != null) {
                        int mask = MessageObject.POSITION_FLAG_LEFT | MessageObject.POSITION_FLAG_RIGHT;
                        fullWidth = (currentPosition.flags & mask) == mask;
                    }
                    if ((documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF && autoDownload) && canStreamVideo && hasDocLayout && fullWidth) {
                        drawVideoImageButton = true;
                        getIconForCurrentState();
                        radialProgress.setIcon(autoPlayingMedia ? MediaActionDrawable.ICON_NONE : MediaActionDrawable.ICON_PLAY, ifSame, animated);
                        videoRadialProgress.setIcon(MediaActionDrawable.ICON_DOWNLOAD, ifSame, animated);
                    } else {
                        drawVideoImageButton = false;
                        radialProgress.setIcon(getIconForCurrentState(), ifSame, animated);
                        videoRadialProgress.setIcon(MediaActionDrawable.ICON_NONE, ifSame, false);
                        if (!drawVideoSize && animatingDrawVideoImageButton == 0) {
                            animatingDrawVideoImageButtonProgress = 0.0f;
                        }
                    }
                } else {
                    buttonState = 1;
                    long[] progress = ImageLoader.getInstance().getFileProgressSizes(fileName);
                    if (progress != null) {
                        createLoadingProgressLayout(progress[0], progress[1]);
                    } else {
                        createLoadingProgressLayout(documentAttach);
                    }
                    boolean hasDocLayout = currentMessageObject.type == MessageObject.TYPE_VIDEO || currentMessageObject.type == 8 || documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO;
                    boolean fullWidth = true;
                    if (currentPosition != null) {
                        int mask = MessageObject.POSITION_FLAG_LEFT | MessageObject.POSITION_FLAG_RIGHT;
                        fullWidth = (currentPosition.flags & mask) == mask;
                    }
                    if ((documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || MessageObject.isGifDocument(documentAttach, currentMessageObject.hasValidGroupId()) && autoDownload) && canStreamVideo && hasDocLayout && fullWidth) {
                        drawVideoImageButton = true;
                        getIconForCurrentState();
                        radialProgress.setIcon(autoPlayingMedia || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF ? MediaActionDrawable.ICON_NONE : MediaActionDrawable.ICON_PLAY, ifSame, animated);
                        videoRadialProgress.setProgress(progress != null ? DownloadController.getProgress(progress) : 0, animated);
                        videoRadialProgress.setIcon(MediaActionDrawable.ICON_CANCEL_FILL, ifSame, animated);
                    } else {
                        drawVideoImageButton = false;
                        radialProgress.setProgress(progress != null ? DownloadController.getProgress(progress) : 0, animated);
                        radialProgress.setIcon(getIconForCurrentState(), ifSame, animated);
                        videoRadialProgress.setIcon(MediaActionDrawable.ICON_NONE, ifSame, false);
                        if (!drawVideoSize && animatingDrawVideoImageButton == 0) {
                            animatingDrawVideoImageButtonProgress = 0.0f;
                        }
                    }
                }
                invalidate();
            }
        }
    }
    if (hasMiniProgress == 0) {
        radialProgress.setMiniIcon(MediaActionDrawable.ICON_NONE, false, animated);
    }
}
Also used : AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) HashMap(java.util.HashMap) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(org.telegram.ui.Components.Point)

Example 18 with AnimatedFileDrawable

use of org.telegram.ui.Components.AnimatedFileDrawable in project Telegram-FOSS by Telegram-FOSS-Team.

the class ProfileActivity method setForegroundImage.

private void setForegroundImage(boolean secondParent) {
    Drawable drawable = avatarImage.getImageReceiver().getDrawable();
    if (drawable instanceof AnimatedFileDrawable) {
        AnimatedFileDrawable fileDrawable = (AnimatedFileDrawable) drawable;
        avatarImage.setForegroundImage(null, null, fileDrawable);
        if (secondParent) {
            fileDrawable.addSecondParentView(avatarImage);
        }
    } else {
        ImageLocation location = avatarsViewPager.getImageLocation(0);
        String filter;
        if (location != null && location.imageType == FileLoader.IMAGE_TYPE_ANIMATION) {
            filter = ImageLoader.AUTOPLAY_FILTER;
        } else {
            filter = null;
        }
        avatarImage.setForegroundImage(location, filter, drawable);
    }
}
Also used : AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) AvatarDrawable(org.telegram.ui.Components.AvatarDrawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) TimerDrawable(org.telegram.ui.Components.TimerDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable) IdenticonDrawable(org.telegram.ui.Components.IdenticonDrawable) CrossfadeDrawable(org.telegram.ui.Components.CrossfadeDrawable) BackDrawable(org.telegram.ui.ActionBar.BackDrawable) ScamDrawable(org.telegram.ui.Components.ScamDrawable) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) ImageLocation(org.telegram.messenger.ImageLocation)

Example 19 with AnimatedFileDrawable

use of org.telegram.ui.Components.AnimatedFileDrawable in project Telegram-FOSS by Telegram-FOSS-Team.

the class PhotoViewer method closePhoto.

public void closePhoto(boolean animated, boolean fromEditMode) {
    if (!fromEditMode && currentEditMode != 0) {
        if (currentEditMode == 3 && photoPaintView != null) {
            closePaintMode();
            return;
        }
        if (currentEditMode == 1) {
            cropTransform.setViewTransform(previousHasTransform, previousCropPx, previousCropPy, previousCropRotation, previousCropOrientation, previousCropScale, 1.0f, 1.0f, previousCropPw, previousCropPh, 0, 0, previousCropMirrored);
        }
        switchToEditMode(0);
        return;
    }
    if (qualityChooseView != null && qualityChooseView.getTag() != null) {
        qualityPicker.cancelButton.callOnClick();
        return;
    }
    openedFullScreenVideo = false;
    try {
        if (visibleDialog != null) {
            visibleDialog.dismiss();
            visibleDialog = null;
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
    if (Build.VERSION.SDK_INT >= 21 && containerView != null) {
        AndroidUtilities.cancelRunOnUIThread(updateContainerFlagsRunnable);
        updateContainerFlags(true);
    }
    if (currentEditMode != 0) {
        if (currentEditMode == 2) {
            photoFilterView.shutdown();
            containerView.removeView(photoFilterView);
            photoFilterView = null;
        } else if (currentEditMode == 1) {
            editorDoneLayout.setVisibility(View.GONE);
            photoCropView.setVisibility(View.GONE);
        } else if (currentEditMode == 3) {
            photoPaintView.shutdown();
            containerView.removeView(photoPaintView);
            photoPaintView = null;
            savedState = null;
        }
        currentEditMode = 0;
    }
    if (parentActivity == null || !isInline && !isVisible || checkAnimation() || placeProvider == null) {
        return;
    }
    if (captionEditText.hideActionMode() && !fromEditMode) {
        return;
    }
    if (parentActivity != null && fullscreenedByButton != 0) {
        parentActivity.setRequestedOrientation(prevOrientation);
        fullscreenedByButton = 0;
        wasRotated = false;
    }
    if (!doneButtonPressed && !imagesArrLocals.isEmpty() && currentIndex >= 0 && currentIndex < imagesArrLocals.size()) {
        Object entry = imagesArrLocals.get(currentIndex);
        if (entry instanceof MediaController.MediaEditState) {
            ((MediaController.MediaEditState) entry).editedInfo = getCurrentVideoEditedInfo();
        }
    }
    final PlaceProviderObject object = placeProvider.getPlaceForPhoto(currentMessageObject, getFileLocation(currentFileLocation), currentIndex, true);
    if (videoPlayer != null && object != null) {
        AnimatedFileDrawable animation = object.imageReceiver.getAnimation();
        if (animation != null) {
            if (textureUploaded) {
                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);
                    }
                }
            }
            if (currentMessageObject != null) {
                long startTime = animation.getStartTime();
                long seekTo = videoPlayer.getCurrentPosition() + (startTime > 0 ? startTime : 0);
                animation.seekTo(seekTo, !FileLoader.getInstance(currentMessageObject.currentAccount).isLoadingVideo(currentMessageObject.getDocument(), true));
            }
            object.imageReceiver.setAllowStartAnimation(true);
            object.imageReceiver.startAnimation();
        }
    }
    if (!doneButtonPressed) {
        releasePlayer(true);
    }
    if (photoViewerWebView != null) {
        photoViewerWebView.release();
        containerView.removeView(photoViewerWebView);
        photoViewerWebView = null;
    }
    captionEditText.onDestroy();
    if (parentChatActivity != null && parentChatActivity.getFragmentView() != null) {
        parentChatActivity.getFragmentView().invalidate();
    }
    parentChatActivity = null;
    removeObservers();
    isActionBarVisible = false;
    if (velocityTracker != null) {
        velocityTracker.recycle();
        velocityTracker = null;
    }
    if (isInline) {
        isInline = false;
        animationInProgress = 0;
        onPhotoClosed(object);
        containerView.setScaleX(1.0f);
        containerView.setScaleY(1.0f);
    } else {
        if (animated) {
            final ClippingImageView[] animatingImageViews = getAnimatingImageViews(object);
            for (int i = 0; i < animatingImageViews.length; i++) {
                animatingImageViews[i].setAnimationValues(animationValues);
                animatingImageViews[i].setVisibility(View.VISIBLE);
            }
            animationInProgress = 3;
            containerView.invalidate();
            AnimatorSet animatorSet = new AnimatorSet();
            final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams();
            RectF drawRegion = null;
            if (object != null) {
                drawRegion = object.imageReceiver.getDrawRegion();
                layoutParams.width = (int) drawRegion.width();
                layoutParams.height = (int) drawRegion.height();
                int orientation = object.imageReceiver.getOrientation();
                int animatedOrientation = object.imageReceiver.getAnimatedOrientation();
                if (animatedOrientation != 0) {
                    orientation = animatedOrientation;
                }
                for (int i = 0; i < animatingImageViews.length; i++) {
                    animatingImageViews[i].setOrientation(orientation);
                    animatingImageViews[i].setImageBitmap(object.thumb);
                }
            } else {
                layoutParams.width = (int) centerImage.getImageWidth();
                layoutParams.height = (int) centerImage.getImageHeight();
                for (int i = 0; i < animatingImageViews.length; i++) {
                    animatingImageViews[i].setOrientation(centerImage.getOrientation());
                    animatingImageViews[i].setImageBitmap(centerImage.getBitmapSafe());
                }
            }
            if (layoutParams.width <= 0) {
                layoutParams.width = 100;
            }
            if (layoutParams.height <= 0) {
                layoutParams.height = 100;
            }
            float scaleX;
            float scaleY;
            float scale2;
            if (sendPhotoType == SELECT_TYPE_AVATAR) {
                float statusBarHeight = (isStatusBarVisible() ? AndroidUtilities.statusBarHeight : 0);
                float measuredHeight = (float) photoCropView.getMeasuredHeight() - AndroidUtilities.dp(64) - statusBarHeight;
                float minSide = Math.min(photoCropView.getMeasuredWidth(), measuredHeight) - 2 * AndroidUtilities.dp(16);
                scaleX = minSide / layoutParams.width;
                scaleY = minSide / layoutParams.height;
                scale2 = Math.max(scaleX, scaleY);
            } else {
                scaleX = (float) windowView.getMeasuredWidth() / layoutParams.width;
                scaleY = (float) (AndroidUtilities.displaySize.y + (isStatusBarVisible() ? AndroidUtilities.statusBarHeight : 0)) / layoutParams.height;
                scale2 = Math.min(scaleX, scaleY);
            }
            float width = layoutParams.width * scale * scale2;
            float height = layoutParams.height * scale * scale2;
            float xPos = (windowView.getMeasuredWidth() - width) / 2.0f;
            float yPos;
            if (sendPhotoType == SELECT_TYPE_AVATAR) {
                float statusBarHeight = (isStatusBarVisible() ? AndroidUtilities.statusBarHeight : 0);
                float measuredHeight = (float) photoCropView.getMeasuredHeight() - statusBarHeight;
                yPos = (measuredHeight - height) / 2.0f;
            } else {
                yPos = ((AndroidUtilities.displaySize.y + (isStatusBarVisible() ? AndroidUtilities.statusBarHeight : 0)) - height) / 2.0f;
            }
            for (int i = 0; i < animatingImageViews.length; i++) {
                animatingImageViews[i].setLayoutParams(layoutParams);
                animatingImageViews[i].setTranslationX(xPos + translationX);
                animatingImageViews[i].setTranslationY(yPos + translationY);
                animatingImageViews[i].setScaleX(scale * scale2);
                animatingImageViews[i].setScaleY(scale * scale2);
            }
            if (object != null) {
                object.imageReceiver.setVisible(false, true);
                int clipHorizontal = (int) Math.abs(drawRegion.left - object.imageReceiver.getImageX());
                int clipVertical = (int) Math.abs(drawRegion.top - object.imageReceiver.getImageY());
                if (pageBlocksAdapter != null && object.imageReceiver.isAspectFit()) {
                    clipHorizontal = 0;
                }
                int[] coords2 = new int[2];
                object.parentView.getLocationInWindow(coords2);
                int clipTop = (int) (coords2[1] - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight) - (object.viewY + drawRegion.top) + object.clipTopAddition);
                if (clipTop < 0) {
                    clipTop = 0;
                }
                int clipBottom = (int) ((object.viewY + drawRegion.top + (drawRegion.bottom - drawRegion.top)) - (coords2[1] + object.parentView.getHeight() - (Build.VERSION.SDK_INT >= 21 ? 0 : AndroidUtilities.statusBarHeight)) + object.clipBottomAddition);
                if (clipBottom < 0) {
                    clipBottom = 0;
                }
                clipTop = Math.max(clipTop, clipVertical);
                clipBottom = Math.max(clipBottom, clipVertical);
                animationValues[0][0] = animatingImageView.getScaleX();
                animationValues[0][1] = animatingImageView.getScaleY();
                animationValues[0][2] = animatingImageView.getTranslationX();
                animationValues[0][3] = animatingImageView.getTranslationY();
                animationValues[0][4] = 0;
                animationValues[0][5] = 0;
                animationValues[0][6] = 0;
                animationValues[0][7] = 0;
                animationValues[0][8] = 0;
                animationValues[0][9] = 0;
                animationValues[0][10] = 0;
                animationValues[0][11] = 0;
                animationValues[0][12] = 0;
                animationValues[1][0] = object.scale;
                animationValues[1][1] = object.scale;
                animationValues[1][2] = object.viewX + drawRegion.left * object.scale;
                animationValues[1][3] = object.viewY + drawRegion.top * object.scale;
                animationValues[1][4] = clipHorizontal * object.scale;
                animationValues[1][5] = clipTop * object.scale;
                animationValues[1][6] = clipBottom * object.scale;
                for (int a = 0; a < 4; a++) {
                    animationValues[1][7 + a] = object.radius != null ? object.radius[a] : 0;
                }
                animationValues[1][11] = clipVertical * object.scale;
                animationValues[1][12] = clipHorizontal * object.scale;
                ArrayList<Animator> animators = new ArrayList<>((sendPhotoType == SELECT_TYPE_AVATAR ? 3 : 2) + animatingImageViews.length + (animatingImageViews.length > 1 ? 1 : 0));
                for (int i = 0; i < animatingImageViews.length; i++) {
                    animators.add(ObjectAnimator.ofFloat(animatingImageViews[i], AnimationProperties.CLIPPING_IMAGE_VIEW_PROGRESS, 0.0f, 1.0f));
                }
                if (animatingImageViews.length > 1) {
                    animators.add(ObjectAnimator.ofFloat(animatingImageView, View.ALPHA, 0f));
                    animatingImageViews[1].setAdditionalTranslationX(-getLeftInset());
                }
                animators.add(ObjectAnimator.ofInt(backgroundDrawable, AnimationProperties.COLOR_DRAWABLE_ALPHA, 0));
                animators.add(ObjectAnimator.ofFloat(containerView, View.ALPHA, 0.0f));
                if (sendPhotoType == SELECT_TYPE_AVATAR) {
                    animators.add(ObjectAnimator.ofFloat(photoCropView, View.ALPHA, 0.0f));
                }
                animatorSet.playTogether(animators);
            } else {
                int h = (AndroidUtilities.displaySize.y + (isStatusBarVisible() ? AndroidUtilities.statusBarHeight : 0));
                animatorSet.playTogether(ObjectAnimator.ofInt(backgroundDrawable, AnimationProperties.COLOR_DRAWABLE_ALPHA, 0), ObjectAnimator.ofFloat(animatingImageView, View.ALPHA, 0.0f), ObjectAnimator.ofFloat(animatingImageView, View.TRANSLATION_Y, translationY >= 0 ? h : -h), ObjectAnimator.ofFloat(containerView, View.ALPHA, 0.0f));
            }
            animationEndRunnable = () -> {
                animationEndRunnable = null;
                if (Build.VERSION.SDK_INT >= 18) {
                    containerView.setLayerType(View.LAYER_TYPE_NONE, null);
                }
                animationInProgress = 0;
                onPhotoClosed(object);
            };
            animatorSet.setDuration(200);
            animatorSet.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    AndroidUtilities.runOnUIThread(() -> {
                        if (animationEndRunnable != null) {
                            animationEndRunnable.run();
                            animationEndRunnable = null;
                        }
                    });
                }
            });
            transitionAnimationStartTime = System.currentTimeMillis();
            if (Build.VERSION.SDK_INT >= 18) {
                containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            }
            animatorSet.start();
        } else {
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, View.SCALE_X, 0.9f), ObjectAnimator.ofFloat(containerView, View.SCALE_Y, 0.9f), ObjectAnimator.ofInt(backgroundDrawable, AnimationProperties.COLOR_DRAWABLE_ALPHA, 0), ObjectAnimator.ofFloat(containerView, View.ALPHA, 0.0f));
            animationInProgress = 2;
            animationEndRunnable = () -> {
                animationEndRunnable = null;
                if (containerView == null) {
                    return;
                }
                if (Build.VERSION.SDK_INT >= 18) {
                    containerView.setLayerType(View.LAYER_TYPE_NONE, null);
                }
                animationInProgress = 0;
                onPhotoClosed(object);
                containerView.setScaleX(1.0f);
                containerView.setScaleY(1.0f);
            };
            animatorSet.setDuration(200);
            animatorSet.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    if (animationEndRunnable != null) {
                        ChatActivity chatActivity = parentChatActivity;
                        if (chatActivity == null && parentAlert != null) {
                            BaseFragment baseFragment = parentAlert.getBaseFragment();
                            if (baseFragment instanceof ChatActivity) {
                                chatActivity = (ChatActivity) baseFragment;
                            }
                        }
                        if (chatActivity != null) {
                            chatActivity.doOnIdle(animationEndRunnable);
                        } else {
                            animationEndRunnable.run();
                            animationEndRunnable = null;
                        }
                    }
                }
            });
            transitionAnimationStartTime = System.currentTimeMillis();
            if (Build.VERSION.SDK_INT >= 18) {
                containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            }
            animatorSet.start();
        }
        if (currentAnimation != null) {
            currentAnimation.removeSecondParentView(containerView);
            currentAnimation = null;
            centerImage.setImageBitmap((Drawable) null);
        }
        if (placeProvider != null && !placeProvider.canScrollAway()) {
            placeProvider.cancelButtonPressed();
        }
    }
}
Also used : MediaController(org.telegram.messenger.MediaController) ArrayList(java.util.ArrayList) AnimatorSet(android.animation.AnimatorSet) BaseFragment(org.telegram.ui.ActionBar.BaseFragment) Bitmap(android.graphics.Bitmap) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ViewGroup(android.view.ViewGroup) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) TextPaint(android.text.TextPaint) SuppressLint(android.annotation.SuppressLint) RectF(android.graphics.RectF) Animator(android.animation.Animator) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) ValueAnimator(android.animation.ValueAnimator) ObjectAnimator(android.animation.ObjectAnimator) ViewPropertyAnimator(android.view.ViewPropertyAnimator) UserObject(org.telegram.messenger.UserObject) TLObject(org.telegram.tgnet.TLObject) MessageObject(org.telegram.messenger.MessageObject) DialogObject(org.telegram.messenger.DialogObject) ChatObject(org.telegram.messenger.ChatObject) ClippingImageView(org.telegram.ui.Components.ClippingImageView)

Example 20 with AnimatedFileDrawable

use of org.telegram.ui.Components.AnimatedFileDrawable in project Telegram-FOSS by Telegram-FOSS-Team.

the class PinchToZoomHelper method clear.

public void clear() {
    if (inOverlayMode) {
        if (callback != null) {
            callback.onZoomFinished(messageObject);
        }
        inOverlayMode = false;
    }
    if (overlayView != null && overlayView.getParent() != null) {
        parentView.removeView(overlayView);
        overlayView.backupImageView.getImageReceiver().clearImage();
        if (childImage != null) {
            Drawable drawable = this.childImage.getDrawable();
            if (drawable instanceof AnimatedFileDrawable) {
                ((AnimatedFileDrawable) drawable).removeSecondParentView(overlayView);
            }
        }
    }
    if (child != null) {
        child.invalidate();
        child = null;
    }
    if (childImage != null) {
        this.childImage.onDetachedFromWindow();
        this.childImage.clearImage();
        this.childImage = null;
    }
    if (fullImage != null) {
        fullImage.onDetachedFromWindow();
        fullImage.clearImage();
        fullImage = null;
    }
    messageObject = null;
}
Also used : AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) AnimatedFileDrawable(org.telegram.ui.Components.AnimatedFileDrawable) Drawable(android.graphics.drawable.Drawable)

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