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;
}
Aggregations