use of com.rongseal.utlis.MediaRecorderUtils in project SeaStar by 13120241790.
the class RecordDialog method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getContext().setTheme(android.R.style.Theme_InputMethod);
setContentView(R.layout.layout_dialog_record);
Window window = getWindow();
WindowManager.LayoutParams attributesParams = window.getAttributes();
attributesParams.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
attributesParams.dimAmount = 0.4f;
@SuppressWarnings("deprecation") int width = (int) (window.getWindowManager().getDefaultDisplay().getWidth() * 0.85);
window.setLayout(width, LayoutParams.WRAP_CONTENT);
downMinTimer = new DownTimer();
downMinTimer.setListener(new DownTimerListener() {
@Override
public void onTick(long millisUntilFinished) {
recordTimeFlag = false;
}
@Override
public void onFinish() {
recordTimeFlag = true;
}
});
downMaxTimer = new DownTimer();
downMaxTimer.setListener(new DownTimerListener() {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
animation.stop();
recorderUtils.onRecord(false);
view_line.setVisibility(View.VISIBLE);
btn_detail_record.setVisibility(View.GONE);
img_record_animation.setVisibility(View.GONE);
btn_detail_confirm.setVisibility(View.VISIBLE);
btn_detail_confirm.setText(R.string.submit_text);
btn_detail_cancel.setVisibility(View.VISIBLE);
img_record_bg.setVisibility(View.VISIBLE);
tv_record_play.setVisibility(View.VISIBLE);
NToast.shortToast(getContext(), R.string.record_time_max_text);
}
});
recorderUtils = new MediaRecorderUtils();
img_record_animation = (ImageView) findViewById(R.id.img_record_animation);
img_record_bg = (ImageView) findViewById(R.id.img_record_bg);
tv_record_play = (TextView) findViewById(R.id.tv_record_play);
tv_record_play.setOnClickListener(this);
animation = (AnimationDrawable) img_record_animation.getBackground();
btn_detail_cancel = (Button) findViewById(R.id.btn_detail_cancel);
btn_detail_cancel.setOnClickListener(this);
btn_detail_cancel.setVisibility(View.GONE);
view_line = (View) findViewById(R.id.view_line);
view_line.setVisibility(View.GONE);
btn_detail_confirm = (Button) findViewById(R.id.btn_detail_confirm);
btn_detail_confirm.setOnClickListener(this);
btn_detail_confirm.setVisibility(View.GONE);
btn_detail_record = (Button) findViewById(R.id.btn_detail_record);
btn_detail_record.setVisibility(View.VISIBLE);
btn_detail_record.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent event) {
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
animation.stop();
animation.start();
if (downMinTimer != null) {
downMinTimer.stopDown();
}
downMinTimer.startDown(2000);
if (downMaxTimer != null) {
downMaxTimer.stopDown();
}
downMaxTimer.startDown(5000);
recorderUtils.onRecord(true);
break;
case MotionEvent.ACTION_UP:
animation.stop();
recorderUtils.onRecord(false);
if (downMaxTimer != null) {
downMaxTimer.stopDown();
}
if (recordTimeFlag) {
view_line.setVisibility(View.VISIBLE);
btn_detail_record.setVisibility(View.GONE);
img_record_animation.setVisibility(View.GONE);
btn_detail_confirm.setVisibility(View.VISIBLE);
btn_detail_confirm.setText(R.string.submit_text);
btn_detail_cancel.setVisibility(View.VISIBLE);
img_record_bg.setVisibility(View.VISIBLE);
tv_record_play.setVisibility(View.VISIBLE);
} else {
NToast.shortToast(getContext(), R.string.record_time_text);
}
break;
}
return false;
}
});
}
Aggregations