Search in sources :

Example 1 with VoiceRecorder

use of com.easemob.util.VoiceRecorder in project wechat by motianhuo.

the class ChatActivity method initView.

/**
	 * initView
	 */
protected void initView() {
    netClient = new NetClient(this);
    recordingContainer = findViewById(R.id.view_talk);
    txt_title = (TextView) findViewById(R.id.txt_title);
    img_right = (ImageView) findViewById(R.id.img_right);
    micImage = (ImageView) findViewById(R.id.mic_image);
    animationDrawable = (AnimationDrawable) micImage.getBackground();
    animationDrawable.setOneShot(false);
    recordingHint = (TextView) findViewById(R.id.recording_hint);
    listView = (ListView) findViewById(R.id.list);
    mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage);
    buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard);
    edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout);
    buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice);
    buttonSend = findViewById(R.id.btn_send);
    buttonPressToSpeak = findViewById(R.id.btn_press_to_speak);
    expressionViewpager = (ViewPager) findViewById(R.id.vPager);
    emojiIconContainer = (LinearLayout) findViewById(R.id.ll_face_container);
    btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container);
    // locationImgview = (ImageView) findViewById(R.id.btn_location);
    iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal);
    iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked);
    loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more);
    btnMore = (Button) findViewById(R.id.btn_more);
    iv_emoticons_normal.setVisibility(View.VISIBLE);
    iv_emoticons_checked.setVisibility(View.INVISIBLE);
    more = findViewById(R.id.more);
    edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal);
    // 表情list
    reslist = getExpressionRes(62);
    // 初始化表情viewpager
    List<View> views = new ArrayList<View>();
    View gv1 = getGridChildView(1);
    View gv2 = getGridChildView(2);
    View gv3 = getGridChildView(3);
    views.add(gv1);
    views.add(gv2);
    views.add(gv3);
    expressionViewpager.setAdapter(new ExpressionPagerAdapter(views));
    edittext_layout.requestFocus();
    voiceRecorder = new VoiceRecorder(micImageHandler);
    buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen());
    mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active);
            } else {
                edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal);
            }
        }
    });
    mEditTextContent.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active);
            more.setVisibility(View.GONE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
            emojiIconContainer.setVisibility(View.GONE);
            btnContainer.setVisibility(View.GONE);
        }
    });
    // 监听文字框
    mEditTextContent.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (!TextUtils.isEmpty(s)) {
                btnMore.setVisibility(View.GONE);
                buttonSend.setVisibility(View.VISIBLE);
            } else {
                btnMore.setVisibility(View.VISIBLE);
                buttonSend.setVisibility(View.GONE);
            }
        }

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

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
}
Also used : OnFocusChangeListener(android.view.View.OnFocusChangeListener) VoiceRecorder(com.easemob.util.VoiceRecorder) ArrayList(java.util.ArrayList) ExpressionPagerAdapter(com.juns.wechat.chat.adpter.ExpressionPagerAdapter) ImageView(android.widget.ImageView) ExpandGridView(com.juns.wechat.chat.widght.ExpandGridView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) NetClient(com.juns.wechat.net.NetClient) OnClickListener(android.view.View.OnClickListener) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable)

Aggregations

Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 OnFocusChangeListener (android.view.View.OnFocusChangeListener)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 VoiceRecorder (com.easemob.util.VoiceRecorder)1 ExpressionPagerAdapter (com.juns.wechat.chat.adpter.ExpressionPagerAdapter)1 ExpandGridView (com.juns.wechat.chat.widght.ExpandGridView)1 NetClient (com.juns.wechat.net.NetClient)1 ArrayList (java.util.ArrayList)1