Search in sources :

Example 1 with ApiServiceExChangedAvatar

use of im.actor.core.api.ApiServiceExChangedAvatar in project actor-platform by actorapp.

the class AbsContent method convertData.

protected static AbsContent convertData(AbsContentContainer container) {
    if (container instanceof ContentLocalContainer) {
        ContentLocalContainer localContainer = (ContentLocalContainer) container;
        AbsLocalContent content = ((ContentLocalContainer) container).getContent();
        if (content instanceof LocalPhoto) {
            return new PhotoContent(localContainer);
        } else if (content instanceof LocalVideo) {
            return new VideoContent(localContainer);
        } else if (content instanceof LocalVoice) {
            return new VoiceContent(localContainer);
        } else if (content instanceof LocalAnimation) {
            return new AnimationContent(localContainer);
        } else if (content instanceof LocalDocument) {
            return new DocumentContent(localContainer);
        } else {
            throw new RuntimeException("Unknown type");
        }
    } else if (container instanceof ContentRemoteContainer) {
        ContentRemoteContainer remoteContainer = (ContentRemoteContainer) container;
        ApiMessage content = ((ContentRemoteContainer) container).getMessage();
        try {
            if (content instanceof ApiDocumentMessage) {
                ApiDocumentMessage d = (ApiDocumentMessage) content;
                if (d.getExt() instanceof ApiDocumentExPhoto) {
                    return new PhotoContent(remoteContainer);
                } else if (d.getExt() instanceof ApiDocumentExVideo) {
                    return new VideoContent(remoteContainer);
                } else if (d.getExt() instanceof ApiDocumentExVoice) {
                    return new VoiceContent(remoteContainer);
                } else if (d.getExt() instanceof ApiDocumentExAnimation) {
                    return new AnimationContent(remoteContainer);
                } else {
                    return new DocumentContent(remoteContainer);
                }
            } else if (content instanceof ApiTextMessage) {
                return new TextContent(remoteContainer);
            } else if (content instanceof ApiServiceMessage) {
                ApiServiceEx ext = ((ApiServiceMessage) content).getExt();
                if (ext instanceof ApiServiceExContactRegistered) {
                    return new ServiceUserRegistered(remoteContainer);
                } else if (ext instanceof ApiServiceExChangedTitle) {
                    return new ServiceGroupTitleChanged(remoteContainer);
                } else if (ext instanceof ApiServiceExChangedTopic) {
                    return new ServiceGroupTopicChanged(remoteContainer);
                } else if (ext instanceof ApiServiceExChangedAbout) {
                    return new ServiceGroupAboutChanged(remoteContainer);
                } else if (ext instanceof ApiServiceExChangedAvatar) {
                    return new ServiceGroupAvatarChanged(remoteContainer);
                } else if (ext instanceof ApiServiceExGroupCreated) {
                    return new ServiceGroupCreated(remoteContainer);
                } else if (ext instanceof ApiServiceExUserInvited) {
                    return new ServiceGroupUserInvited(remoteContainer);
                } else if (ext instanceof ApiServiceExUserKicked) {
                    return new ServiceGroupUserKicked(remoteContainer);
                } else if (ext instanceof ApiServiceExUserLeft) {
                    return new ServiceGroupUserLeave(remoteContainer);
                } else if (ext instanceof ApiServiceExUserJoined) {
                    return new ServiceGroupUserJoined(remoteContainer);
                } else if (ext instanceof ApiServiceExPhoneCall) {
                    return new ServiceCallEnded(remoteContainer);
                } else if (ext instanceof ApiServiceExPhoneMissed) {
                    return new ServiceCallMissed(remoteContainer);
                } else {
                    return new ServiceContent(remoteContainer);
                }
            } else if (content instanceof ApiJsonMessage) {
                ApiJsonMessage json = (ApiJsonMessage) content;
                JSONObject object = new JSONObject(json.getRawJson());
                if (object.getString("dataType").equals("contact")) {
                    return new ContactContent(remoteContainer);
                } else if (object.getString("dataType").equals("location")) {
                    return new LocationContent(remoteContainer);
                } else {
                    return new JsonContent(remoteContainer);
                }
            } else if (content instanceof ApiStickerMessage) {
                return new StickerContent(remoteContainer);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        // Fallback
        return new UnsupportedContent(remoteContainer);
    } else {
        throw new RuntimeException("Unknown type");
    }
}
Also used : ApiTextMessage(im.actor.core.api.ApiTextMessage) ApiStickerMessage(im.actor.core.api.ApiStickerMessage) ApiServiceExUserLeft(im.actor.core.api.ApiServiceExUserLeft) ApiServiceExChangedAvatar(im.actor.core.api.ApiServiceExChangedAvatar) LocalPhoto(im.actor.core.entity.content.internal.LocalPhoto) ApiServiceExChangedTopic(im.actor.core.api.ApiServiceExChangedTopic) ApiServiceExUserJoined(im.actor.core.api.ApiServiceExUserJoined) ApiServiceMessage(im.actor.core.api.ApiServiceMessage) ApiJsonMessage(im.actor.core.api.ApiJsonMessage) ApiServiceExChangedAbout(im.actor.core.api.ApiServiceExChangedAbout) ContentRemoteContainer(im.actor.core.entity.content.internal.ContentRemoteContainer) ApiDocumentExAnimation(im.actor.core.api.ApiDocumentExAnimation) ContentLocalContainer(im.actor.core.entity.content.internal.ContentLocalContainer) ApiDocumentExVideo(im.actor.core.api.ApiDocumentExVideo) LocalVoice(im.actor.core.entity.content.internal.LocalVoice) AbsLocalContent(im.actor.core.entity.content.internal.AbsLocalContent) ApiServiceExUserInvited(im.actor.core.api.ApiServiceExUserInvited) JSONObject(im.actor.runtime.json.JSONObject) ApiMessage(im.actor.core.api.ApiMessage) LocalDocument(im.actor.core.entity.content.internal.LocalDocument) ApiDocumentExVoice(im.actor.core.api.ApiDocumentExVoice) ApiServiceEx(im.actor.core.api.ApiServiceEx) ApiServiceExChangedTitle(im.actor.core.api.ApiServiceExChangedTitle) ApiServiceExPhoneCall(im.actor.core.api.ApiServiceExPhoneCall) ApiServiceExPhoneMissed(im.actor.core.api.ApiServiceExPhoneMissed) LocalAnimation(im.actor.core.entity.content.internal.LocalAnimation) ApiServiceExGroupCreated(im.actor.core.api.ApiServiceExGroupCreated) IOException(java.io.IOException) LocalVideo(im.actor.core.entity.content.internal.LocalVideo) ApiDocumentMessage(im.actor.core.api.ApiDocumentMessage) ApiDocumentExPhoto(im.actor.core.api.ApiDocumentExPhoto) ApiServiceExUserKicked(im.actor.core.api.ApiServiceExUserKicked) ApiServiceExContactRegistered(im.actor.core.api.ApiServiceExContactRegistered)

Aggregations

ApiDocumentExAnimation (im.actor.core.api.ApiDocumentExAnimation)1 ApiDocumentExPhoto (im.actor.core.api.ApiDocumentExPhoto)1 ApiDocumentExVideo (im.actor.core.api.ApiDocumentExVideo)1 ApiDocumentExVoice (im.actor.core.api.ApiDocumentExVoice)1 ApiDocumentMessage (im.actor.core.api.ApiDocumentMessage)1 ApiJsonMessage (im.actor.core.api.ApiJsonMessage)1 ApiMessage (im.actor.core.api.ApiMessage)1 ApiServiceEx (im.actor.core.api.ApiServiceEx)1 ApiServiceExChangedAbout (im.actor.core.api.ApiServiceExChangedAbout)1 ApiServiceExChangedAvatar (im.actor.core.api.ApiServiceExChangedAvatar)1 ApiServiceExChangedTitle (im.actor.core.api.ApiServiceExChangedTitle)1 ApiServiceExChangedTopic (im.actor.core.api.ApiServiceExChangedTopic)1 ApiServiceExContactRegistered (im.actor.core.api.ApiServiceExContactRegistered)1 ApiServiceExGroupCreated (im.actor.core.api.ApiServiceExGroupCreated)1 ApiServiceExPhoneCall (im.actor.core.api.ApiServiceExPhoneCall)1 ApiServiceExPhoneMissed (im.actor.core.api.ApiServiceExPhoneMissed)1 ApiServiceExUserInvited (im.actor.core.api.ApiServiceExUserInvited)1 ApiServiceExUserJoined (im.actor.core.api.ApiServiceExUserJoined)1 ApiServiceExUserKicked (im.actor.core.api.ApiServiceExUserKicked)1 ApiServiceExUserLeft (im.actor.core.api.ApiServiceExUserLeft)1