lmw
2024-09-23 f23be5d1086538d541281b84d8b093f95c545c47
app/src/main/java/com/future/driver/ui/main/MainActivity.kt
@@ -7,6 +7,7 @@
import android.os.Looper
import android.provider.Settings
import android.util.Log
import android.view.View
import android.widget.Toast
import cn.sinata.rxnetty.NettyClient
import cn.sinata.xldutils.utils.*
@@ -40,6 +41,7 @@
import com.tbruyelle.rxpermissions2.RxPermissions
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.app_title.*
import kotlinx.android.synthetic.main.dialog_sure_and_del.view.*
import org.greenrobot.eventbus.EventBus
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
@@ -118,7 +120,6 @@
                        }
                    }
                }
            }
        }
    }
@@ -150,18 +151,25 @@
//        map["id"] = CacheKey.getUserId()
        callNet(Api.queryNewData, map) {
            var data = gson.fromJson<VersionBean>(it, VersionBean::class.java)
            if (data.data.version != "" && data.data.version != Utils.getAppVersion(this)) {
            if (data.data.version != "" && data.data.version > Utils.getAppVersion(this)) {
                if (data.data.mandatory == 2) {
                    DialogUtil.getDelAndSureDialog(this, "有新版本是否更新?", {}, {
                        DownloadUtil(this).downloadAPK(data.data.url, "未来出行司机端")
                    })
                } else if (data.data.mandatory == 1) {
                    DialogUtil.getDelAndSureDialog(this, "版本已过时,是否强制升级?", {
                        EventBus.getDefault().post(BaseEvent(BaseEvent.OUT_APP))
                    var isOk = false
                    val delAndSureDialog = DialogUtil.getDelAndSureDialog(this, "版本已过时,是否强制升级?", {
                    }, {
                        isOk = true
                        DownloadUtil(this).downloadAPK(data.data.url, "未来出行司机端")
                        ToastUtils.showShortToast(this, "后台开始下载,请等待")
                    })
                    val view = DialogUtil.getView(delAndSureDialog)
                    view.view_hint_close_base.visibility = View.INVISIBLE
                    delAndSureDialog.setOnDismissListener {
                        if (!isOk)
                            EventBus.getDefault().post(BaseEvent(BaseEvent.OUT_APP))
                    }
                }else{
//                    toast("已经是最新版本")
                }
@@ -187,7 +195,7 @@
    }
    private fun initCall() {
    private fun initCall(playVoice:Boolean = true) {
        var map = getMapByAny()
        callNet(Api.queryHomeData, map) {
            var data = gson.fromJson<HomeDataBean>(it, HomeDataBean::class.java)
@@ -200,10 +208,12 @@
            tv_lien_name.text = data.data.brand.toString()
            tv_car.text = if (data.data.work == 1) "收车" else "出车"
            if (data.data.work == 1){
                MyApplication.getTTsManager().setVideoText("您正在上班中")
                if (playVoice)
                    MyApplication.getTTsManager().setVideoText("您正在上班中")
                beOnDuty(true)
            }else{
                MyApplication.getTTsManager().setVideoText("您已收车")
                if (playVoice)
                    MyApplication.getTTsManager().setVideoText("您已收车")
                beOnDuty(false)
            }
            tv_time.text = DateUtil.getTime(
@@ -287,10 +297,14 @@
                    }else{
                        var map= getMapByAny()
                        map["type"] = bean[0].id
                        callNet(Api.work, map) {
                        callNet(Api.work, map,{
                            toast("上班成功")
                            beOnDuty(true)
                            EventBus.getDefault().post(BaseEvent(BaseEvent.START_CAR))
                        }){
                            if (it?.contains("人脸") == true){
                                tv_face.visible()
                            }
                        }
                    }
                }
@@ -337,6 +351,7 @@
            }
            BaseEvent.FACE_FAILED -> {
                tv_face.visible()
                initCall(false)
            }
            BaseEvent.START_RECORD -> {
                if (!MyApplication.isRecording)
@@ -371,18 +386,17 @@
    private fun updateVoice(filePath: String) {
        val ossUtil = OSSUtil(this)
        ossUtil.uploadSingleWithSize(filePath, object : OSSUtil.OSSUploadCallBack() {
            override fun onFinishWithSize(url: String?, size: Long) {
            override fun onFinishWithSize(url: String, size: Long) {
                super.onFinishWithSize(url, size)
                Log.e("mmp","录音保存路径:${url},大小:${size/1024}kb")
                val mapByAny = getMapByAny()
                mapByAny["fileFormat"] = "caf"
                mapByAny["fileName"] = url.substring(url.lastIndexOf("/"))
                mapByAny["fileLink"] = url
                mapByAny["fileSize"] = size/1024
                mapByAny["orderId"] = MyApplication.recordOrderId
                mapByAny["orderType"] = MyApplication.recordOrderType
                callNet(false,Api.tape,mapByAny){
                }
                callNet(false,Api.tape,mapByAny){}
            }
            override fun onFial(message: String?) {