Search in sources :

Example 21 with JsPromiseExecutor

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

the class JsFacade method unfavoriteChat.

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

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

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

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

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

the class JsFacade method removeContact.

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

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

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

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

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

the class JsFacade method revokeInviteLink.

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

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

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

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

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

the class JsFacade method doGroupCall.

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

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

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

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

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

the class JsFacade method loadSessions.

@UsedByApp
public JsPromise loadSessions() {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            messenger.loadSessions().start(new CommandCallback<List<ApiAuthSession>>() {

                @Override
                public void onResult(List<ApiAuthSession> res) {
                    JsArray<JsAuthSession> jsSessions = JsArray.createArray().cast();
                    for (ApiAuthSession session : res) {
                        jsSessions.push(JsAuthSession.create(session));
                    }
                    resolve(jsSessions);
                }

                @Override
                public void onError(Exception e) {
                    Log.e(TAG, e);
                    reject(e.getMessage());
                }
            });
        }
    });
}
Also used : JsPromiseExecutor(im.actor.runtime.js.utils.JsPromiseExecutor) ApiAuthSession(im.actor.core.api.ApiAuthSession) 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