Search in sources :

Example 1 with SlotsDrawable

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

the class ChatMessageCell method setCurrentDiceValue.

public boolean setCurrentDiceValue(boolean instant) {
    if (currentMessageObject.isDice()) {
        Drawable drawable = photoImage.getDrawable();
        if (drawable instanceof RLottieDrawable) {
            RLottieDrawable lottieDrawable = (RLottieDrawable) drawable;
            String emoji = currentMessageObject.getDiceEmoji();
            TLRPC.TL_messages_stickerSet stickerSet = MediaDataController.getInstance(currentAccount).getStickerSetByEmojiOrName(emoji);
            if (stickerSet != null) {
                int value = currentMessageObject.getDiceValue();
                if ("\uD83C\uDFB0".equals(currentMessageObject.getDiceEmoji())) {
                    if (value >= 0 && value <= 64) {
                        ((SlotsDrawable) lottieDrawable).setDiceNumber(this, value, stickerSet, instant);
                        if (currentMessageObject.isOut()) {
                            lottieDrawable.setOnFinishCallback(diceFinishCallback, Integer.MAX_VALUE);
                        }
                        currentMessageObject.wasUnread = false;
                    }
                    if (!lottieDrawable.hasBaseDice() && stickerSet.documents.size() > 0) {
                        ((SlotsDrawable) lottieDrawable).setBaseDice(this, stickerSet);
                    }
                } else {
                    if (!lottieDrawable.hasBaseDice() && stickerSet.documents.size() > 0) {
                        TLRPC.Document document = stickerSet.documents.get(0);
                        File path = FileLoader.getPathToAttach(document, true);
                        if (lottieDrawable.setBaseDice(path)) {
                            DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
                        } else {
                            String fileName = FileLoader.getAttachFileName(document);
                            DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, currentMessageObject, this);
                            FileLoader.getInstance(currentAccount).loadFile(document, stickerSet, 1, 1);
                        }
                    }
                    if (value >= 0 && value < stickerSet.documents.size()) {
                        if (!instant && currentMessageObject.isOut()) {
                            MessagesController.DiceFrameSuccess frameSuccess = MessagesController.getInstance(currentAccount).diceSuccess.get(emoji);
                            if (frameSuccess != null && frameSuccess.num == value) {
                                lottieDrawable.setOnFinishCallback(diceFinishCallback, frameSuccess.frame);
                            }
                        }
                        TLRPC.Document document = stickerSet.documents.get(Math.max(value, 0));
                        File path = FileLoader.getPathToAttach(document, true);
                        if (lottieDrawable.setDiceNumber(path, instant)) {
                            DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
                        } else {
                            String fileName = FileLoader.getAttachFileName(document);
                            DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, currentMessageObject, this);
                            FileLoader.getInstance(currentAccount).loadFile(document, stickerSet, 1, 1);
                        }
                        currentMessageObject.wasUnread = false;
                    }
                }
            } else {
                MediaDataController.getInstance(currentAccount).loadStickersByEmojiOrName(emoji, true, true);
            }
        }
        return true;
    }
    return false;
}
Also used : SlotsDrawable(org.telegram.ui.Components.SlotsDrawable) 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) MessagesController(org.telegram.messenger.MessagesController) RLottieDrawable(org.telegram.ui.Components.RLottieDrawable) File(java.io.File) WebFile(org.telegram.messenger.WebFile) TLRPC(org.telegram.tgnet.TLRPC) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Point(org.telegram.ui.Components.Point)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 Paint (android.graphics.Paint)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Drawable (android.graphics.drawable.Drawable)1 RippleDrawable (android.graphics.drawable.RippleDrawable)1 TextPaint (android.text.TextPaint)1 File (java.io.File)1 MessagesController (org.telegram.messenger.MessagesController)1 WebFile (org.telegram.messenger.WebFile)1 TLRPC (org.telegram.tgnet.TLRPC)1 AnimatedFileDrawable (org.telegram.ui.Components.AnimatedFileDrawable)1 AudioVisualizerDrawable (org.telegram.ui.Components.AudioVisualizerDrawable)1 AvatarDrawable (org.telegram.ui.Components.AvatarDrawable)1 BackgroundGradientDrawable (org.telegram.ui.Components.BackgroundGradientDrawable)1 MediaActionDrawable (org.telegram.ui.Components.MediaActionDrawable)1 MessageBackgroundDrawable (org.telegram.ui.Components.MessageBackgroundDrawable)1 MotionBackgroundDrawable (org.telegram.ui.Components.MotionBackgroundDrawable)1 MsgClockDrawable (org.telegram.ui.Components.MsgClockDrawable)1 Point (org.telegram.ui.Components.Point)1 RLottieDrawable (org.telegram.ui.Components.RLottieDrawable)1