コード例 #1
0
 @Override
 public void onReceive(Object message) {
   if (message instanceof SendText) {
     SendText sendText = (SendText) message;
     doSendText(
         sendText.getPeer(),
         sendText.getText(),
         sendText.getMentions(),
         sendText.getMarkDownText(),
         sendText.isAutoDetect());
   } else if (message instanceof MessageSent) {
     MessageSent messageSent = (MessageSent) message;
     onSent(messageSent.getPeer(), messageSent.getRid());
   } else if (message instanceof MessageError) {
     MessageError messageError = (MessageError) message;
     onError(messageError.getPeer(), messageError.getRid());
   } else if (message instanceof SendDocument) {
     SendDocument sendDocument = (SendDocument) message;
     doSendDocument(
         sendDocument.getPeer(),
         sendDocument.getFileName(),
         sendDocument.getMimeType(),
         sendDocument.getFileSize(),
         sendDocument.getFastThumb(),
         sendDocument.getDescriptor());
   } else if (message instanceof UploadManager.UploadCompleted) {
     UploadManager.UploadCompleted uploadCompleted = (UploadManager.UploadCompleted) message;
     onFileUploaded(uploadCompleted.getRid(), uploadCompleted.getFileReference());
   } else if (message instanceof UploadManager.UploadError) {
     UploadManager.UploadError uploadError = (UploadManager.UploadError) message;
     onFileUploadError(uploadError.getRid());
   } else if (message instanceof SendPhoto) {
     SendPhoto sendPhoto = (SendPhoto) message;
     doSendPhoto(
         sendPhoto.getPeer(),
         sendPhoto.getFastThumb(),
         sendPhoto.getDescriptor(),
         sendPhoto.getFileName(),
         sendPhoto.getFileSize(),
         sendPhoto.getW(),
         sendPhoto.getH());
   } else if (message instanceof SendVideo) {
     SendVideo sendVideo = (SendVideo) message;
     doSendVideo(
         sendVideo.getPeer(),
         sendVideo.getFileName(),
         sendVideo.getW(),
         sendVideo.getH(),
         sendVideo.getDuration(),
         sendVideo.getFastThumb(),
         sendVideo.getDescriptor(),
         sendVideo.getFileSize());
   } else if (message instanceof SendAudio) {
     SendAudio sendAudio = (SendAudio) message;
     doSendAudio(
         sendAudio.getPeer(),
         sendAudio.getDescriptor(),
         sendAudio.getFileName(),
         sendAudio.getFileSize(),
         sendAudio.getDuration());
   } else if (message instanceof SendContact) {
     SendContact sendContact = (SendContact) message;
     doSendContact(
         sendContact.getPeer(),
         sendContact.getEmails(),
         sendContact.getPhones(),
         sendContact.getName(),
         sendContact.getBase64photo());
   } else if (message instanceof SendLocation) {
     SendLocation sendLocation = (SendLocation) message;
     doSendLocation(
         sendLocation.getPeer(),
         sendLocation.getLongitude(),
         sendLocation.getLatitude(),
         sendLocation.getStreet(),
         sendLocation.getPlace());
   } else if (message instanceof SendSticker) {
     SendSticker sendSticker = (SendSticker) message;
     doSendSticker(sendSticker.getPeer(), sendSticker.getSticker());
   } else if (message instanceof SendJson) {
     SendJson sendJson = (SendJson) message;
     doSendJson(sendJson.getPeer(), sendJson.getJson());
   } else if (message instanceof ForwardContent) {
     ForwardContent forwardContent = (ForwardContent) message;
     doForwardContent(forwardContent.getPeer(), forwardContent.getContent());
   } else if (message instanceof SendAnimation) {
     SendAnimation animation = (SendAnimation) message;
     doSendAnimation(
         animation.getPeer(),
         animation.getFileName(),
         animation.getW(),
         animation.getH(),
         animation.getFastThumb(),
         animation.getDescriptor(),
         animation.getFileSize());
   } else {
     super.onReceive(message);
   }
 }