lmw
2023-06-13 adf8013576cbdd12e5ebea8ff7e32baf5d558b27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.kuanzhai.user.ui.mine
 
import android.app.Activity
import androidx.core.os.bundleOf
import cn.sinata.xldutils.clickDelay
import com.kuanzhai.user.R
import com.kuanzhai.user.dialog.TipDialog
import com.kuanzhai.user.dialog.VoiceSetSuccessDialog
import com.kuanzhai.user.network.HttpManager
import com.kuanzhai.user.network.request
import com.kuanzhai.user.ui.TransparentStatusBarActivity
import kotlinx.android.synthetic.main.activity_voice_record.*
import org.jetbrains.anko.backgroundColorResource
 
class VoiceRecordActivity : TransparentStatusBarActivity() {
    override fun setContentView() = R.layout.activity_voice_record
 
    private var voice  = true
 
    override fun initClick() {
        tv_action.clickDelay {
            val tipDialog = TipDialog()
            val operation = if (voice) "关闭" else "开启"
            tipDialog.arguments = bundleOf("title" to "是否${operation}车内录音?","msg" to if (voice) "关闭后立即生效" else "开启后下一订单生效","ok" to "确认$operation")
            tipDialog.setCallback(object :TipDialog.OnClickCallback{
                override fun onOk() {
                    HttpManager.setSound(if (voice) 0 else 1).request(this@VoiceRecordActivity){_,_->
                        setResult(Activity.RESULT_OK)
                        voice = !voice
                        val voiceSetSuccessDialog = VoiceSetSuccessDialog()
                        voiceSetSuccessDialog.arguments = bundleOf("msg" to if (voice) "车内录音将在下一单开启" else "已关闭车内录音功能")
                        voiceSetSuccessDialog.show(supportFragmentManager,"suc")
                        showState()
                    }
                }
 
                override fun onCancel() {
                }
            })
            tipDialog.show(supportFragmentManager,"voice")
        }
    }
 
    override fun initView() {
        voice = intent.getBooleanExtra("voice",false)
        showState()
    }
 
    private fun showState(){
        if (!voice){
            bg.backgroundColorResource = R.color.textColor66
            tv_state.text = "车内录音功能已关闭"
            tv_action.text = "立即开启车内录音"
        }else{
            bg.backgroundColorResource = R.color.colorPrimary
            tv_state.text = "车内录音功能已开启"
            tv_action.text = "立即关闭车内录音"
        }
    }
}