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()
|
}
|
}
|
}
|