Search in sources :

Example 6 with CommandCallback

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

the class JsFacade method findUsers.

@UsedByApp
public JsPromise findUsers(final String query) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            messenger.findUsers(query).start(new CommandCallback<UserVM[]>() {

                @Override
                public void onResult(UserVM[] users) {
                    Log.d(TAG, "findUsers:result");
                    JsArray<JsUser> jsUsers = JsArray.createArray().cast();
                    for (UserVM user : users) {
                        jsUsers.push(messenger.getJsUser(user.getId()).get());
                    }
                    resolve(jsUsers);
                }

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

Example 7 with CommandCallback

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

the class JsFacade method archiveChat.

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

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

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

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

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

the class JsFacade method terminateSession.

@UsedByApp
public JsPromise terminateSession(final int id) {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            messenger.terminateSession(id).start(new CommandCallback<Void>() {

                @Override
                public void onResult(Void res) {
                    resolve();
                }

                @Override
                public void onError(Exception e) {
                    Log.e(TAG, e);
                    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 9 with CommandCallback

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

the class JsFacade method getInviteLink.

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

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

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

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

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

the class JsFacade method terminateAllSessions.

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

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

                @Override
                public void onResult(Void res) {
                    resolve();
                }

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