private void performSendContent(final Peer peer, final long rid, AbsContent content) {
        WakeLock wakeLock = im.actor.runtime.Runtime.makeWakeLock();

        ApiMessage message;
        if (content instanceof TextContent) {
            message = new ApiTextMessage(((TextContent) content).getText(), ((TextContent) content).getMentions(), ((TextContent) content).getTextMessageEx());
        } else if (content instanceof DocumentContent) {
            DocumentContent documentContent = (DocumentContent) content;

            FileRemoteSource source = (FileRemoteSource) documentContent.getSource();

            ApiDocumentEx documentEx = null;

            if (content instanceof PhotoContent) {
                PhotoContent photoContent = (PhotoContent) content;
                documentEx = new ApiDocumentExPhoto(photoContent.getW(), photoContent.getH());
            } else if (content instanceof VideoContent) {
                VideoContent videoContent = (VideoContent) content;
                documentEx = new ApiDocumentExVideo(videoContent.getW(), videoContent.getH(), videoContent.getDuration());
            } else if (content instanceof AnimationContent) {
                AnimationContent animationContent = (AnimationContent) content;
                documentEx = new ApiDocumentExAnimation(animationContent.getW(), animationContent.getH());
            } else if (content instanceof VoiceContent) {
                VoiceContent voiceContent = (VoiceContent) content;
                documentEx = new ApiDocumentExVoice(voiceContent.getDuration());
            }


            ApiFastThumb fastThumb = null;
            if (documentContent.getFastThumb() != null) {
                fastThumb = new ApiFastThumb(
                        documentContent.getFastThumb().getW(),
                        documentContent.getFastThumb().getH(),
                        documentContent.getFastThumb().getImage());
            }

            message = new ApiDocumentMessage(source.getFileReference().getFileId(),
                    source.getFileReference().getAccessHash(),
                    source.getFileReference().getFileSize(),
                    source.getFileReference().getFileName(),
                    documentContent.getMimeType(),
                    fastThumb, documentEx);
        } else if (content instanceof LocationContent) {
            message = new ApiJsonMessage(((LocationContent) content).getRawJson());
        } else if (content instanceof ContactContent) {
            message = new ApiJsonMessage(((ContactContent) content).getRawJson());
        } else if (content instanceof JsonContent) {
            message = new ApiJsonMessage(((JsonContent) content).getRawJson());
        } else if (content instanceof StickerContent) {
            message = ((ContentRemoteContainer) content.getContentContainer()).getMessage();
        } else {
            return;
        }

        performSendApiContent(peer, rid, message, wakeLock);
    }
private void performSendContent ( final Peer peer , final long rid , AbsContent content ) { WakeLock wakeLock = im . actor . runtime . Runtime . makeWakeLock ( ) ; ApiMessage message ; if ( content instanceof TextContent ) { message = new ApiTextMessage ( ( ( TextContent ) content ) . getText ( ) , ( ( TextContent ) content ) . getMentions ( ) , ( ( TextContent ) content ) . getTextMessageEx ( ) ) ; } else if ( content instanceof DocumentContent ) { DocumentContent documentContent = ( DocumentContent ) content ; FileRemoteSource source = ( FileRemoteSource ) documentContent . getSource ( ) ; ApiDocumentEx documentEx = null ; if ( content instanceof PhotoContent ) { PhotoContent photoContent = ( PhotoContent ) content ; documentEx = new ApiDocumentExPhoto ( photoContent . getW ( ) , photoContent . getH ( ) ) ; } else if ( content instanceof VideoContent ) { VideoContent videoContent = ( VideoContent ) content ; documentEx = new ApiDocumentExVideo ( videoContent . getW ( ) , videoContent . getH ( ) , videoContent . getDuration ( ) ) ; } else if ( content instanceof AnimationContent ) { AnimationContent animationContent = ( AnimationContent ) content ; documentEx = new ApiDocumentExAnimation ( animationContent . getW ( ) , animationContent . getH ( ) ) ; } else if ( content instanceof VoiceContent ) { VoiceContent voiceContent = ( VoiceContent ) content ; documentEx = new ApiDocumentExVoice ( voiceContent . getDuration ( ) ) ; } ApiFastThumb fastThumb = null ; if ( documentContent . getFastThumb ( ) != null ) { fastThumb = new ApiFastThumb ( documentContent . getFastThumb ( ) . getW ( ) , documentContent . getFastThumb ( ) . getH ( ) , documentContent . getFastThumb ( ) . getImage ( ) ) ; } message = new ApiDocumentMessage ( source . getFileReference ( ) . getFileId ( ) , source . getFileReference ( ) . getAccessHash ( ) , source . getFileReference ( ) . getFileSize ( ) , source . getFileReference ( ) . getFileName ( ) , documentContent . getMimeType ( ) , fastThumb , documentEx ) ; } else if ( content instanceof LocationContent ) { message = new ApiJsonMessage ( ( ( LocationContent ) content ) . getRawJson ( ) ) ; } else if ( content instanceof ContactContent ) { message = new ApiJsonMessage ( ( ( ContactContent ) content ) . getRawJson ( ) ) ; } else if ( content instanceof JsonContent ) { message = new ApiJsonMessage ( ( ( JsonContent ) content ) . getRawJson ( ) ) ; } else if ( content instanceof StickerContent ) { message = ( ( ContentRemoteContainer ) content . getContentContainer ( ) ) . getMessage ( ) ; } else { return ; } performSendApiContent ( peer , rid , message , wakeLock ) ; }
Sending content