Search in sources :

Example 1 with OnCameraCallbackListener

use of cn.jiguang.imui.chatinput.listener.OnCameraCallbackListener 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)

Example 2 with OnCameraCallbackListener

use of cn.jiguang.imui.chatinput.listener.OnCameraCallbackListener in project aurora-imui by jpush.

the class MessageListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_chat);
    this.mImm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mWindow = getWindow();
    registerProximitySensorListener();
    mChatView = (ChatView) findViewById(R.id.chat_view);
    mChatView.initModule();
    mChatView.setTitle("Deadpool");
    mData = getMessages();
    initMsgAdapter();
    mReceiver = new HeadsetDetectReceiver();
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_HEADSET_PLUG);
    registerReceiver(mReceiver, intentFilter);
    mChatView.setOnTouchListener(this);
    mChatView.setMenuClickListener(new OnMenuClickListener() {

        @Override
        public boolean onSendTextMessage(CharSequence input) {
            if (input.length() == 0) {
                return false;
            }
            MyMessage message = new MyMessage(input.toString(), IMessage.MessageType.SEND_TEXT.ordinal());
            message.setUserInfo(new DefaultUser("1", "Ironman", "R.drawable.ironman"));
            message.setTimeString(new SimpleDateFormat("HH:mm", Locale.getDefault()).format(new Date()));
            message.setMessageStatus(IMessage.MessageStatus.SEND_GOING);
            mAdapter.addToStart(message, true);
            return true;
        }

        @Override
        public void onSendFiles(List<FileItem> list) {
            if (list == null || list.isEmpty()) {
                return;
            }
            // should reset messageList height
            mChatView.setMsgListHeight(true);
            MyMessage message;
            for (FileItem item : list) {
                if (item.getType() == FileItem.Type.Image) {
                    message = new MyMessage(null, IMessage.MessageType.SEND_IMAGE.ordinal());
                    mPathList.add(item.getFilePath());
                    mMsgIdList.add(message.getMsgId());
                } else if (item.getType() == FileItem.Type.Video) {
                    message = new MyMessage(null, IMessage.MessageType.SEND_VIDEO.ordinal());
                    message.setDuration(((VideoItem) item).getDuration());
                } else {
                    throw new RuntimeException("Invalid FileItem type. Must be Type.Image or Type.Video");
                }
                message.setTimeString(new SimpleDateFormat("HH:mm", Locale.getDefault()).format(new Date()));
                message.setMediaFilePath(item.getFilePath());
                message.setUserInfo(new DefaultUser("1", "Ironman", "R.drawable.ironman"));
                final MyMessage fMsg = message;
                MessageListActivity.this.runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        mAdapter.addToStart(fMsg, true);
                    }
                });
            }
        }

        @Override
        public boolean switchToMicrophoneMode() {
            scrollToBottom();
            String[] perms = new String[] { Manifest.permission.RECORD_AUDIO, Manifest.permission.WRITE_EXTERNAL_STORAGE };
            if (!EasyPermissions.hasPermissions(MessageListActivity.this, perms)) {
                EasyPermissions.requestPermissions(MessageListActivity.this, getResources().getString(R.string.rationale_record_voice), RC_RECORD_VOICE, perms);
            }
            return true;
        }

        @Override
        public boolean switchToGalleryMode() {
            scrollToBottom();
            String[] perms = new String[] { Manifest.permission.READ_EXTERNAL_STORAGE };
            if (!EasyPermissions.hasPermissions(MessageListActivity.this, perms)) {
                EasyPermissions.requestPermissions(MessageListActivity.this, getResources().getString(R.string.rationale_photo), RC_PHOTO, perms);
            }
            // If you call updateData, select photo view will try to update data(Last update over 30 seconds.)
            mChatView.getChatInputView().getSelectPhotoView().updateData();
            return true;
        }

        @Override
        public boolean switchToCameraMode() {
            scrollToBottom();
            String[] perms = new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO };
            if (!EasyPermissions.hasPermissions(MessageListActivity.this, perms)) {
                EasyPermissions.requestPermissions(MessageListActivity.this, getResources().getString(R.string.rationale_camera), RC_CAMERA, perms);
                return false;
            } else {
                File rootDir = getFilesDir();
                String fileDir = rootDir.getAbsolutePath() + "/photo";
                mChatView.setCameraCaptureFile(fileDir, new SimpleDateFormat("yyyy-MM-dd-hhmmss", Locale.getDefault()).format(new Date()));
            }
            return true;
        }

        @Override
        public boolean switchToEmojiMode() {
            scrollToBottom();
            return true;
        }
    });
    mChatView.setRecordVoiceListener(new RecordVoiceListener() {

        @Override
        public void onStartRecord() {
            // set voice file path, after recording, audio file will save here
            String path = Environment.getExternalStorageDirectory().getPath() + "/voice";
            File destDir = new File(path);
            if (!destDir.exists()) {
                destDir.mkdirs();
            }
            mChatView.setRecordVoiceFile(destDir.getPath(), DateFormat.format("yyyy-MM-dd-hhmmss", Calendar.getInstance(Locale.CHINA)) + "");
        }

        @Override
        public void onFinishRecord(File voiceFile, int duration) {
            MyMessage message = new MyMessage(null, IMessage.MessageType.SEND_VOICE.ordinal());
            message.setUserInfo(new DefaultUser("1", "Ironman", "R.drawable.ironman"));
            message.setMediaFilePath(voiceFile.getPath());
            message.setDuration(duration);
            message.setTimeString(new SimpleDateFormat("HH:mm", Locale.getDefault()).format(new Date()));
            mAdapter.addToStart(message, true);
        }

        @Override
        public void onCancelRecord() {
        }

        /**
         * In preview record voice layout, fires when click cancel button
         * Add since chatinput v0.7.3
         */
        @Override
        public void onPreviewCancel() {
        }

        /**
         * In preview record voice layout, fires when click send button
         * Add since chatinput v0.7.3
         */
        @Override
        public void onPreviewSend() {
        }
    });
    mChatView.setOnCameraCallbackListener(new OnCameraCallbackListener() {

        @Override
        public void onTakePictureCompleted(String photoPath) {
            final MyMessage message = new MyMessage(null, IMessage.MessageType.SEND_IMAGE.ordinal());
            message.setTimeString(new SimpleDateFormat("HH:mm", Locale.getDefault()).format(new Date()));
            message.setMediaFilePath(photoPath);
            mPathList.add(photoPath);
            mMsgIdList.add(message.getMsgId());
            message.setUserInfo(new DefaultUser("1", "Ironman", "R.drawable.ironman"));
            MessageListActivity.this.runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    mAdapter.addToStart(message, true);
                }
            });
        }

        @Override
        public void onStartVideoRecord() {
        }

        @Override
        public void onFinishVideoRecord(String videoPath) {
        }

        @Override
        public void onCancelVideoRecord() {
        }
    });
    mChatView.getChatInputView().getInputView().setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            scrollToBottom();
            return false;
        }
    });
    mChatView.getSelectAlbumBtn().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MessageListActivity.this, "OnClick select album button", Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : OnCameraCallbackListener(cn.jiguang.imui.chatinput.listener.OnCameraCallbackListener) IntentFilter(android.content.IntentFilter) RecordVoiceListener(cn.jiguang.imui.chatinput.listener.RecordVoiceListener) ImageView(android.widget.ImageView) ChatView(imui.jiguang.cn.imuisample.views.ChatView) ChatInputView(cn.jiguang.imui.chatinput.ChatInputView) View(android.view.View) Date(java.util.Date) MotionEvent(android.view.MotionEvent) OnMenuClickListener(cn.jiguang.imui.chatinput.listener.OnMenuClickListener) FileItem(cn.jiguang.imui.chatinput.model.FileItem) DefaultUser(imui.jiguang.cn.imuisample.models.DefaultUser) MyMessage(imui.jiguang.cn.imuisample.models.MyMessage) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File)

Aggregations

MotionEvent (android.view.MotionEvent)2 View (android.view.View)2 ChatInputView (cn.jiguang.imui.chatinput.ChatInputView)2 OnCameraCallbackListener (cn.jiguang.imui.chatinput.listener.OnCameraCallbackListener)2 OnMenuClickListener (cn.jiguang.imui.chatinput.listener.OnMenuClickListener)2 RecordVoiceListener (cn.jiguang.imui.chatinput.listener.RecordVoiceListener)2 FileItem (cn.jiguang.imui.chatinput.model.FileItem)2 File (java.io.File)2 Activity (android.app.Activity)1 IntentFilter (android.content.IntentFilter)1 SharedPreferences (android.content.SharedPreferences)1 BitmapFactory (android.graphics.BitmapFactory)1 MediaPlayer (android.media.MediaPlayer)1 Handler (android.os.Handler)1 ViewPager (android.support.v4.view.ViewPager)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 DisplayMetrics (android.util.DisplayMetrics)1 ViewTreeObserver (android.view.ViewTreeObserver)1 EditText (android.widget.EditText)1