Search in sources :

Example 31 with CommandCallback

use of im.actor.core.viewmodel.CommandCallback 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 32 with CommandCallback

use of im.actor.core.viewmodel.CommandCallback 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 33 with CommandCallback

use of im.actor.core.viewmodel.CommandCallback 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)

Example 34 with CommandCallback

use of im.actor.core.viewmodel.CommandCallback in project actor-platform by actorapp.

the class JsFacade method kickMember.

@UsedByApp
public JsPromise kickMember(final int gid, final int uid) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            //noinspection ConstantConditions
            messenger.kickMember(gid, uid).start(new CommandCallback<Void>() {

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

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

use of im.actor.core.viewmodel.CommandCallback in project actor-platform by actorapp.

the class JsFacade method favoriteChat.

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

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

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

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

Aggregations

CommandCallback (im.actor.core.viewmodel.CommandCallback)37 UsedByApp (im.actor.core.js.annotations.UsedByApp)28 RpcException (im.actor.core.network.RpcException)28 JsPromiseExecutor (im.actor.runtime.js.utils.JsPromiseExecutor)28 Void (im.actor.runtime.actors.messages.Void)13 UserVM (im.actor.core.viewmodel.UserVM)8 ArrayList (java.util.ArrayList)8 View (android.view.View)7 TextView (android.widget.TextView)7 List (java.util.List)7 AlertDialog (android.app.AlertDialog)5 Intent (android.content.Intent)4 GroupVM (im.actor.core.viewmodel.GroupVM)4 DialogInterface (android.content.DialogInterface)3 ViewGroup (android.view.ViewGroup)3 Toast (android.widget.Toast)3 MessageSearchEntity (im.actor.core.entity.MessageSearchEntity)3 ActorSDK (im.actor.sdk.ActorSDK)3 R (im.actor.sdk.R)3 ActorSDKMessenger.messenger (im.actor.sdk.util.ActorSDKMessenger.messenger)3