| | |
| | | import com.igo.user.network.request |
| | | import com.igo.user.ui.H5Activity |
| | | import com.igo.user.ui.TransparentStatusBarActivity |
| | | import com.igo.user.ui.login.AreaCodeActivity |
| | | import com.tbruyelle.rxpermissions2.RxPermissions |
| | | import org.jetbrains.anko.find |
| | | import org.jetbrains.anko.startActivity |
| | | import org.jetbrains.anko.startActivityForResult |
| | | |
| | | class OrderOtherActivity:TransparentStatusBarActivity() { |
| | | override fun setContentView() = R.layout.activity_order_other |
| | | |
| | | private val areaCode by lazy { find<TextView>(R.id.areaCode) } |
| | | private val tv_action by lazy { find<View>(R.id.tv_action) } |
| | | private val tv_contact by lazy { find<View>(R.id.tv_contact) } |
| | | private val tv_rule by lazy { find<TextView>(R.id.tv_rule) } |
| | |
| | | private val et_name by lazy { find<EditText>(R.id.et_name) } |
| | | |
| | | override fun initClick() { |
| | | areaCode.setOnClickListener { |
| | | startActivityForResult<AreaCodeActivity>(10086) |
| | | } |
| | | tv_contact.setOnClickListener { |
| | | RxPermissions(this).request(Manifest.permission.READ_CONTACTS).subscribe { |
| | | if (it) { |
| | |
| | | } |
| | | } |
| | | tv_action.setOnClickListener { |
| | | val phone = et_phone.text.toString() |
| | | if (phone.isEmpty()){ |
| | | var phone = et_phone.text.toString() |
| | | if (phone.isEmpty()) { |
| | | myToast(getString(R.string.请填写手机号)) |
| | | return@setOnClickListener |
| | | } |
| | | phone = areaCode.toString().replace("+", "") + phone |
| | | |
| | | val name = et_name.text.toString() |
| | | if (name.isEmpty()){ |
| | | if (name.isEmpty()) { |
| | | myToast(getString(R.string.请输入姓名)) |
| | | return@setOnClickListener |
| | | } |
| | | setResult(Activity.RESULT_OK,intent.putExtra("name", name).putExtra("phone", phone)) |
| | | setResult(Activity.RESULT_OK, intent.putExtra("name", name).putExtra("phone", phone)) |
| | | finish() |
| | | } |
| | | } |
| | |
| | | |
| | | override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
| | | super.onActivityResult(requestCode, resultCode, data) |
| | | if (data!=null&&resultCode == Activity.RESULT_OK){ |
| | | val uri = data.data |
| | | if (uri!=null){ |
| | | val contacts = getPhoneContacts (uri) |
| | | et_name.setText(contacts[0]) |
| | | et_phone.setText(contacts[1].replace(" ","")) |
| | | et_phone.setSelection(et_phone.text.length) |
| | | if (data != null && resultCode == Activity.RESULT_OK) { |
| | | if (requestCode == 10086) { |
| | | data.getStringExtra("code")?.let { |
| | | areaCode.text = it |
| | | } |
| | | } else { |
| | | val uri = data.data |
| | | if (uri != null) { |
| | | val contacts = getPhoneContacts(uri) |
| | | et_name.setText(contacts[0]) |
| | | et_phone.setText(contacts[1].replace(" ", "")) |
| | | et_phone.setSelection(et_phone.text.length) |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |