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 = "立即关闭车内录音"
|
}
|
}
|
}
|