lmw
2025-04-14 0361f47762f9958f2ec91fdb62bfc98de4e162a6
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.xianning.driver.ui.main
 
import android.os.Bundle
import android.os.CountDownTimer
import cn.sinata.xldutils.activitys.DialogActivity
import cn.sinata.xldutils.utils.*
import com.xianning.driver.R
import com.xianning.driver.netUtls.*
import com.xianning.driver.utils.AudioRecoderUtils
import kotlinx.android.synthetic.main.dialog_voice_order.*
import org.jetbrains.anko.startActivity
 
class VoiceOrderFragment : DialogActivity() {
 
 
    val orderId by lazy {
        intent?.getStringExtra("orderId")
    }
    val orderType by lazy {
        intent?.getStringExtra("orderType")
    }
 
    val timeDown by lazy {
        intent?.getIntExtra("time", -1)
    }
    val type by lazy {
        intent?.getIntExtra("type", -1)
    }
 
    val audio by lazy {
        intent?.getStringExtra("audio")
    }
 
 
    lateinit var time: CountDownTimer
    private val audioRecoderUtils by lazy { AudioRecoderUtils() }
 
 
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        var strBtn = "抢单"
        if (type == 2) {
            strBtn = "确定"
        }
        time = timeOver((timeDown!!.toLong() * 1000L)) {
            if (it == 0) {
                finish()
            } else {
                tv_sure.text = strBtn + it.toString() + "S"
            }
        }
        tv_close.clickDelay {
            finish()
        }
        tv_sure.clickDelay {
            showGetOrder()
        }
 
        audioRecoderUtils.startplayMusic(this,audio)
        iv_voice.clickDelay {
            audioRecoderUtils.startplayMusic(this,audio)
        }
    }
 
    override fun initView() {
 
    }
 
    override fun onPause() {
        super.onPause()
 
    }
 
    override fun onDestroy() {
        super.onDestroy()
        time.cancel()
        audioRecoderUtils.stopPlayMusic()
    }
 
    override fun setContentLayout(): Int {
        return R.layout.dialog_voice_order
    }
 
    fun showGetOrder() {
        var map = getMapByAny()
        map["orderId"] = orderId
        map["orderType"] = orderType
        callNet(this, Api.grabOrder, map) {
            Toast.create(this).show("抢单成功")
            startActivity<CallOrderActivity>(
                "orderId" to orderId,
                "orderType" to orderType)
            onBackPressed()
        }
    }
}