|
@@ -416,7 +416,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- UiUtils.showPermissionTipDialog(getChildFragmentManager(),getContext(),"提示","请开启麦克风访问权限");
|
|
|
+ UiUtils.showPermissionTipDialog(getChildFragmentManager(), getContext(), "提示", "请开启麦克风访问权限");
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -444,7 +444,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
}
|
|
|
|
|
|
private void showLoadingAnim() {
|
|
|
- if (mViewBinding!=null && mViewBinding.llLoading.getVisibility() != View.VISIBLE) {
|
|
|
+ if (mViewBinding != null && mViewBinding.llLoading.getVisibility() != View.VISIBLE) {
|
|
|
currentProgressCount = 0;
|
|
|
mViewBinding.progress.setProgress(0);
|
|
|
mViewBinding.ivLoadingBack.setVisibility(View.VISIBLE);
|
|
@@ -461,7 +461,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
}
|
|
|
|
|
|
private void hideLoadingAnim() {
|
|
|
- if(mViewBinding!=null){
|
|
|
+ if (mViewBinding != null) {
|
|
|
currentProgressCount = 0;
|
|
|
mViewBinding.ivLoadingBack.setVisibility(View.GONE);
|
|
|
mViewBinding.viewLoadingAnim.cancelAnimation();
|
|
@@ -736,7 +736,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
long bufferDuration = (long) wavRecorder.getBufferDuration();
|
|
|
long time = System.currentTimeMillis();
|
|
|
long result = time - bufferDuration;
|
|
|
- mPlayHelper.toPlay2(result,getFirstNoteTime(message),isMuteMode(message));
|
|
|
+ mPlayHelper.toPlay2(result, getFirstNoteTime(message), isMuteMode(message));
|
|
|
} else if ("1".equals(recorder)) {
|
|
|
// onSendMessage(message.toString());
|
|
|
} else {
|
|
@@ -783,7 +783,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private int getFirstNoteTime(JSONObject jsonObject){
|
|
|
+ private int getFirstNoteTime(JSONObject jsonObject) {
|
|
|
if (jsonObject == null) {
|
|
|
return 0;
|
|
|
}
|
|
@@ -835,7 +835,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
if (permission) {
|
|
|
startWebSocketClient(message);
|
|
|
} else {
|
|
|
- UiUtils.showPermissionTipDialog(getChildFragmentManager(),getContext(),"提示","请开启麦克风访问权限");
|
|
|
+ UiUtils.showPermissionTipDialog(getChildFragmentManager(), getContext(), "提示", "请开启麦克风访问权限");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -1074,12 +1074,11 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
@SuppressLint("CheckResult")
|
|
|
@Override
|
|
|
public void isWiredHeadsetOn(JSONObject jsonObject) {
|
|
|
-
|
|
|
-
|
|
|
try {
|
|
|
JSONObject content = jsonObject.getJSONObject("content");
|
|
|
- content.put("checkIsWired", !TextUtils.isEmpty(checkType()));
|
|
|
- content.put("type", checkType());
|
|
|
+ String s = com.daya.orchestra.accompany.utils.Utils.checkType(getContext());
|
|
|
+ content.put("checkIsWired", !TextUtils.isEmpty(s));
|
|
|
+ content.put("type", s);
|
|
|
onSendMessage(jsonObject.toString());
|
|
|
|
|
|
if (webSocketClient != null) {
|
|
@@ -1181,7 +1180,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- UiUtils.showPermissionTipDialog(getChildFragmentManager(),getContext(),"提示","请开启摄像头、麦克风、储存访问权限");
|
|
|
+ UiUtils.showPermissionTipDialog(getChildFragmentManager(), getContext(), "提示", "请开启摄像头、麦克风、储存访问权限");
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -1214,7 +1213,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- UiUtils.showPermissionTipDialog(getChildFragmentManager(),getContext(),"提示","请开启摄像头、麦克风、储存访问权限");
|
|
|
+ UiUtils.showPermissionTipDialog(getChildFragmentManager(), getContext(), "提示", "请开启摄像头、麦克风、储存访问权限");
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -1232,38 +1231,6 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
}, 1500);
|
|
|
}
|
|
|
|
|
|
- private String checkType() {
|
|
|
- AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
|
- AudioDeviceInfo[] devices = audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
|
|
|
- for (AudioDeviceInfo device : devices) {
|
|
|
- int deviceType = device.getType();
|
|
|
- if (deviceType == AudioDeviceInfo.TYPE_WIRED_HEADSET || deviceType == AudioDeviceInfo.TYPE_WIRED_HEADPHONES) {
|
|
|
- return "有线耳机";
|
|
|
- }
|
|
|
- if (deviceType == AudioDeviceInfo.TYPE_BLUETOOTH_A2DP
|
|
|
- || deviceType == AudioDeviceInfo.TYPE_BLUETOOTH_SCO) {
|
|
|
- return "蓝牙耳机";
|
|
|
- }
|
|
|
- if (deviceType == AudioDeviceInfo.TYPE_BUILTIN_EARPIECE) {
|
|
|
- if (Constants.HEADSET_PLUE_TAG.isEmpty()) {
|
|
|
- return null;
|
|
|
- } else {
|
|
|
- return "有线耳机";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (audioManager.isWiredHeadsetOn()) {
|
|
|
- return "有线耳机";
|
|
|
- }
|
|
|
- if (audioManager.isBluetoothScoOn() || audioManager.isBluetoothA2dpOn()) {
|
|
|
- return "蓝牙耳机";
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void videoUpdate(JSONObject jsonObject) {
|
|
|
if (onAccompanyListener != null)
|
|
@@ -1768,7 +1735,7 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
} else {
|
|
|
- UiUtils.showPermissionTipDialog(getChildFragmentManager(),getContext(),"提示","请开启储存访问权限");
|
|
|
+ UiUtils.showPermissionTipDialog(getChildFragmentManager(), getContext(), "提示", "请开启储存访问权限");
|
|
|
}
|
|
|
});
|
|
|
} catch (Exception e) {
|
|
@@ -2068,18 +2035,18 @@ public class AccompanyFragment extends BaseMVPFragment<FragmentAccompanyBinding,
|
|
|
mPlayHelper.startTune(message);
|
|
|
}
|
|
|
} else {
|
|
|
- sendNoPermissionMsg(message,"没有麦克风权限");
|
|
|
- UiUtils.showPermissionTipDialog(getChildFragmentManager(),getContext(),"提示","请开启麦克风访问权限");
|
|
|
+ sendNoPermissionMsg(message, "没有麦克风权限");
|
|
|
+ UiUtils.showPermissionTipDialog(getChildFragmentManager(), getContext(), "提示", "请开启麦克风访问权限");
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private void sendNoPermissionMsg(JSONObject message,String tip){
|
|
|
+ private void sendNoPermissionMsg(JSONObject message, String tip) {
|
|
|
try {
|
|
|
JSONObject content = message.getJSONObject("content");
|
|
|
content.put("reson", tip);
|
|
|
onSendMessage(message.toString());
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|