Search in sources :

Example 11 with WritableArray

use of com.facebook.react.bridge.WritableArray in project stringee-react-native by stringeecom.

the class RNStringeeClientModule method getAllMessagesAfter.

@ReactMethod
public void getAllMessagesAfter(final String instanceId, final String convId, final int sequence, final int count, final boolean loadDeletedMsg, final boolean loadDeletedMsgContent, final Callback callback) {
    StringeeClient mClient = StringeeManager.getInstance().getClientsMap().get(instanceId);
    if (mClient == null) {
        callback.invoke(false, -1, "StringeeClient is not initialized");
        return;
    }
    if (convId == null) {
        callback.invoke(false, -2, "Conversation id can not be null");
        return;
    }
    mClient.getConversationFromServer(convId, new CallbackListener<Conversation>() {

        @Override
        public void onSuccess(Conversation conversation) {
            conversation.getMessagesAfter(mClient, sequence, count, loadDeletedMsg, loadDeletedMsgContent, true, new CallbackListener<List<Message>>() {

                @Override
                public void onSuccess(List<Message> messages) {
                    WritableArray params = Arguments.createArray();
                    for (int i = 0; i < messages.size(); i++) {
                        WritableMap param = Utils.getMessageMap(messages.get(i));
                        params.pushMap(param);
                    }
                    callback.invoke(true, 0, "Success", params);
                }

                @Override
                public void onError(StringeeError error) {
                    callback.invoke(false, error.getCode(), error.getMessage());
                }
            });
        }

        @Override
        public void onError(StringeeError error) {
            callback.invoke(false, error.getCode(), error.getMessage());
        }
    });
}
Also used : CallbackListener(com.stringee.messaging.listeners.CallbackListener) WritableMap(com.facebook.react.bridge.WritableMap) Message(com.stringee.messaging.Message) WritableArray(com.facebook.react.bridge.WritableArray) StringeeError(com.stringee.exception.StringeeError) StringeeClient(com.stringee.StringeeClient) Conversation(com.stringee.messaging.Conversation) ArrayList(java.util.ArrayList) List(java.util.List) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 12 with WritableArray

use of com.facebook.react.bridge.WritableArray in project stringee-react-native by stringeecom.

the class RNStringeeClientModule method getUnreadConversationsBefore.

@ReactMethod
public void getUnreadConversationsBefore(final String instanceId, final double datetime, final int count, final Callback callback) {
    StringeeClient mClient = StringeeManager.getInstance().getClientsMap().get(instanceId);
    if (mClient == null) {
        callback.invoke(false, -1, "StringeeClient is not initialized");
        return;
    }
    mClient.getUnreadConversationsBefore((long) datetime, count, new CallbackListener<List<Conversation>>() {

        @Override
        public void onSuccess(List<Conversation> conversations) {
            WritableArray params = Arguments.createArray();
            for (int i = 0; i < conversations.size(); i++) {
                WritableMap param = Utils.getConversationMap(conversations.get(i));
                params.pushMap(param);
            }
            callback.invoke(true, 0, "Success", params);
        }

        @Override
        public void onError(StringeeError error) {
            callback.invoke(false, error.getCode(), error.getMessage());
        }
    });
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) StringeeError(com.stringee.exception.StringeeError) StringeeClient(com.stringee.StringeeClient) ArrayList(java.util.ArrayList) List(java.util.List) Conversation(com.stringee.messaging.Conversation) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 13 with WritableArray

use of com.facebook.react.bridge.WritableArray in project stringee-react-native by stringeecom.

the class RNStringeeClientModule method getAllConversationsBefore.

@ReactMethod
public void getAllConversationsBefore(final String instanceId, final double datetime, final int count, final Callback callback) {
    StringeeClient mClient = StringeeManager.getInstance().getClientsMap().get(instanceId);
    if (mClient == null) {
        callback.invoke(false, -1, "StringeeClient is not initialized");
        return;
    }
    mClient.getConversationsBefore((long) datetime, count, true, new CallbackListener<List<Conversation>>() {

        @Override
        public void onSuccess(List<Conversation> conversations) {
            WritableArray params = Arguments.createArray();
            for (int i = 0; i < conversations.size(); i++) {
                WritableMap param = Utils.getConversationMap(conversations.get(i));
                params.pushMap(param);
            }
            callback.invoke(true, 0, "Success", params);
        }

        @Override
        public void onError(StringeeError error) {
            callback.invoke(false, error.getCode(), error.getMessage());
        }
    });
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) StringeeError(com.stringee.exception.StringeeError) StringeeClient(com.stringee.StringeeClient) ArrayList(java.util.ArrayList) List(java.util.List) Conversation(com.stringee.messaging.Conversation) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 14 with WritableArray

use of com.facebook.react.bridge.WritableArray in project stringee-react-native by stringeecom.

the class RNStringeeClientModule method removeParticipants.

@ReactMethod
public void removeParticipants(final String instanceId, final String convId, final ReadableArray usersArray, final Callback callback) {
    StringeeClient mClient = StringeeManager.getInstance().getClientsMap().get(instanceId);
    if (mClient == null) {
        callback.invoke(false, -1, "StringeeClient is not initialized");
        return;
    }
    if (convId == null) {
        callback.invoke(false, -2, "Conversation id can not be null");
        return;
    }
    mClient.getConversationFromServer(convId, new CallbackListener<Conversation>() {

        @Override
        public void onSuccess(Conversation conversation) {
            List<User> users = new ArrayList<>();
            for (int i = 0; i < usersArray.size(); i++) {
                User user = new User(usersArray.getString(i));
                users.add(user);
            }
            conversation.removeParticipants(mClient, users, new CallbackListener<List<User>>() {

                @Override
                public void onSuccess(List<User> users) {
                    WritableArray params = Arguments.createArray();
                    for (int i = 0; i < users.size(); i++) {
                        WritableMap param = Utils.getUserMap(users.get(i));
                        params.pushMap(param);
                    }
                    callback.invoke(true, 0, "Success", params);
                }

                @Override
                public void onError(StringeeError error) {
                    callback.invoke(false, error.getCode(), error.getMessage());
                }
            });
        }

        @Override
        public void onError(StringeeError error) {
            callback.invoke(false, error.getCode(), error.getMessage());
        }
    });
}
Also used : CallbackListener(com.stringee.messaging.listeners.CallbackListener) User(com.stringee.messaging.User) WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) StringeeError(com.stringee.exception.StringeeError) StringeeClient(com.stringee.StringeeClient) Conversation(com.stringee.messaging.Conversation) ArrayList(java.util.ArrayList) List(java.util.List) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 15 with WritableArray

use of com.facebook.react.bridge.WritableArray in project react-native-carbon by qlik-oss.

the class SelectionsEngine method signal.

public void signal(View contextView) {
    Integer[] selected = currentSelections.toArray(new Integer[0]);
    WritableArray selectedArray = Arguments.createArray();
    for (int i = 0; i < selected.length; i++) {
        selectedArray.pushInt(selected[i]);
    }
    WritableMap event = Arguments.createMap();
    event.putArray("selections", selectedArray);
    EventUtils.sendEventToJSFromView(contextView, "onSelection", event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray)

Aggregations

WritableArray (com.facebook.react.bridge.WritableArray)144 WritableMap (com.facebook.react.bridge.WritableMap)121 ReactMethod (com.facebook.react.bridge.ReactMethod)41 ArrayList (java.util.ArrayList)38 List (java.util.List)25 WritableNativeMap (com.facebook.react.bridge.WritableNativeMap)20 StringeeClient (com.stringee.StringeeClient)20 StringeeError (com.stringee.exception.StringeeError)20 Conversation (com.stringee.messaging.Conversation)20 WritableNativeArray (com.facebook.react.bridge.WritableNativeArray)18 Text (com.google.mlkit.vision.text.Text)10 ReadableMap (com.facebook.react.bridge.ReadableMap)9 CallbackListener (com.stringee.messaging.listeners.CallbackListener)9 JSONException (org.json.JSONException)8 SuppressLint (android.annotation.SuppressLint)7 Bundle (android.os.Bundle)7 Handler (android.os.Handler)7 Nullable (androidx.annotation.Nullable)7 Face (com.google.mlkit.vision.face.Face)7 Message (com.stringee.messaging.Message)7