Search in sources :

Example 1 with JsPromiseExecutor

use of im.actor.runtime.js.utils.JsPromiseExecutor in project actor-platform by actorapp.

the class JsFacade method doCall.

// Calls
@UsedByApp
public JsPromise doCall(final int uid) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            messenger.doCall(uid).start(new CommandCallback<Long>() {

                @Override
                public void onResult(Long res) {
                    Log.d(TAG, "doCall:result");
                    resolve();
                }

                @Override
                public void onError(Exception e) {
                    Log.d(TAG, "doCall:error");
                    reject(e.getMessage());
                }
            });
        }
    });
}
Also used : JsPromiseExecutor(im.actor.runtime.js.utils.JsPromiseExecutor) CommandCallback(im.actor.core.viewmodel.CommandCallback) RpcException(im.actor.core.network.RpcException) UsedByApp(im.actor.core.js.annotations.UsedByApp)

Example 2 with JsPromiseExecutor

use of im.actor.runtime.js.utils.JsPromiseExecutor in project actor-platform by actorapp.

the class JsFacade method findAllPhotos.

@UsedByApp
public JsPromise findAllPhotos(final JsPeer peer) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            messenger.findAllPhotos(peer.convert()).start(new CommandCallback<List<MessageSearchEntity>>() {

                @Override
                public void onResult(List<MessageSearchEntity> res) {
                    resolve(convertSearchRes(res));
                }

                @Override
                public void onError(Exception e) {
                    Log.d(TAG, "findAllText:error");
                    reject(e.getMessage());
                }
            });
        }
    });
}
Also used : JsPromiseExecutor(im.actor.runtime.js.utils.JsPromiseExecutor) MessageSearchEntity(im.actor.core.entity.MessageSearchEntity) List(java.util.List) ArrayList(java.util.ArrayList) CommandCallback(im.actor.core.viewmodel.CommandCallback) RpcException(im.actor.core.network.RpcException) UsedByApp(im.actor.core.js.annotations.UsedByApp)

Example 3 with JsPromiseExecutor

use of im.actor.runtime.js.utils.JsPromiseExecutor in project actor-platform by actorapp.

the class JsFacade method findAllText.

@UsedByApp
public JsPromise findAllText(final JsPeer peer, final String query) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            messenger.findTextMessages(peer.convert(), query).start(new CommandCallback<List<MessageSearchEntity>>() {

                @Override
                public void onResult(List<MessageSearchEntity> res) {
                    resolve(convertSearchRes(res));
                }

                @Override
                public void onError(Exception e) {
                    Log.d(TAG, "findAllText:error");
                    reject(e.getMessage());
                }
            });
        }
    });
}
Also used : JsPromiseExecutor(im.actor.runtime.js.utils.JsPromiseExecutor) MessageSearchEntity(im.actor.core.entity.MessageSearchEntity) List(java.util.List) ArrayList(java.util.ArrayList) CommandCallback(im.actor.core.viewmodel.CommandCallback) RpcException(im.actor.core.network.RpcException) UsedByApp(im.actor.core.js.annotations.UsedByApp)

Example 4 with JsPromiseExecutor

use of im.actor.runtime.js.utils.JsPromiseExecutor in project actor-platform by actorapp.

the class JsFacade method deleteChat.

@UsedByApp
public JsPromise deleteChat(final JsPeer peer) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            messenger.deleteChat(peer.convert()).start(new CommandCallback<Void>() {

                @Override
                public void onResult(Void res) {
                    Log.d(TAG, "deleteChat:result");
                    resolve();
                }

                @Override
                public void onError(Exception e) {
                    Log.d(TAG, "deleteChat:error");
                    reject(e.getMessage());
                }
            });
        }
    });
}
Also used : JsPromiseExecutor(im.actor.runtime.js.utils.JsPromiseExecutor) CommandCallback(im.actor.core.viewmodel.CommandCallback) Void(im.actor.runtime.actors.messages.Void) RpcException(im.actor.core.network.RpcException) UsedByApp(im.actor.core.js.annotations.UsedByApp)

Example 5 with JsPromiseExecutor

use of im.actor.runtime.js.utils.JsPromiseExecutor in project actor-platform by actorapp.

the class JsFacade method joinGroupViaLink.

@UsedByApp
public JsPromise joinGroupViaLink(final String url) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            //noinspection ConstantConditions
            messenger.joinGroupViaToken(url).start(new CommandCallback<Integer>() {

                @Override
                public void onResult(Integer res) {
                    Log.d(TAG, "joinGroupViaLink:result");
                    resolve(JsPeer.create(Peer.group(res)));
                }

                @Override
                public void onError(Exception e) {
                    Log.d(TAG, "joinGroupViaLink:error");
                    reject(e.getMessage());
                }
            });
        }
    });
}
Also used : JsPromiseExecutor(im.actor.runtime.js.utils.JsPromiseExecutor) CommandCallback(im.actor.core.viewmodel.CommandCallback) RpcException(im.actor.core.network.RpcException) UsedByApp(im.actor.core.js.annotations.UsedByApp)

Aggregations

UsedByApp (im.actor.core.js.annotations.UsedByApp)29 RpcException (im.actor.core.network.RpcException)29 JsPromiseExecutor (im.actor.runtime.js.utils.JsPromiseExecutor)29 CommandCallback (im.actor.core.viewmodel.CommandCallback)28 Void (im.actor.runtime.actors.messages.Void)9 ArrayList (java.util.ArrayList)5 List (java.util.List)5 MessageSearchEntity (im.actor.core.entity.MessageSearchEntity)4 ApiAuthSession (im.actor.core.api.ApiAuthSession)1 ApiDialog (im.actor.core.api.ApiDialog)1 ResponseLoadArchived (im.actor.core.api.rpc.ResponseLoadArchived)1 RpcCallback (im.actor.core.network.RpcCallback)1 UserVM (im.actor.core.viewmodel.UserVM)1