Search in sources :

Example 6 with WritableNativeArray

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

the class RCTMGLMapView method getCenter.

public void getCenter(String callbackID) {
    LatLng center = mMap.getCameraPosition().target;
    WritableArray array = new WritableNativeArray();
    array.pushDouble(center.getLongitude());
    array.pushDouble(center.getLatitude());
    WritableMap payload = new WritableNativeMap();
    payload.putArray("center", array);
    AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
    mManager.handleEvent(event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) AndroidCallbackEvent(com.mapbox.rctmgl.events.AndroidCallbackEvent)

Example 7 with WritableNativeArray

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

the class RCTMGLMapView method getCoordinateFromView.

public void getCoordinateFromView(String callbackID, PointF pointInView) {
    float density = getDisplayDensity();
    pointInView.x *= density;
    pointInView.y *= density;
    LatLng mapCoordinate = mMap.getProjection().fromScreenLocation(pointInView);
    WritableMap payload = new WritableNativeMap();
    WritableArray array = new WritableNativeArray();
    array.pushDouble(mapCoordinate.getLongitude());
    array.pushDouble(mapCoordinate.getLatitude());
    payload.putArray("coordinateFromView", array);
    AndroidCallbackEvent event = new AndroidCallbackEvent(this, callbackID, payload);
    mManager.handleEvent(event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) AndroidCallbackEvent(com.mapbox.rctmgl.events.AndroidCallbackEvent)

Example 8 with WritableNativeArray

use of com.facebook.react.bridge.WritableNativeArray in project react-native-yamap by volga-volga.

the class YamapView method convertRouteSection.

private WritableMap convertRouteSection(Route route, final Section section, Polyline geometry, Weight routeWeight, int routeIndex) {
    SectionMetadata.SectionData data = section.getMetadata().getData();
    WritableMap routeMetadata = Arguments.createMap();
    WritableMap routeWeightData = Arguments.createMap();
    WritableMap sectionWeightData = Arguments.createMap();
    Map<String, ArrayList<String>> transports = new HashMap<>();
    routeWeightData.putString("time", routeWeight.getTime().getText());
    routeWeightData.putInt("transferCount", routeWeight.getTransfersCount());
    routeWeightData.putDouble("walkingDistance", routeWeight.getWalkingDistance().getValue());
    sectionWeightData.putString("time", section.getMetadata().getWeight().getTime().getText());
    sectionWeightData.putInt("transferCount", section.getMetadata().getWeight().getTransfersCount());
    sectionWeightData.putDouble("walkingDistance", section.getMetadata().getWeight().getWalkingDistance().getValue());
    routeMetadata.putMap("sectionInfo", sectionWeightData);
    routeMetadata.putMap("routeInfo", routeWeightData);
    routeMetadata.putInt("routeIndex", routeIndex);
    final WritableArray stops = new WritableNativeArray();
    for (RouteStop stop : section.getStops()) {
        stops.pushString(stop.getStop().getName());
    }
    routeMetadata.putArray("stops", stops);
    if (data.getTransports() != null) {
        for (Transport transport : data.getTransports()) {
            for (String type : transport.getLine().getVehicleTypes()) {
                if (type.equals("suburban"))
                    continue;
                if (transports.get(type) != null) {
                    ArrayList<String> list = transports.get(type);
                    if (list != null) {
                        list.add(transport.getLine().getName());
                        transports.put(type, list);
                    }
                } else {
                    ArrayList<String> list = new ArrayList<>();
                    list.add(transport.getLine().getName());
                    transports.put(type, list);
                }
                routeMetadata.putString("type", type);
                int color = Color.BLACK;
                if (transportHasStyle(transport)) {
                    try {
                        color = transport.getLine().getStyle().getColor();
                    } catch (Exception ignored) {
                    }
                }
                routeMetadata.putString("sectionColor", formatColor(color));
            }
        }
    } else {
        routeMetadata.putString("sectionColor", formatColor(Color.DKGRAY));
        if (section.getMetadata().getWeight().getWalkingDistance().getValue() == 0) {
            routeMetadata.putString("type", "waiting");
        } else {
            routeMetadata.putString("type", "walk");
        }
    }
    WritableMap wTransports = Arguments.createMap();
    for (Map.Entry<String, ArrayList<String>> entry : transports.entrySet()) {
        wTransports.putArray(entry.getKey(), Arguments.fromList(entry.getValue()));
    }
    routeMetadata.putMap("transports", wTransports);
    Polyline subpolyline = SubpolylineHelper.subpolyline(route.getGeometry(), section.getGeometry());
    List<Point> linePoints = subpolyline.getPoints();
    WritableArray jsonPoints = Arguments.createArray();
    for (Point point : linePoints) {
        WritableMap jsonPoint = Arguments.createMap();
        jsonPoint.putDouble("lat", point.getLatitude());
        jsonPoint.putDouble("lon", point.getLongitude());
        jsonPoints.pushMap(jsonPoint);
    }
    routeMetadata.putArray("points", jsonPoints);
    return routeMetadata;
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) HashMap(java.util.HashMap) WritableArray(com.facebook.react.bridge.WritableArray) ArrayList(java.util.ArrayList) Point(com.yandex.mapkit.geometry.Point) RequestPoint(com.yandex.mapkit.RequestPoint) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) Point(com.yandex.mapkit.geometry.Point) RequestPoint(com.yandex.mapkit.RequestPoint) SectionMetadata(com.yandex.mapkit.transport.masstransit.SectionMetadata) Polyline(com.yandex.mapkit.geometry.Polyline) RouteStop(com.yandex.mapkit.transport.masstransit.RouteStop) Transport(com.yandex.mapkit.transport.masstransit.Transport) Map(java.util.Map) HashMap(java.util.HashMap) WritableMap(com.facebook.react.bridge.WritableMap)

Example 9 with WritableNativeArray

use of com.facebook.react.bridge.WritableNativeArray in project react-native-yamap by volga-volga.

the class YamapView method convertDrivingRouteSection.

private WritableMap convertDrivingRouteSection(DrivingRoute route, final DrivingSection section, int routeIndex) {
    com.yandex.mapkit.directions.driving.Weight routeWeight = route.getMetadata().getWeight();
    WritableMap routeMetadata = Arguments.createMap();
    WritableMap routeWeightData = Arguments.createMap();
    WritableMap sectionWeightData = Arguments.createMap();
    Map<String, ArrayList<String>> transports = new HashMap<>();
    routeWeightData.putString("time", routeWeight.getTime().getText());
    routeWeightData.putString("timeWithTraffic", routeWeight.getTimeWithTraffic().getText());
    routeWeightData.putDouble("distance", routeWeight.getDistance().getValue());
    sectionWeightData.putString("time", section.getMetadata().getWeight().getTime().getText());
    sectionWeightData.putString("timeWithTraffic", section.getMetadata().getWeight().getTimeWithTraffic().getText());
    sectionWeightData.putDouble("distance", section.getMetadata().getWeight().getDistance().getValue());
    routeMetadata.putMap("sectionInfo", sectionWeightData);
    routeMetadata.putMap("routeInfo", routeWeightData);
    routeMetadata.putInt("routeIndex", routeIndex);
    final WritableArray stops = new WritableNativeArray();
    routeMetadata.putArray("stops", stops);
    routeMetadata.putString("sectionColor", formatColor(Color.DKGRAY));
    if (section.getMetadata().getWeight().getDistance().getValue() == 0) {
        routeMetadata.putString("type", "waiting");
    } else {
        routeMetadata.putString("type", "car");
    }
    WritableMap wTransports = Arguments.createMap();
    routeMetadata.putMap("transports", wTransports);
    Polyline subpolyline = SubpolylineHelper.subpolyline(route.getGeometry(), section.getGeometry());
    List<Point> linePoints = subpolyline.getPoints();
    WritableArray jsonPoints = Arguments.createArray();
    for (Point point : linePoints) {
        WritableMap jsonPoint = Arguments.createMap();
        jsonPoint.putDouble("lat", point.getLatitude());
        jsonPoint.putDouble("lon", point.getLongitude());
        jsonPoints.pushMap(jsonPoint);
    }
    routeMetadata.putArray("points", jsonPoints);
    return routeMetadata;
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) HashMap(java.util.HashMap) WritableArray(com.facebook.react.bridge.WritableArray) ArrayList(java.util.ArrayList) Point(com.yandex.mapkit.geometry.Point) RequestPoint(com.yandex.mapkit.RequestPoint) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) Polyline(com.yandex.mapkit.geometry.Polyline)

Example 10 with WritableNativeArray

use of com.facebook.react.bridge.WritableNativeArray in project aurora-imui by jpush.

the class ReactChatInputManager method createViewInstance.

@Override
protected ChatInputView createViewInstance(final ThemedReactContext reactContext) {
    mContext = reactContext;
    final SharedPreferences sp = reactContext.getSharedPreferences(AURORA_IMUI_SHARED_PREFERENCES, Context.MODE_PRIVATE);
    mSoftKeyboardHeight = sp.getInt(SOFT_KEYBOARD_HEIGHT, 0);
    if (!EventBus.getDefault().isRegistered(this)) {
        EventBus.getDefault().register(this);
    }
    final Activity activity = reactContext.getCurrentActivity();
    mChatInput = new ChatInputView(activity, null);
    final EditText editText = mChatInput.getInputView();
    editText.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), ON_TOUCH_EDIT_TEXT_EVENT, null);
                if (!mChatInput.isFocused()) {
                    EmoticonsKeyboardUtils.openSoftKeyboard(mChatInput.getInputView());
                }
                EventBus.getDefault().post(new ScrollEvent(true));
                int height = mChatInput.getSoftKeyboardHeight();
                if (mSoftKeyboardHeight != height && height != 0 && height < 1000) {
                    mSoftKeyboardHeight = mChatInput.getSoftKeyboardHeight();
                    SharedPreferences.Editor editor = sp.edit();
                    editor.putInt(SOFT_KEYBOARD_HEIGHT, mSoftKeyboardHeight);
                    editor.commit();
                }
            }
            return false;
        }
    });
    editText.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            editText.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            mWidth = editText.getWidth();
        }
    });
    DisplayMetrics dm = new DisplayMetrics();
    reactContext.getCurrentActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
    mDensity = dm.density;
    mScreenWidth = dm.widthPixels;
    mMenuContainerHeight = (int) (mMenuContainerHeight / mDensity);
    editText.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            WritableMap event = Arguments.createMap();
            double layoutHeight = calculateMenuHeight();
            mInitState = false;
            event.putDouble("height", layoutHeight);
            editText.setLayoutParams(new LinearLayout.LayoutParams(editText.getWidth(), (int) (mCurrentInputHeight)));
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), ON_INPUT_SIZE_CHANGED_EVENT, event);
        }
    });
    // Use default layout
    mChatInput.setMenuClickListener(new OnMenuClickListener() {

        @Override
        public boolean onSendTextMessage(CharSequence input) {
            if (input.length() == 0) {
                return false;
            }
            // WritableMap map = Arguments.createMap();
            // map.putDouble("height", mInitialChatInputHeight);
            // reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), ON_INPUT_SIZE_CHANGED_EVENT, map);
            WritableMap event = Arguments.createMap();
            event.putString("text", input.toString());
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), ON_SEND_TEXT_EVENT, event);
            return true;
        }

        @Override
        public void onSendFiles(List<FileItem> list) {
            if (list == null || list.isEmpty()) {
                return;
            }
            WritableMap event = Arguments.createMap();
            WritableArray array = new WritableNativeArray();
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            for (FileItem fileItem : list) {
                WritableMap map = new WritableNativeMap();
                if (fileItem.getType().ordinal() == 0) {
                    map.putString("mediaType", "image");
                    BitmapFactory.decodeFile(fileItem.getFilePath(), options);
                    map.putInt("width", options.outWidth);
                    map.putInt("height", options.outHeight);
                } else {
                    map.putString("mediaType", "video");
                    map.putInt("duration", (int) ((VideoItem) fileItem).getDuration());
                }
                map.putDouble("size", fileItem.getLongFileSize());
                map.putString("mediaPath", fileItem.getFilePath());
                array.pushMap(map);
            }
            event.putArray("mediaFiles", array);
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), ON_SEND_FILES_EVENT, event);
        }

        @Override
        public boolean switchToMicrophoneMode() {
            String[] perms = new String[] { Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE };
            if (!EasyPermissions.hasPermissions(activity, perms)) {
                EasyPermissions.requestPermissions(activity, activity.getResources().getString(R.string.rationale_record_voice), RC_RECORD_VOICE, perms);
            }
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), SWITCH_TO_MIC_EVENT, null);
            // If menu is visible, close menu.
            if (mLastClickId == 0 && mShowMenu) {
                mShowMenu = false;
                mChatInput.dismissMenuLayout();
                mChatInput.dismissRecordVoiceLayout();
                sendSizeChangedEvent(mInitialChatInputHeight + mLineExpend);
            } else if (mShowMenu) {
                mChatInput.showMenuLayout();
                mChatInput.showRecordVoiceLayout();
                mChatInput.requestLayout();
            } else {
                mShowMenu = true;
                // mChatInput.setPendingShowMenu(true);
                EmoticonsKeyboardUtils.closeSoftKeyboard(editText);
                sendSizeChangedEvent(calculateMenuHeight());
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        mChatInput.showMenuLayout();
                        mChatInput.showRecordVoiceLayout();
                        mChatInput.requestLayout();
                    }
                }, 150);
            }
            mLastClickId = 0;
            return false;
        }

        @Override
        public boolean switchToGalleryMode() {
            String[] perms = new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE };
            if (!EasyPermissions.hasPermissions(activity, perms)) {
                EasyPermissions.requestPermissions(activity, activity.getResources().getString(R.string.rationale_photo), RC_SELECT_PHOTO, perms);
                return false;
            }
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), SWITCH_TO_GALLERY_EVENT, null);
            if (mLastClickId == 1 && mShowMenu) {
                mShowMenu = false;
                mChatInput.dismissMenuLayout();
                mChatInput.dismissPhotoLayout();
                sendSizeChangedEvent(mInitialChatInputHeight + mLineExpend);
            } else if (mShowMenu) {
                mChatInput.getSelectPhotoView().updateData();
                mChatInput.showMenuLayout();
                mChatInput.showSelectPhotoLayout();
                mChatInput.requestLayout();
            } else {
                mChatInput.getSelectPhotoView().updateData();
                mShowMenu = true;
                // mChatInput.setPendingShowMenu(true);
                EmoticonsKeyboardUtils.closeSoftKeyboard(editText);
                sendSizeChangedEvent(calculateMenuHeight());
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        mChatInput.showMenuLayout();
                        mChatInput.showSelectPhotoLayout();
                        mChatInput.requestLayout();
                    }
                }, 150);
            }
            mLastClickId = 1;
            return false;
        }

        @Override
        public boolean switchToCameraMode() {
            String[] perms = new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO };
            if (!EasyPermissions.hasPermissions(activity, perms)) {
                EasyPermissions.requestPermissions(activity, activity.getResources().getString(R.string.rationale_camera), RC_CAMERA, perms);
                return false;
            }
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), SWITCH_TO_CAMERA_EVENT, null);
            if (mLastClickId == 2 && mShowMenu) {
                mShowMenu = false;
                mChatInput.dismissMenuLayout();
                mChatInput.dismissCameraLayout();
                sendSizeChangedEvent(mInitialChatInputHeight + mLineExpend);
            } else if (mShowMenu) {
                mChatInput.initCamera();
                mChatInput.showMenuLayout();
                mChatInput.showCameraLayout();
                mChatInput.requestLayout();
            } else {
                mShowMenu = true;
                // mChatInput.setPendingShowMenu(true);
                mChatInput.initCamera();
                EmoticonsKeyboardUtils.closeSoftKeyboard(editText);
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        mChatInput.showMenuLayout();
                        mChatInput.showCameraLayout();
                        sendSizeChangedEvent(calculateMenuHeight());
                        mChatInput.requestLayout();
                    }
                }, 100);
            }
            mLastClickId = 2;
            return false;
        }

        @Override
        public boolean switchToEmojiMode() {
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), SWITCH_TO_EMOJI_EVENT, null);
            if (mLastClickId == 3 && mShowMenu) {
                mShowMenu = false;
                mChatInput.dismissMenuLayout();
                mChatInput.dismissEmojiLayout();
                sendSizeChangedEvent(mInitialChatInputHeight + mLineExpend);
            } else if (mShowMenu) {
                mChatInput.showMenuLayout();
                mChatInput.showEmojiLayout();
                mChatInput.requestLayout();
            } else {
                mShowMenu = true;
                // mChatInput.setPendingShowMenu(true);
                EmoticonsKeyboardUtils.closeSoftKeyboard(editText);
                sendSizeChangedEvent(calculateMenuHeight());
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        mChatInput.showMenuLayout();
                        mChatInput.showEmojiLayout();
                        mChatInput.requestLayout();
                    }
                }, 150);
            }
            mLastClickId = 3;
            return false;
        }
    });
    mChatInput.setOnCameraCallbackListener(new OnCameraCallbackListener() {

        @Override
        public void onTakePictureCompleted(String photoPath) {
            if (mLastPhotoPath.equals(photoPath)) {
                return;
            }
            mLastPhotoPath = photoPath;
            mContext.runOnUiQueueThread(new Runnable() {

                @Override
                public void run() {
                    if (mChatInput.isFullScreen()) {
                        mChatInput.dismissCameraLayout();
                    }
                    mChatInput.dismissMenuLayout();
                }
            });
            WritableMap event = Arguments.createMap();
            event.putString("mediaPath", photoPath);
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeFile(photoPath, options);
            event.putInt("width", options.outWidth);
            event.putInt("height", options.outHeight);
            File file = new File(photoPath);
            event.putDouble("size", file.length());
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), TAKE_PICTURE_EVENT, event);
        }

        @Override
        public void onStartVideoRecord() {
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), START_RECORD_VIDEO_EVENT, null);
        }

        @Override
        public void onFinishVideoRecord(String videoPath) {
            if (videoPath != null) {
                WritableMap event = Arguments.createMap();
                event.putString("mediaPath", videoPath);
                MediaPlayer mediaPlayer = MediaPlayer.create(reactContext, Uri.parse(videoPath));
                // Millisecond to second.
                int duration = mediaPlayer.getDuration() / 1000;
                mediaPlayer.release();
                File file = new File(videoPath);
                event.putDouble("size", file.length());
                event.putInt("duration", duration);
                reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), FINISH_RECORD_VIDEO_EVENT, event);
            }
        }

        @Override
        public void onCancelVideoRecord() {
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), CANCEL_RECORD_VIDEO_EVENT, null);
        }
    });
    mChatInput.setRecordVoiceListener(new RecordVoiceListener() {

        @Override
        public void onStartRecord() {
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), START_RECORD_VOICE_EVENT, null);
            File rootDir = reactContext.getFilesDir();
            String fileDir = rootDir.getAbsolutePath() + "/voice";
            mChatInput.getRecordVoiceButton().setVoiceFilePath(fileDir, DateFormat.format("yyyy_MMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + "");
        }

        @Override
        public void onFinishRecord(File voiceFile, int duration) {
            WritableMap event = Arguments.createMap();
            event.putString("mediaPath", voiceFile.getAbsolutePath());
            event.putInt("duration", duration);
            event.putDouble("size", voiceFile.length());
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), FINISH_RECORD_VOICE_EVENT, event);
        }

        @Override
        public void onCancelRecord() {
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), CANCEL_RECORD_VOICE_EVENT, null);
        }

        @Override
        public void onPreviewCancel() {
        }

        @Override
        public void onPreviewSend() {
            sendSizeChangedEvent(mInitialChatInputHeight + mLineExpend);
        }
    });
    mChatInput.setCameraControllerListener(new CameraControllerListener() {

        @Override
        public void onFullScreenClick() {
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), ON_FULL_SCREEN_EVENT, null);
        }

        @Override
        public void onRecoverScreenClick() {
            mShowMenu = false;
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), ON_RECOVER_SCREEN_EVENT, null);
            WritableMap map = Arguments.createMap();
            Log.e(REACT_CHAT_INPUT, "send onSizeChangedEvent to js, height: " + mInitialChatInputHeight + mLineExpend);
            map.putDouble("height", mInitialChatInputHeight + mLineExpend);
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), ON_INPUT_SIZE_CHANGED_EVENT, map);
        }

        @Override
        public void onCloseCameraClick() {
            mShowMenu = false;
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), CLOSE_CAMERA_EVENT, null);
        }

        @Override
        public void onSwitchCameraModeClick(boolean isRecordVideoMode) {
            WritableMap map = Arguments.createMap();
            map.putBoolean("isRecordVideoMode", isRecordVideoMode);
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), SWITCH_CAMERA_MODE_EVENT, map);
        }
    });
    mChatInput.getSelectAlbumBtn().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(mChatInput.getId(), ON_CLICK_SELECT_ALBUM_EVENT, null);
        }
    });
    mChatInput.getEmojiContainer().getEmoticonsFuncView().addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            Log.e(REACT_CHAT_INPUT, "EmotionPage Position" + position);
            mChatInput.requestLayout();
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    return mChatInput;
}
Also used : CameraControllerListener(cn.jiguang.imui.chatinput.listener.CameraControllerListener) WritableNativeMap(com.facebook.react.bridge.WritableNativeMap) Activity(android.app.Activity) DisplayMetrics(android.util.DisplayMetrics) WritableNativeArray(com.facebook.react.bridge.WritableNativeArray) OnMenuClickListener(cn.jiguang.imui.chatinput.listener.OnMenuClickListener) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) BitmapFactory(android.graphics.BitmapFactory) ViewTreeObserver(android.view.ViewTreeObserver) EditText(android.widget.EditText) OnCameraCallbackListener(cn.jiguang.imui.chatinput.listener.OnCameraCallbackListener) ChatInputView(cn.jiguang.imui.chatinput.ChatInputView) WritableMap(com.facebook.react.bridge.WritableMap) SharedPreferences(android.content.SharedPreferences) WritableArray(com.facebook.react.bridge.WritableArray) Handler(android.os.Handler) RecordVoiceListener(cn.jiguang.imui.chatinput.listener.RecordVoiceListener) ChatInputView(cn.jiguang.imui.chatinput.ChatInputView) View(android.view.View) ViewPager(android.support.v4.view.ViewPager) MotionEvent(android.view.MotionEvent) FileItem(cn.jiguang.imui.chatinput.model.FileItem) ScrollEvent(cn.jiguang.imui.messagelist.event.ScrollEvent) File(java.io.File) MediaPlayer(android.media.MediaPlayer)

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