Skip to content

Commit cf2db46

Browse files
committed
解决60s语音发送失败等问题
Signed-off-by: Carlos2015 <[email protected]>
1 parent ead3f97 commit cf2db46

7 files changed

Lines changed: 25 additions & 13 deletions

File tree

app/src/main/java/net/coding/program/common/AmrAudioRecorder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public void stop(){
268268
isRecording = false;
269269
synchronized (mLock) {
270270
try {
271-
mLock.wait(500);
271+
mLock.wait(1800);
272272
} catch (InterruptedException e) {
273273
e.printStackTrace();
274274
}

app/src/main/java/net/coding/program/common/enter/EnterEmojiLayout.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public class EnterEmojiLayout extends EnterLayout {
205205
protected InputType mInputType;
206206
private FrameLayout mPanelLayout;
207207

208-
208+
protected boolean isSoftKeyBoard = false;
209209

210210

211211
public EnterEmojiLayout(final FragmentActivity activity, View.OnClickListener sendTextOnClick, Type type, EmojiType emojiType) {
@@ -240,12 +240,15 @@ public void onGlobalLayout() {
240240
}
241241
}
242242

243-
// if(isCloseSoftkeyboardAndOpenNoTextInput && !mEnterLayoutStatus && mInputType!=null && mInputType!=InputType.Text && contentViewHeight == getContentViewHeight(activity)){
244-
// // dropTempWindow();
245-
// isCloseSoftkeyboardAndOpenNoTextInput = false;
246-
// // updateEnterLayoutBottom(0);
247-
// Log.w("Test", "输入法已经隐藏");
248-
// }
243+
int h = getContentViewHeight(activity);
244+
if(contentViewHeight == h){
245+
// dropTempWindow();
246+
isSoftKeyBoard = false;
247+
// updateEnterLayoutBottom(0);
248+
//Log.w("Test", "输入法已经隐藏");
249+
}else if(contentViewHeight>h){
250+
isSoftKeyBoard = true;
251+
}
249252
if (rootViewHigh == 0) {
250253
return;
251254
}
@@ -426,7 +429,8 @@ public void onClick(View v) {
426429

427430
final int bottomHigh = Global.dpToPx(100); // 底部虚拟按键高度,nexus5是73dp,以防万一,所以设大一点
428431
int rootParentHigh = rootView.getRootView().getHeight();
429-
if (rootParentHigh - rootViewHigh > bottomHigh) {
432+
//rootParentHigh - rootViewHigh > bottomHigh
433+
if (isSoftKeyBoard) {
430434
// 说明键盘已经弹出来了,等键盘消失后再设置 emoji keyboard 可见
431435
if(commonEnterRoot!=null){
432436
toggleInputTypeWithCloseSoftkeyboard(InputType.Emoji);

app/src/main/java/net/coding/program/common/enter/EnterLayout.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.text.Editable;
77
import android.text.Spannable;
88
import android.text.TextWatcher;
9+
import android.util.Log;
910
import android.view.KeyEvent;
1011
import android.view.View;
1112
import android.view.ViewGroup;

app/src/main/java/net/coding/program/common/enter/EnterVoiceLayout.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public class EnterVoiceLayout extends EnterEmojiLayout {
6363
//判断是否为新功能,如果是,语音按钮会显示红点
6464
private boolean isNewFunction = true;
6565
private BadgeView mBadgeView;
66-
6766
public EnterVoiceLayout(ActionBarActivity activity, View.OnClickListener sendTextOnClick, Type type, EmojiType emojiType) {
6867
super(activity, sendTextOnClick, type, emojiType);
6968
init(activity);
@@ -137,7 +136,8 @@ public void onClick(View v) {
137136

138137
final int bottomHigh = Global.dpToPx(100); // 底部虚拟按键高度,nexus5是73dp,以防万一,所以设大一点
139138
int rootParentHigh = rootView.getRootView().getHeight();
140-
if (rootParentHigh - rootViewHigh > bottomHigh) {
139+
140+
if (isSoftKeyBoard) {
141141
// 说明键盘已经弹出来了,等键盘消失后再设置 emoji keyboard 可见
142142
toggleInputTypeWithCloseSoftkeyboard(InputType.Voice);
143143
// 魅族手机的 rootView 无论输入法是否弹出高度都是不变的,只好搞个延时做这个事
@@ -539,6 +539,7 @@ private long stopRecord() {
539539
voiceRecrodAnimtion.selectDrawable(0);
540540
tips_hold_to_talk.setVisibility(View.VISIBLE);
541541
soundWaveLayout.setVisibility(View.GONE);
542+
recordTime.setTextColor(0xFF50AEEA);
542543
if (mAmrAudioRecorder == null) {
543544
return 0L;
544545
}

app/src/main/java/net/coding/program/maopao/item/ContentAreaImages.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ private void playVoiceAnim(){
241241
private void stopPlayVoiceAnim(){
242242

243243
isAnimRuning = false;
244+
mHandler.removeCallbacksAndMessages(null);
244245
frame = 0;
245246
if(Build.VERSION.SDK_INT>=16){
246247
voice_play.setBackground(voicePlayAnim.getFrame(0));
@@ -335,8 +336,11 @@ public void setData(String data) {
335336
voice_play.setBackgroundDrawable(voicePlayAnim.getFrame(0));
336337
}
337338
}else{
338-
mHandler.removeCallbacksAndMessages(null);
339-
playVoiceAnim();
339+
stopPlayVoiceAnim();
340+
if(mVoicePlayCallBack.getPlayingVoicePath()!=null){
341+
playVoiceAnim();
342+
}
343+
340344
}
341345

342346
View.OnClickListener mOnClickListener = new View.OnClickListener() {

app/src/main/java/net/coding/program/message/MessageListActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,7 @@ public void markVoicePlayed(int id) {
914914
}
915915
}
916916
adapter.notifyDataSetChanged();
917+
AccountInfo.saveMessages(MessageListActivity.this, mUserObject.global_key, mData);
917918
}
918919

919920
@Override

app/src/main/java/net/coding/program/message/UsersListFragment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ public void parseJson(int code, JSONObject respanse, String tag, int pos, Object
400400
private void markUserReaded(String globalKey, Message.MessageObject message) {
401401
for (int i = 0; i < mData.size(); ++i) {
402402
Message.MessageObject item = mData.get(i);
403+
handleVoiceMessage(item);
403404
if (item.friend.global_key.equals(globalKey)) {
404405
item.unreadCount = 0;
405406
if (message != null) {

0 commit comments

Comments
 (0)