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());
}
});
}
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());
}
});
}
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());
}
});
}
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());
}
});
}
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);
}
Aggregations