parent
b407c73ae4
commit
1d80f1be86
11 changed files with 275 additions and 32 deletions
@ -0,0 +1,67 @@ |
|||||||
|
package com.project.survey.ui.login |
||||||
|
|
||||||
|
import androidx.activity.viewModels |
||||||
|
import com.project.survey.databinding.ActivityUpdatePwdBinding |
||||||
|
import com.project.survey.extend.setOnClickNoRepeatListener |
||||||
|
import com.project.survey.extend.smartDismiss |
||||||
|
import com.project.survey.extend.toast |
||||||
|
import com.project.survey.logic.viewmodel.LoginViewModel |
||||||
|
import com.project.survey.ui.base.BaseBindingActivity |
||||||
|
import com.project.survey.util.ActivityNavUtil |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新密码 |
||||||
|
*/ |
||||||
|
class UpdatePwdActivity : BaseBindingActivity<ActivityUpdatePwdBinding>() { |
||||||
|
|
||||||
|
companion object { |
||||||
|
fun start() { |
||||||
|
ActivityNavUtil.startActivity<UpdatePwdActivity> {} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private val viewModel: LoginViewModel by viewModels() |
||||||
|
|
||||||
|
override fun getBinding(): ActivityUpdatePwdBinding = |
||||||
|
ActivityUpdatePwdBinding.inflate(layoutInflater) |
||||||
|
|
||||||
|
|
||||||
|
override fun initView() { |
||||||
|
immersionToolbar(mBinding.toolbar) |
||||||
|
|
||||||
|
viewModel.errorResponse.observe(this) { |
||||||
|
toast(it) |
||||||
|
} |
||||||
|
viewModel.updatePasswordResponse.observe(this) { |
||||||
|
finish() |
||||||
|
toast(it) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun initData() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
override fun initListener() { |
||||||
|
mBinding.btnConfirm.setOnClickNoRepeatListener { |
||||||
|
val oldPassword = mBinding.passwordViewOld.text.takeIf { it.isNotEmpty() } ?: run { |
||||||
|
toast("请输入旧密码") |
||||||
|
return@setOnClickNoRepeatListener |
||||||
|
} |
||||||
|
val newPassword = mBinding.passwordViewOne.text.takeIf { it.isNotEmpty() } ?: run { |
||||||
|
toast("请输入新密码") |
||||||
|
return@setOnClickNoRepeatListener |
||||||
|
} |
||||||
|
val newPassword2 = mBinding.passwordViewTwo.text.takeIf { it.isNotEmpty() } ?: run { |
||||||
|
toast("请输入确认密码") |
||||||
|
return@setOnClickNoRepeatListener |
||||||
|
} |
||||||
|
if (newPassword != newPassword2) { |
||||||
|
toast("新密码输入不一致") |
||||||
|
return@setOnClickNoRepeatListener |
||||||
|
} |
||||||
|
viewModel.updatePassword(oldPassword, newPassword) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,96 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="match_parent" |
||||||
|
android:orientation="vertical"> |
||||||
|
|
||||||
|
<!-- <include layout="@layout/sh_toolbar" />--> |
||||||
|
<com.google.android.material.appbar.MaterialToolbar |
||||||
|
android:id="@+id/toolbar" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="?actionBarSize" |
||||||
|
android:background="@color/transparent" |
||||||
|
app:navigationIcon="@drawable/icon_toolbar_back" |
||||||
|
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" |
||||||
|
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" |
||||||
|
app:titleCentered="true" |
||||||
|
app:titleTextAppearance="@style/ToolbarTextAppearance" /> |
||||||
|
|
||||||
|
<LinearLayout |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginTop="@dimen/sw_12dp" |
||||||
|
android:orientation="vertical" |
||||||
|
android:paddingHorizontal="@dimen/sw_22dp"> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:text="@string/change_pwd" |
||||||
|
android:textColor="@color/text_color_20" |
||||||
|
android:textSize="@dimen/sw_20sp" |
||||||
|
android:textStyle="bold" /> |
||||||
|
|
||||||
|
<!-- <TextView--> |
||||||
|
<!-- android:layout_width="wrap_content"--> |
||||||
|
<!-- android:layout_height="wrap_content"--> |
||||||
|
<!-- android:layout_marginTop="@dimen/sw_6dp"--> |
||||||
|
<!-- android:text="@string/please_enter_new_password"--> |
||||||
|
<!-- android:textColor="@color/text_color_727778"--> |
||||||
|
<!-- android:textSize="@dimen/sw_14sp" />--> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginTop="@dimen/sw_40dp" |
||||||
|
android:text="旧密码" |
||||||
|
android:textColor="@color/text_color_727778" |
||||||
|
android:textSize="@dimen/sw_11sp" /> |
||||||
|
|
||||||
|
<com.project.survey.widget.edittext.PasswordView |
||||||
|
android:id="@+id/passwordViewOld" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" /> |
||||||
|
|
||||||
|
|
||||||
|
<TextView |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginTop="@dimen/sw_24dp" |
||||||
|
android:text="新密码" |
||||||
|
android:textColor="@color/text_color_727778" |
||||||
|
android:textSize="@dimen/sw_11sp" /> |
||||||
|
|
||||||
|
<com.project.survey.widget.edittext.PasswordView |
||||||
|
android:id="@+id/passwordViewOne" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" /> |
||||||
|
|
||||||
|
<TextView |
||||||
|
android:layout_width="wrap_content" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginTop="@dimen/sw_24dp" |
||||||
|
android:text="@string/confirm_password" |
||||||
|
android:textColor="@color/text_color_727778" |
||||||
|
android:textSize="@dimen/sw_11sp" /> |
||||||
|
|
||||||
|
<com.project.survey.widget.edittext.PasswordView |
||||||
|
android:id="@+id/passwordViewTwo" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" /> |
||||||
|
|
||||||
|
<Button |
||||||
|
android:id="@+id/btnConfirm" |
||||||
|
android:layout_width="match_parent" |
||||||
|
android:layout_height="wrap_content" |
||||||
|
android:layout_marginTop="@dimen/sw_60dp" |
||||||
|
android:background="@drawable/bg_btn_login" |
||||||
|
android:text="确认" |
||||||
|
android:textColor="@color/white" |
||||||
|
android:textSize="@dimen/sw_16sp" /> |
||||||
|
|
||||||
|
</LinearLayout> |
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout> |
||||||
Loading…
Reference in new issue