From d615261301c4f88ffe4e9729ebbaf25e7881dc6c Mon Sep 17 00:00:00 2001 From: xuxinchao Date: Thu, 23 Nov 2023 14:27:25 +0800 Subject: [PATCH] =?UTF-8?q?[6.2.0]=E4=B8=BB=E5=8A=A8=E5=BD=95=E5=8C=85?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../badcase/biz/InitiativeBadCaseWindow.kt | 52 +++++++++++++++---- .../devatools/badcase/BadCaseNetListener.kt | 5 ++ .../devatools/CallerDevaToolsNetManager.kt | 10 ++++ 3 files changed, 56 insertions(+), 11 deletions(-) diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/InitiativeBadCaseWindow.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/InitiativeBadCaseWindow.kt index 46da673877..022835a157 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/InitiativeBadCaseWindow.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/badcase/biz/InitiativeBadCaseWindow.kt @@ -131,6 +131,9 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList // 用HashMap存储听写结果 private val mIatResults: HashMap = 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) { - 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() 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) + } + } + } \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/devatools/badcase/BadCaseNetListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/devatools/badcase/BadCaseNetListener.kt index e1dcad3d5b..7bee9f317c 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/devatools/badcase/BadCaseNetListener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/devatools/badcase/BadCaseNetListener.kt @@ -33,4 +33,9 @@ interface BadCaseNetListener { * 被动录包请求错误回调 */ fun onPassiveError(){} + + /** + * 录包上传Cos成功回调 + */ + fun onUploadCosSuccess(cosUrl: String){} } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/devatools/CallerDevaToolsNetManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/devatools/CallerDevaToolsNetManager.kt index dd99793bf6..a228a2621a 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/devatools/CallerDevaToolsNetManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/devatools/CallerDevaToolsNetManager.kt @@ -67,4 +67,14 @@ object CallerDevaToolsNetManager: CallerBase() { } } + /** + * 主动录包上传Cos桶成功回调 + */ + fun invokeUploadCosSuccess(cosUrl: String){ + M_LISTENERS.forEach{ + val listener = it.value + listener.onUploadCosSuccess(cosUrl) + } + } + } \ No newline at end of file