Search in sources :

Example 11 with JsPromiseExecutor

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

the class JsFacade method editMyName.

// Profile
@UsedByApp
public JsPromise editMyName(final String newName) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            //noinspection ConstantConditions
            messenger.editMyName(newName).start(new CommandCallback<Boolean>() {

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

                @Override
                public void onError(Exception e) {
                    Log.d(TAG, "editMyName: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 12 with JsPromiseExecutor

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

the class JsFacade method findAllLinks.

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

        @Override
        public void execute() {
            messenger.findAllLinks(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 13 with JsPromiseExecutor

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

the class JsFacade method addContact.

@UsedByApp
public JsPromise addContact(final int uid) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            //noinspection ConstantConditions
            messenger.addContact(uid).start(new CommandCallback<Boolean>() {

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

                @Override
                public void onError(Exception e) {
                    Log.d(TAG, "addContact: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 14 with JsPromiseExecutor

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

the class JsFacade method getIntegrationToken.

@UsedByApp
public JsPromise getIntegrationToken(final int gid) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            //noinspection ConstantConditions
            messenger.requestIntegrationToken(gid).start(new CommandCallback<String>() {

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

                @Override
                public void onError(Exception e) {
                    Log.d(TAG, "getIntegrationToken: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 15 with JsPromiseExecutor

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

the class JsFacade method findAllDocs.

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

        @Override
        public void execute() {
            messenger.findAllDocs(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)

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