| | |
| | | package com.igo.user.ui.mine |
| | | |
| | | import android.app.Activity |
| | | import android.content.Intent |
| | | import android.widget.EditText |
| | | import android.widget.TextView |
| | | import cn.sinata.xldutils.utils.myToast |
| | |
| | | import com.igo.user.network.HttpManager |
| | | import com.igo.user.network.request |
| | | import com.igo.user.ui.TransparentStatusBarActivity |
| | | import com.igo.user.ui.login.AreaCodeActivity |
| | | import org.jetbrains.anko.find |
| | | import org.jetbrains.anko.startActivity |
| | | import org.jetbrains.anko.startActivityForResult |
| | | |
| | | class SetEmergencyActivity:TransparentStatusBarActivity() { |
| | | override fun setContentView() = R.layout.activity_set_emergency |
| | |
| | | private lateinit var name:String |
| | | private lateinit var phone:String |
| | | |
| | | private val areaCode by lazy { find<TextView>(R.id.areaCode) } |
| | | private val myPhone by lazy { |
| | | intent.getStringExtra("myPhone") |
| | | } |
| | |
| | | private val et_phone by lazy { find<EditText>(R.id.et_phone) } |
| | | |
| | | override fun initClick() { |
| | | areaCode.setOnClickListener { |
| | | startActivityForResult<AreaCodeActivity>(10086) |
| | | } |
| | | tv_action.setOnClickListener { |
| | | val name = et_name.text.toString() |
| | | if (name.isEmpty()){ |
| | | myToast(getString(R.string.请输入姓名)) |
| | | return@setOnClickListener |
| | | } |
| | | val phone = et_phone.text.toString() |
| | | var phone = et_phone.text.toString() |
| | | if (phone.isEmpty()){ |
| | | myToast(getString(R.string.请填写手机号)) |
| | | return@setOnClickListener |
| | | } |
| | | phone = areaCode.text.toString().replace("+","") + phone |
| | | |
| | | if (phone == myPhone){ |
| | | myToast(getString(R.string.请勿设置本人手机号为紧急联系人)) |
| | | return@setOnClickListener |
| | |
| | | title = getString(R.string.编辑) |
| | | } |
| | | } |
| | | |
| | | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
| | | super.onActivityResult(requestCode, resultCode, data) |
| | | if (resultCode == Activity.RESULT_OK && requestCode == 10086) { |
| | | data?.getStringExtra("code")?.let { |
| | | areaCode.text = it |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |