use of org.kymjs.blog.ui.widget.RecordButtonUtil.OnPlayListener in project KJFrameForAndroid by kymjs.
the class TweetRecordFragment method initWidget.
@Override
protected void initWidget(View view) {
super.initWidget(view);
RelativeLayout.LayoutParams params = (LayoutParams) mBtnRecort.getLayoutParams();
params.width = DensityUtils.getScreenW(getActivity());
params.height = (int) (DensityUtils.getScreenH(getActivity()) * 0.4);
mBtnRecort.setLayoutParams(params);
mBtnRecort.setOnFinishedRecordListener(new OnFinishedRecordListener() {
@Override
public void onFinishedRecord(String audioPath, int recordTime) {
mLayout.setVisibility(View.VISIBLE);
if (recordTime < 10) {
mTvTime.setText("0" + recordTime + "\"");
} else {
mTvTime.setText(recordTime + "\"");
}
mImgAdd.setVisibility(View.GONE);
filePath = null;
}
@Override
public void onCancleRecord() {
mLayout.setVisibility(View.GONE);
}
});
drawable = (AnimationDrawable) mImgVolume.getBackground();
mBtnRecort.getAudioUtil().setOnPlayListener(new OnPlayListener() {
@Override
public void stopPlay() {
drawable.stop();
mImgVolume.setBackgroundDrawable(drawable.getFrame(0));
}
@Override
public void starPlay() {
mImgVolume.setBackgroundDrawable(drawable);
drawable.start();
}
});
mEtSpeech.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() > MAX_LEN) {
mTvInputLen.setText("已达到最大长度");
} else {
mTvInputLen.setText("你还可以输入" + (MAX_LEN - s.length()) + "个字");
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
if (s.length() > MAX_LEN) {
mEtSpeech.setText(s.subSequence(0, MAX_LEN));
CharSequence text = mEtSpeech.getText();
if (text instanceof Spannable) {
Selection.setSelection((Spannable) text, MAX_LEN);
}
}
}
});
}
Aggregations