[6.2.0]主动录包修改

This commit is contained in:
xuxinchao
2023-11-23 14:27:25 +08:00
parent ffc746fecd
commit d615261301
3 changed files with 56 additions and 11 deletions

View File

@@ -131,6 +131,9 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
// 用HashMap存储听写结果
private val mIatResults: HashMap<String, String> = LinkedHashMap()
private var isUploadCos = false //是否在上传Cos操作
private var isLoadData = false //是否已经加载数据
init {
initFloatWindow()
}
@@ -211,6 +214,13 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
uploadAudio()
},1000)
}else{
//停止语音听写
mIat?.stopListening()
//结束倒计时
countDownTimer?.cancel()
countDownTimer?.onFinish()
//将倒计时置空
countDownTimer = null
uploadAudio()
}
}
@@ -323,8 +333,8 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
RecordManager.getInstance().start(audioFileName)
//开始录音,展示放大缩小动效
val scaleAnimation = ScaleAnimation(
1.0f, 0.9f, 1.0f, 0.9f,
Animation.RELATIVE_TO_SELF, 0.9f, Animation.RELATIVE_TO_SELF, 0.9f
1.0f, 0.8f, 1.0f, 0.8f,
Animation.RELATIVE_TO_SELF, 0.8f, Animation.RELATIVE_TO_SELF, 0.8f
)
scaleAnimation.duration = 1000
scaleAnimation.repeatCount = -1
@@ -365,17 +375,19 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
val singlePath = "/mnt/sdcard/mogo/DataCollection/${audioFileName}.wav"
val file = File(singlePath)
if(file.exists()){
isUploadCos = true
LogInfoManagerFactory.createAudioUpload(mActivity.applicationContext,DebugConfig.isDebug(),
TAG, MoGoAiCloudClientConfig.getInstance().sn,singlePath,
object : OnUploadListener {
override fun onUploadSuccess(key: String, filePath: String, downloadUrl: String) {
CallerLogger.d("$M_DEVA$TAG", "语音文件上传成功downloadUrl=$downloadUrl")
//将语音文件上传Cos监听移除
removeUploadListener(singlePath)
//上传到服务器
upload(downloadUrl)
if(key == TAG){
FileUtil.deleteFile(File(filePath))
if(downloadUrl.isNotBlank() && downloadUrl.contains(".wav")){
CallerDevaToolsNetManager.invokeUploadCosSuccess(downloadUrl)
//将语音文件上传Cos监听移除
removeUploadListener(singlePath)
if(key == TAG){
FileUtil.deleteFile(File(filePath))
}
}
}
@@ -501,6 +513,7 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
// mWindowParams!!.x = metrics.widthPixels
mWindowParams!!.x = 0
mWindowParams!!.y = metrics.heightPixels - BarUtils.getStatusBarHeight()-950
Log.i(TAG,"showFloatWindow hashcode = "+mFloatLayout.hashCode())
mWindowManager!!.addView(mFloatLayout, mWindowParams)
//开启录包
recordKey = Random(SystemClock.elapsedRealtime()).nextInt().toLong()
@@ -515,6 +528,7 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
}
fun showReportBIWindow(bagInfoEntity: BagInfoEntity){
Log.i(TAG,"showReportBIWindow")
if (mFloatLayout.parent == null) {
val metrics = DisplayMetrics()
// 默认固定位置,靠屏幕右边缘的中间
@@ -537,7 +551,13 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
CallerAutopilotRecordListenerManager.removeListener(this.hashCode().toString())
//注销采集原因回调监听
CallerDevaToolsNetManager.removeListener(this.hashCode().toString())
if (mFloatLayout.parent != null) mWindowManager!!.removeView(mFloatLayout)
Log.i(TAG,"hide window hash="+mFloatLayout.hashCode())
if (mFloatLayout.parent != null){
mWindowManager!!.removeView(mFloatLayout)
}
}
override fun onAutopilotRecordResult(recordPanel: RecordPanelOuterClass.RecordPanel) {
@@ -563,13 +583,15 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
}
override fun onInitiativeResponse(list: List<RecordOptionEntity>) {
if(list.isNotEmpty()){
if(!isLoadData && list.isNotEmpty()){
badReasonListAdapter?.setData(list)
isLoadData = true
}
}
override fun onInitiativeError() {
if(BadCaseReasonStore.getInitiativeDataRecord().isNotEmpty()){
if(!isLoadData && BadCaseReasonStore.getInitiativeDataRecord().isNotEmpty()){
val list = ArrayList<RecordOptionEntity>()
val result = JSONArray(BadCaseReasonStore.getInitiativeDataRecord())
if(result.length() > 0){
@@ -598,6 +620,7 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
}
}
if(list.isNotEmpty()){
isLoadData = true
badReasonListAdapter?.setData(list)
}
}else{
@@ -605,4 +628,11 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
}
}
override fun onUploadCosSuccess(cosUrl: String) {
if(isUploadCos){
//上传到服务器
upload(cosUrl)
}
}
}