Search in sources :

Example 1 with WritableNativeArray

use of com.facebook.react.bridge.WritableNativeArray in project SalesIQ-Mobilisten-ReactNative by zoho.

the class RNZohoSalesIQ method getArticles.

@ReactMethod
public void getArticles(@NonNull final Callback articlesCallback) {
    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {

        public void run() {
            ZohoSalesIQ.FAQ.getArticles(new FAQListener() {

                @Override
                public void onSuccess(ArrayList<SalesIQArticle> articlesList) {
                    if (articlesList != null) {
                        WritableArray array = new WritableNativeArray();
                        for (int i = 0; i < articlesList.size(); i++) {
                            SalesIQArticle article = articlesList.get(i);
                            WritableMap articleMap = getArticleMapObject(article);
                            array.pushMap(articleMap);
                        }
                        articlesCallback.invoke(null, array);
                    }
                }

                @Override
                public void onFailure(int code, String message) {
                    WritableMap errorMap = new WritableNativeMap();
                    // No I18N
                    errorMap.putInt("code", code);
                    // No I18N
                    errorMap.putString("message", message);
                    articlesCallback.invoke(errorMap, null);
                }
            });
        }
    });
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) FAQListener(com.zoho.livechat.android.listeners.FAQListener) SalesIQFAQListener(com.zoho.livechat.android.listeners.SalesIQFAQListener) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) ArrayList(java.util.ArrayList) Handler(android.os.Handler) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) SalesIQArticle(com.zoho.livechat.android.models.SalesIQArticle) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 2 with WritableNativeArray

use of com.facebook.react.bridge.WritableNativeArray in project SalesIQ-Mobilisten-ReactNative by zoho.

the class RNZohoSalesIQ method getChatsWithFilter.

@ReactMethod
public void getChatsWithFilter(@NonNull final String filter, @NonNull final Callback listCallback) {
    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {

        public void run() {
            try {
                if (isValidFilterName(filter)) {
                    ConversationType filterName = getFilterName(filter);
                    ZohoSalesIQ.Chat.getList(filterName, new ConversationListener() {

                        @Override
                        public void onSuccess(ArrayList<VisitorChat> arrayList) {
                            if (arrayList != null) {
                                WritableArray array = new WritableNativeArray();
                                for (int i = 0; i < arrayList.size(); i++) {
                                    VisitorChat chat = arrayList.get(i);
                                    WritableMap visitorMap = getChatMapObject(chat);
                                    array.pushMap(visitorMap);
                                }
                                listCallback.invoke(null, array);
                            }
                        }

                        @Override
                        public void onFailure(int code, String message) {
                            WritableMap errorMap = new WritableNativeMap();
                            // No I18N
                            errorMap.putInt("code", code);
                            // No I18N
                            errorMap.putString("message", message);
                            listCallback.invoke(errorMap, null);
                        }
                    });
                } else {
                    WritableMap errorMap = new WritableNativeMap();
                    // No I18N
                    errorMap.putInt("code", INVALID_FILTER_CODE);
                    // No I18N
                    errorMap.putString("message", INVALID_FILTER_TYPE);
                    listCallback.invoke(errorMap, null);
                }
            } catch (Exception e) {
                LiveChatUtil.log(e);
            }
        }
    });
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) ArrayList(java.util.ArrayList) Handler(android.os.Handler) VisitorChat(com.zoho.livechat.android.VisitorChat) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) InvalidEmailException(com.zoho.livechat.android.exception.InvalidEmailException) InvalidVisitorIDException(com.zoho.livechat.android.exception.InvalidVisitorIDException) ConversationType(com.zoho.livechat.android.constants.ConversationType) ConversationListener(com.zoho.livechat.android.listeners.ConversationListener) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 3 with WritableNativeArray

use of com.facebook.react.bridge.WritableNativeArray in project SalesIQ-Mobilisten-ReactNative by zoho.

the class RNZohoSalesIQ method getChats.

@ReactMethod
public void getChats(@NonNull final Callback listCallback) {
    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {

        public void run() {
            ZohoSalesIQ.Chat.getList(new ConversationListener() {

                @Override
                public void onSuccess(ArrayList<VisitorChat> arrayList) {
                    if (arrayList != null) {
                        WritableArray array = new WritableNativeArray();
                        for (int i = 0; i < arrayList.size(); i++) {
                            VisitorChat chat = arrayList.get(i);
                            WritableMap visitorMap = getChatMapObject(chat);
                            array.pushMap(visitorMap);
                        }
                        listCallback.invoke(null, array);
                    }
                }

                @Override
                public void onFailure(int code, String message) {
                    WritableMap errorMap = new WritableNativeMap();
                    // No I18N
                    errorMap.putInt("code", code);
                    // No I18N
                    errorMap.putString("message", message);
                    listCallback.invoke(errorMap, null);
                }
            });
        }
    });
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) ConversationListener(com.zoho.livechat.android.listeners.ConversationListener) WritableArray(com.facebook.react.bridge.WritableArray) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) ArrayList(java.util.ArrayList) Handler(android.os.Handler) VisitorChat(com.zoho.livechat.android.VisitorChat) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 4 with WritableNativeArray

use of com.facebook.react.bridge.WritableNativeArray in project react-native-callkeep by react-native-webrtc.

the class RNCallKeepModule method startObserving.

public void startObserving() {
    int count = delayedEvents.size();
    Log.d(TAG, "[RNCallKeepModule] startObserving, event count: " + count);
    if (count > 0) {
        this.reactContext.getJSModule(RCTDeviceEventEmitter.class).emit("RNCallKeepDidLoadWithEvents", delayedEvents);
        delayedEvents = new WritableNativeArray();
    }
}
Also used : RCTDeviceEventEmitter(com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray)

Example 5 with WritableNativeArray

use of com.facebook.react.bridge.WritableNativeArray in project maps by rnmapbox.

the class GeoJSONUtils method fromLatLng.

public static WritableArray fromLatLng(LatLng latLng) {
    double[] coords = new double[] { latLng.getLongitude(), latLng.getLatitude() };
    WritableArray writableCoords = new WritableNativeArray();
    writableCoords.pushDouble(coords[0]);
    writableCoords.pushDouble(coords[1]);
    return writableCoords;
}
Also used : WritableArray(com.facebook.react.bridge.WritableArray) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray)

Aggregations

WritableNativeArray (com.facebook.react.bridge.WritableNativeArray)19 WritableArray (com.facebook.react.bridge.WritableArray)18 WritableMap (com.facebook.react.bridge.WritableMap)17 WritableNativeMap (com.facebook.react.bridge.WritableNativeMap)14 ArrayList (java.util.ArrayList)10 Handler (android.os.Handler)7 ReactMethod (com.facebook.react.bridge.ReactMethod)7 AndroidCallbackEvent (com.mapbox.rctmgl.events.AndroidCallbackEvent)3 BluetoothDevice (android.bluetooth.BluetoothDevice)2 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)2 RequestPoint (com.yandex.mapkit.RequestPoint)2 Point (com.yandex.mapkit.geometry.Point)2 Polyline (com.yandex.mapkit.geometry.Polyline)2 VisitorChat (com.zoho.livechat.android.VisitorChat)2 ConversationListener (com.zoho.livechat.android.listeners.ConversationListener)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Activity (android.app.Activity)1 BluetoothClass (android.bluetooth.BluetoothClass)1 SharedPreferences (android.content.SharedPreferences)1