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