Commit be03d715 authored by 张释方's avatar 张释方

提交防止重复点击代码

parent 69b06f74
...@@ -47,6 +47,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View ...@@ -47,6 +47,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
return@setOnClickListener return@setOnClickListener
} }
sendCodeThread()
mobile = mobile.replace(" ".toRegex(), "") mobile = mobile.replace(" ".toRegex(), "")
viewModel.sendMobileCode(mobile) viewModel.sendMobileCode(mobile)
...@@ -117,4 +118,31 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View ...@@ -117,4 +118,31 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
R.id.iv_left_icon -> finish() R.id.iv_left_icon -> finish()
} }
} }
/**
* 发送手机验证码,按钮动态改变状态
*/
var num = 0
var run: Runnable? = null
fun sendCodeThread() {
num = 60
tv_send_sms?.let {
it.isEnabled = false
it.text = "($num)重新获取"
run = object : Runnable {
override fun run() {
num--
if (num == 0) {
it.text = "重新获取"
it.isEnabled = true
} else {
it.text = "($num)重新获取"
it.postDelayed(this, 1000)
}
}
}
it.postDelayed(run, 1000)
}
}
} }
\ No newline at end of file
...@@ -16,6 +16,7 @@ import com.mints.street.manager.UserManager ...@@ -16,6 +16,7 @@ import com.mints.street.manager.UserManager
import kotlinx.android.synthetic.main.activity_moresettings.* import kotlinx.android.synthetic.main.activity_moresettings.*
import kotlinx.android.synthetic.main.include_header.* import kotlinx.android.synthetic.main.include_header.*
import me.goldze.mvvmhabit.utils.KLog import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.RxUtils
import me.goldze.mvvmhabit.utils.ToastUtils import me.goldze.mvvmhabit.utils.ToastUtils
import org.w3c.dom.Text import org.w3c.dom.Text
...@@ -53,6 +54,14 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti ...@@ -53,6 +54,14 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti
item_phone.findViewById<TextView>(R.id.tv_right).setTextColor(Color.BLACK) item_phone.findViewById<TextView>(R.id.tv_right).setTextColor(Color.BLACK)
item_phone.findViewById<TextView>(R.id.tv_right).text = "去绑定" item_phone.findViewById<TextView>(R.id.tv_right).text = "去绑定"
item_phone.setOnClickListener(this) item_phone.setOnClickListener(this)
RxUtils.onMultiClick(item_phone){
if (userManager.userIsLogin()) {
startActivity(BindMobileActivity::class.java)
return@onMultiClick
} else {
ToastUtils.showLong("请先使用微信登录")
}
}
} }
} }
private fun initView() { private fun initView() {
...@@ -96,14 +105,14 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti ...@@ -96,14 +105,14 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti
R.id.iv_left_icon -> { R.id.iv_left_icon -> {
finish() finish()
} }
R.id.item_phone -> { // R.id.item_phone -> {
if (userManager.userIsLogin()) { // if (userManager.userIsLogin()) {
startActivity(BindMobileActivity::class.java) // startActivity(BindMobileActivity::class.java)
return // return
} else { // } else {
ToastUtils.showLong("请先使用微信登录") // ToastUtils.showLong("请先使用微信登录")
} // }
} // }
R.id.btn_switch -> {//退出登录 R.id.btn_switch -> {//退出登录
UserManager.INSTANCE.userLogout() UserManager.INSTANCE.userLogout()
......
...@@ -32,6 +32,7 @@ import com.scwang.smartrefresh.layout.listener.OnRefreshListener ...@@ -32,6 +32,7 @@ import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import com.tbruyelle.rxpermissions2.RxPermissions import com.tbruyelle.rxpermissions2.RxPermissions
import kotlinx.android.synthetic.main.fragment_my.* import kotlinx.android.synthetic.main.fragment_my.*
import me.goldze.mvvmhabit.utils.KLog import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.RxUtils
import me.goldze.mvvmhabit.utils.ToastUtils import me.goldze.mvvmhabit.utils.ToastUtils
import java.util.* import java.util.*
...@@ -90,7 +91,8 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList ...@@ -90,7 +91,8 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
private fun initListener() { private fun initListener() {
//设置登录点击事件 //设置登录点击事件
binding.llMyLogin.setOnClickListener { RxUtils.onMultiClick(binding.llMyLogin){
// binding.llMyLogin.setOnClickListener {
if (!userManager.userIsLogin()) { if (!userManager.userIsLogin()) {
//创建弹窗 //创建弹窗
...@@ -109,7 +111,15 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList ...@@ -109,7 +111,15 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
tv_regist?.setOnClickListener(this) tv_regist?.setOnClickListener(this)
tv_private?.setOnClickListener(this) tv_private?.setOnClickListener(this)
iv_weixin?.setOnClickListener(this) iv_weixin?.setOnClickListener(this)
ly_phone?.setOnClickListener(this) // ly_phone?.setOnClickListener(this)
RxUtils.onMultiClick(ly_phone){
if (cb_checked!!.isChecked) {
startActivity(LoginActivity::class.java)
mBottomSheetDialog!!.dismiss()
} else {
ToastUtils.showShort("请先同意用户协议与隐私政策")
}
}
} }
} }
...@@ -124,8 +134,13 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList ...@@ -124,8 +134,13 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
} }
} }
aboutus.setOnClickListener(this)
moresettings.setOnClickListener(this) RxUtils.onMultiClick(aboutus){
startActivity(AboutusActivity::class.java)
}
RxUtils.onMultiClick(moresettings){
startActivity(MoresettingsActivity::class.java)
}
} }
private fun initView() { private fun initView() {
...@@ -147,13 +162,6 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList ...@@ -147,13 +162,6 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
override fun onClick(v: View?) { override fun onClick(v: View?) {
when (v?.id) { when (v?.id) {
R.id.aboutus -> {
startActivity(AboutusActivity::class.java)
// startActivity(PermissionsActivity::class.java)
}
R.id.moresettings -> {
startActivity(MoresettingsActivity::class.java)
}
R.id.iv_weixin -> { R.id.iv_weixin -> {
if (cb_checked!!.isChecked) { if (cb_checked!!.isChecked) {
// ToastUtils.showShort("未完成微信登录对接") // ToastUtils.showShort("未完成微信登录对接")
...@@ -178,14 +186,14 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList ...@@ -178,14 +186,14 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
ToastUtils.showShort("请先同意用户协议与隐私政策") ToastUtils.showShort("请先同意用户协议与隐私政策")
} }
} }
R.id.ly_phone -> { // R.id.ly_phone -> {
if (cb_checked!!.isChecked) { // if (cb_checked!!.isChecked) {
startActivity(LoginActivity::class.java) // startActivity(LoginActivity::class.java)
mBottomSheetDialog!!.dismiss() // mBottomSheetDialog!!.dismiss()
} else { // } else {
ToastUtils.showShort("请先同意用户协议与隐私政策") // ToastUtils.showShort("请先同意用户协议与隐私政策")
} // }
} // }
R.id.tv_regist -> { R.id.tv_regist -> {
KLog.e("sssss", "点击了《注册协议》") KLog.e("sssss", "点击了《注册协议》")
ToastUtils.showShort("点击了《注册协议》") ToastUtils.showShort("点击了《注册协议》")
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<!-- 边框的颜色和粗细 --> <!-- 边框的颜色和粗细 -->
<stroke <stroke
android:width="1dp" android:width="1dp"
android:color="#C7EDCC" android:color="#03A9F4"
/> />
<solid android:color="#ffffffff" /> <solid android:color="#ffffffff" />
<corners android:radius="10dp" /> <corners android:radius="10dp" />
......
...@@ -104,8 +104,8 @@ ...@@ -104,8 +104,8 @@
<TextView <TextView
android:id="@+id/tv_send_sms" android:id="@+id/tv_send_sms"
android:layout_width="100dp" android:layout_width="120dp"
android:layout_height="30dp" android:layout_height="match_parent"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:gravity="center" android:gravity="center"
......
...@@ -219,8 +219,8 @@ ...@@ -219,8 +219,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_marginBottom="20dp" android:paddingTop="10dp"
android:gravity="bottom|center_horizontal" android:gravity="bottom|center_horizontal"
android:orientation="horizontal"> android:orientation="horizontal">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment