本文整理汇总了Java中org.telegram.tgnet.TLRPC.TL_messageMediaDocument方法的典型用法代码示例。如果您正苦于以下问题:Java TLRPC.TL_messageMediaDocument方法的具体用法?Java TLRPC.TL_messageMediaDocument怎么用?Java TLRPC.TL_messageMediaDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.telegram.tgnet.TLRPC
的用法示例。
在下文中一共展示了TLRPC.TL_messageMediaDocument方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFileName
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public String getFileName() {
if (messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
return FileLoader.getAttachFileName(messageOwner.media.document);
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
ArrayList<TLRPC.PhotoSize> sizes = messageOwner.media.photo.sizes;
if (sizes.size() > 0) {
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(sizes, AndroidUtilities.getPhotoSize());
if (sizeFull != null) {
return FileLoader.getAttachFileName(sizeFull);
}
}
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) {
return FileLoader.getAttachFileName(messageOwner.media.webpage.document);
}
return "";
}
示例2: canAddMessageToMedia
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public static boolean canAddMessageToMedia(TLRPC.Message message) {
if (message instanceof TLRPC.TL_message_secret && message.media instanceof TLRPC.TL_messageMediaPhoto && message.ttl != 0 && message.ttl <= 60) {
return false;
} else if (message.media instanceof TLRPC.TL_messageMediaPhoto ||
message.media instanceof TLRPC.TL_messageMediaDocument && !MessageObject.isGifDocument(message.media.document)) {
return true;
} else if (!message.entities.isEmpty()) {
for (int a = 0; a < message.entities.size(); a++) {
TLRPC.MessageEntity entity = message.entities.get(a);
if (entity instanceof TLRPC.TL_messageEntityUrl || entity instanceof TLRPC.TL_messageEntityTextUrl || entity instanceof TLRPC.TL_messageEntityEmail) {
return true;
}
}
}
return false;
}
示例3: newMessageMedia
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
private TLRPC.MessageMedia newMessageMedia(TLRPC.MessageMedia messageMedia) {
TLRPC.MessageMedia tL_messageMediaUnsupported_old = messageMedia instanceof TLRPC.TL_messageMediaUnsupported_old ? new TLRPC.TL_messageMediaUnsupported_old() : messageMedia instanceof TLRPC.TL_messageMediaAudio_layer45 ? new TLRPC.TL_messageMediaAudio_layer45() : messageMedia instanceof TLRPC.TL_messageMediaPhoto_old ? new TLRPC.TL_messageMediaPhoto_old() : messageMedia instanceof TLRPC.TL_messageMediaUnsupported ? new TLRPC.TL_messageMediaUnsupported() : messageMedia instanceof TLRPC.TL_messageMediaEmpty ? new TLRPC.TL_messageMediaEmpty() : messageMedia instanceof TLRPC.TL_messageMediaVenue ? new TLRPC.TL_messageMediaVenue() : messageMedia instanceof TLRPC.TL_messageMediaVideo_old ? new TLRPC.TL_messageMediaVideo_old() : messageMedia instanceof TLRPC.TL_messageMediaDocument_old ? new TLRPC.TL_messageMediaDocument_old() : messageMedia instanceof TLRPC.TL_messageMediaDocument ? new TLRPC.TL_messageMediaDocument() : messageMedia instanceof TLRPC.TL_messageMediaContact ? new TLRPC.TL_messageMediaContact() : messageMedia instanceof TLRPC.TL_messageMediaPhoto ? new TLRPC.TL_messageMediaPhoto() : messageMedia instanceof TLRPC.TL_messageMediaVideo_layer45 ? new TLRPC.TL_messageMediaVideo_layer45() : messageMedia instanceof TLRPC.TL_messageMediaWebPage ? new TLRPC.TL_messageMediaWebPage() : messageMedia instanceof TLRPC.TL_messageMediaGeo ? new TLRPC.TL_messageMediaGeo() : new TLRPC.MessageMedia();
tL_messageMediaUnsupported_old.bytes = messageMedia.bytes;
tL_messageMediaUnsupported_old.caption = messageMedia.caption;
tL_messageMediaUnsupported_old.photo = messageMedia.photo;
tL_messageMediaUnsupported_old.audio_unused = messageMedia.audio_unused;
tL_messageMediaUnsupported_old.geo = messageMedia.geo;
tL_messageMediaUnsupported_old.title = messageMedia.title;
tL_messageMediaUnsupported_old.address = messageMedia.address;
tL_messageMediaUnsupported_old.provider = messageMedia.provider;
tL_messageMediaUnsupported_old.venue_id = messageMedia.venue_id;
tL_messageMediaUnsupported_old.document = messageMedia.document;
tL_messageMediaUnsupported_old.video_unused = messageMedia.video_unused;
tL_messageMediaUnsupported_old.phone_number = messageMedia.phone_number;
tL_messageMediaUnsupported_old.first_name = messageMedia.first_name;
tL_messageMediaUnsupported_old.last_name = messageMedia.last_name;
tL_messageMediaUnsupported_old.user_id = messageMedia.user_id;
tL_messageMediaUnsupported_old.webpage = messageMedia.webpage;
return tL_messageMediaUnsupported_old;
}
示例4: getFileType
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public int getFileType() {
if (isVideo()) {
return FileLoader.MEDIA_DIR_VIDEO;
} else if (isVoice()) {
return FileLoader.MEDIA_DIR_AUDIO;
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
return FileLoader.MEDIA_DIR_DOCUMENT;
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
return FileLoader.MEDIA_DIR_IMAGE;
}
return FileLoader.MEDIA_DIR_CACHE;
}
示例5: canEditMessage
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public static boolean canEditMessage(TLRPC.Message message, TLRPC.Chat chat) {
if (message == null || message.to_id == null || message.action != null && !(message.action instanceof TLRPC.TL_messageActionEmpty) || isForwardedMessage(message) || message.via_bot_id != 0 || message.id < 0 || Math.abs(message.date - ConnectionsManager.getInstance().getCurrentTime()) > MessagesController.getInstance().maxEditTime) {
return false;
}
if (message.to_id.channel_id == 0) {
return message.out && (message.media instanceof TLRPC.TL_messageMediaPhoto ||
message.media instanceof TLRPC.TL_messageMediaDocument && !isStickerMessage(message) ||
message.media instanceof TLRPC.TL_messageMediaEmpty ||
message.media instanceof TLRPC.TL_messageMediaWebPage ||
message.media == null);
}
if (chat == null && message.to_id.channel_id != 0) {
chat = MessagesController.getInstance().getChat(message.to_id.channel_id);
if (chat == null) {
return false;
}
}
if (chat.megagroup && message.out || !chat.megagroup && (chat.creator || chat.editor && isOut(message)) && message.post) {
if (message.media instanceof TLRPC.TL_messageMediaPhoto ||
message.media instanceof TLRPC.TL_messageMediaDocument && !isStickerMessage(message) ||
message.media instanceof TLRPC.TL_messageMediaEmpty ||
message.media instanceof TLRPC.TL_messageMediaWebPage ||
message.media == null) {
return true;
}
}
return false;
}
示例6: getMediaType
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public static int getMediaType(TLRPC.Message message) {
if (message == null) {
return -1;
}
if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
return MEDIA_PHOTOVIDEO;
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
if (MessageObject.isVoiceMessage(message)) {
return MEDIA_AUDIO;
} else if (MessageObject.isVideoMessage(message)) {
return MEDIA_PHOTOVIDEO;
} else if (MessageObject.isStickerMessage(message)) {
return -1;
} else if (MessageObject.isMusicMessage(message)) {
return MEDIA_MUSIC;
} else {
return MEDIA_FILE;
}
} else if (!message.entities.isEmpty()) {
for (int a = 0; a < message.entities.size(); a++) {
TLRPC.MessageEntity entity = message.entities.get(a);
if (entity instanceof TLRPC.TL_messageEntityUrl || entity instanceof TLRPC.TL_messageEntityTextUrl || entity instanceof TLRPC.TL_messageEntityEmail) {
return MEDIA_URL;
}
}
}
return -1;
}
示例7: canEditMessage
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public static boolean canEditMessage(TLRPC.Message message, TLRPC.Chat chat) {
if (message == null || message.to_id == null || message.action != null && !(message.action instanceof TLRPC.TL_messageActionEmpty) || isForwardedMessage(message) || message.via_bot_id != 0 || message.id < 0) {
return false;
}
if (message.from_id == message.to_id.user_id && message.from_id == UserConfig.getClientUserId()) {
return true;
}
if (Math.abs(message.date - ConnectionsManager.getInstance().getCurrentTime()) > MessagesController.getInstance().maxEditTime) {
return false;
}
if (message.to_id.channel_id == 0) {
return (message.out || message.from_id == UserConfig.getClientUserId()) && (message.media instanceof TLRPC.TL_messageMediaPhoto ||
message.media instanceof TLRPC.TL_messageMediaDocument && !isStickerMessage(message) ||
message.media instanceof TLRPC.TL_messageMediaEmpty ||
message.media instanceof TLRPC.TL_messageMediaWebPage ||
message.media == null);
}
if (chat == null && message.to_id.channel_id != 0) {
chat = MessagesController.getInstance().getChat(message.to_id.channel_id);
if (chat == null) {
return false;
}
}
if (chat.megagroup && message.out || !chat.megagroup && (chat.creator || chat.editor && isOut(message)) && message.post) {
if (message.media instanceof TLRPC.TL_messageMediaPhoto ||
message.media instanceof TLRPC.TL_messageMediaDocument && !isStickerMessage(message) ||
message.media instanceof TLRPC.TL_messageMediaEmpty ||
message.media instanceof TLRPC.TL_messageMediaWebPage ||
message.media == null) {
return true;
}
}
return false;
}
示例8: generatePinMessageText
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public void generatePinMessageText(TLRPC.User fromUser, TLRPC.Chat chat) {
if (fromUser == null && chat == null) {
if (messageOwner.from_id > 0) {
fromUser = MessagesController.getInstance().getUser(messageOwner.from_id);
}
if (fromUser == null) {
chat = MessagesController.getInstance().getChat(messageOwner.to_id.channel_id);
}
}
if (replyMessageObject == null) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedNoText", R.string.ActionPinnedNoText), "un1", fromUser != null ? fromUser : chat);
} else {
if (replyMessageObject.isMusic()) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedMusic", R.string.ActionPinnedMusic), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.isVideo()) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedVideo", R.string.ActionPinnedVideo), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.isGif()) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedGif", R.string.ActionPinnedGif), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.isVoice()) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedVoice", R.string.ActionPinnedVoice), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.isSticker()) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedSticker", R.string.ActionPinnedSticker), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedFile", R.string.ActionPinnedFile), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedGeo", R.string.ActionPinnedGeo), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedContact", R.string.ActionPinnedContact), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedPhoto", R.string.ActionPinnedPhoto), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.messageText != null && replyMessageObject.messageText.length() > 0) {
CharSequence mess = replyMessageObject.messageText;
if (mess.length() > 20) {
mess = mess.subSequence(0, 20) + "...";
}
mess = Emoji.replaceEmoji(mess, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
messageText = replaceWithLink(LocaleController.formatString("ActionPinnedText", R.string.ActionPinnedText, mess), "un1", fromUser != null ? fromUser : chat);
} else {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedNoText", R.string.ActionPinnedNoText), "un1", fromUser != null ? fromUser : chat);
}
}
}
示例9: setType
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public void setType() {
int oldType = type;
if (messageOwner instanceof TLRPC.TL_message || messageOwner instanceof TLRPC.TL_messageForwarded_old2) {
if (isMediaEmpty()) {
type = 0;
if (messageText == null || messageText.length() == 0) {
messageText = "Empty message";
}
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
type = 1;
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaGeo || messageOwner.media instanceof TLRPC.TL_messageMediaVenue) {
type = 4;
} else if (isVideo()) {
type = 3;
} else if (isVoice()) {
type = 2;
} else if (isMusic()) {
type = 14;
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
type = 12;
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaUnsupported) {
type = 0;
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
if (messageOwner.media.document.mime_type != null) {
if (isGifDocument(messageOwner.media.document)) {
type = 8;
} else if (messageOwner.media.document.mime_type.equals("image/webp") && isSticker()) {
type = 13;
} else {
type = 9;
}
} else {
type = 9;
}
}
} else if (messageOwner instanceof TLRPC.TL_messageService) {
if (messageOwner.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
type = 0;
} else if (messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto || messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
contentType = 1;
type = 11;
} else if (messageOwner.action instanceof TLRPC.TL_messageEncryptedAction) {
if (messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages || messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
contentType = 1;
type = 10;
} else {
contentType = -1;
type = -1;
}
} else if (messageOwner.action instanceof TLRPC.TL_messageActionHistoryClear) {
contentType = -1;
type = -1;
} else {
contentType = 1;
type = 10;
}
}
if (oldType != 1000 && oldType != type) {
generateThumbs(false);
}
}
示例10: isGif
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public boolean isGif() {
return messageOwner.media instanceof TLRPC.TL_messageMediaDocument && isGifDocument(messageOwner.media.document);
}
示例11: generatePinMessageText
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public void generatePinMessageText(TLRPC.User fromUser, TLRPC.Chat chat) {
if (fromUser == null && chat == null) {
if (messageOwner.from_id > 0) {
fromUser = MessagesController.getInstance().getUser(messageOwner.from_id);
}
if (fromUser == null) {
chat = MessagesController.getInstance().getChat(messageOwner.to_id.channel_id);
}
}
if (replyMessageObject == null) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedNoText", R.string.ActionPinnedNoText), "un1", fromUser != null ? fromUser : chat);
} else {
if (replyMessageObject.isMusic()) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedMusic", R.string.ActionPinnedMusic), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.isVideo()) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedVideo", R.string.ActionPinnedVideo), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.isGif()) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedGif", R.string.ActionPinnedGif), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.isVoice()) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedVoice", R.string.ActionPinnedVoice), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.isSticker()) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedSticker", R.string.ActionPinnedSticker), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedFile", R.string.ActionPinnedFile), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedGeo", R.string.ActionPinnedGeo), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedContact", R.string.ActionPinnedContact), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedPhoto", R.string.ActionPinnedPhoto), "un1", fromUser != null ? fromUser : chat);
} else if (replyMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
messageText = replaceWithLink(LocaleController.formatString("ActionPinnedGame", R.string.ActionPinnedGame, "\uD83C\uDFAE " + replyMessageObject.messageOwner.media.game.title), "un1", fromUser != null ? fromUser : chat);
messageText = Emoji.replaceEmoji(messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
} else if (replyMessageObject.messageText != null && replyMessageObject.messageText.length() > 0) {
CharSequence mess = replyMessageObject.messageText;
if (mess.length() > 20) {
mess = mess.subSequence(0, 20) + "...";
}
mess = Emoji.replaceEmoji(mess, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
messageText = replaceWithLink(LocaleController.formatString("ActionPinnedText", R.string.ActionPinnedText, mess), "un1", fromUser != null ? fromUser : chat);
} else {
messageText = replaceWithLink(LocaleController.getString("ActionPinnedNoText", R.string.ActionPinnedNoText), "un1", fromUser != null ? fromUser : chat);
}
}
}
示例12: setType
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public void setType() {
int oldType = type;
if (messageOwner instanceof TLRPC.TL_message || messageOwner instanceof TLRPC.TL_messageForwarded_old2) {
if (isMediaEmpty()) {
type = 0;
if (messageText == null || messageText.length() == 0) {
messageText = "Empty message";
}
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
type = 1;
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaGeo || messageOwner.media instanceof TLRPC.TL_messageMediaVenue) {
type = 4;
} else if (isVideo()) {
type = 3;
} else if (isVoice()) {
type = 2;
} else if (isMusic()) {
type = 14;
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
type = 12;
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaUnsupported) {
type = 0;
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
if (messageOwner.media.document != null && messageOwner.media.document.mime_type != null) {
if (isGifDocument(messageOwner.media.document)) {
type = 8;
} else if (messageOwner.media.document.mime_type.equals("image/webp") && isSticker()) {
type = 13;
} else {
type = 9;
}
} else {
type = 9;
}
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
type = 0;
}
} else if (messageOwner instanceof TLRPC.TL_messageService) {
if (messageOwner.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
type = 0;
} else if (messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto || messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
contentType = 1;
type = 11;
} else if (messageOwner.action instanceof TLRPC.TL_messageEncryptedAction) {
if (messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionScreenshotMessages || messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) {
contentType = 1;
type = 10;
} else {
contentType = -1;
type = -1;
}
} else if (messageOwner.action instanceof TLRPC.TL_messageActionHistoryClear) {
contentType = -1;
type = -1;
} else {
contentType = 1;
type = 10;
}
}
if (oldType != 1000 && oldType != type) {
generateThumbs(false);
}
}