Commit f3d5c09a authored by 杨秀秀's avatar 杨秀秀

基础搭建

1:XxesitForm添加定义InputType 功能
功能开发
1:完善登陆功能
parent 1eed022f
......@@ -13,6 +13,7 @@
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/consumer" />
<option value="$PROJECT_DIR$/dsbridge" />
<option value="$PROJECT_DIR$/hbhbcompany" />
<option value="$PROJECT_DIR$/mvvmhabit" />
<option value="$PROJECT_DIR$/xxviewlibrary" />
......
......@@ -61,6 +61,7 @@ dependencies {
implementation 'androidx.navigation:navigation-ui-ktx:2.5.2'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
implementation project(path: ':dsbridge')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
......
......@@ -122,6 +122,10 @@
<activity android:name=".ui.appeallist.AppealListActivity"
android:exported="true"/>
<!--H5展示-->
<activity android:name=".ui.web.CommWabActivity"
android:exported="true"/>
<!-- 适配标准 -->
<meta-data
android:name="design_width_in_dp"
......
package com.xx.merchanthbh.ui.login
import android.os.Bundle
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.TextPaint
import android.text.style.ClickableSpan
import android.text.style.ForegroundColorSpan
import android.view.View
import com.xx.merchanthbh.BR
import com.xx.merchanthbh.R
import com.xx.merchanthbh.databinding.ActivityLoginBinding
import com.xx.merchanthbh.data.http.requst.LoginRequest
import com.xx.merchanthbh.databinding.ActivityLoginBinding
import me.goldze.mvvmhabit.base.BaseActivity
class LoginActivity() : BaseActivity<ActivityLoginBinding, LoginViewModel>() {
......@@ -23,6 +29,55 @@ class LoginActivity() : BaseActivity<ActivityLoginBinding, LoginViewModel>() {
override fun initData() {
super.initData()
if (viewModel.isAgree)
{
binding.ivLoginAgreement.setImageDrawable(getDrawable(R.mipmap.login_icon_xuanze2))
}else{
binding.ivLoginAgreement.setImageDrawable(getDrawable(R.mipmap.login_icon_xuanze1))
}
binding.ivLoginAgreement.setOnClickListener()
{
if (viewModel.isAgree)
{
viewModel.isAgree=false
binding.ivLoginAgreement.setImageDrawable(getDrawable(R.mipmap.login_icon_xuanze1))
}else{
viewModel.isAgree=true
binding.ivLoginAgreement.setImageDrawable(getDrawable(R.mipmap.login_icon_xuanze2))
}
}
var sp:SpannableStringBuilder= SpannableStringBuilder("我已阅读并同意《用户协议》、《隐私条款》")
// sp.setSpan(ForegroundColorSpan(getColor(R.color.text_grey_blue)),7,20,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
sp.setSpan(object : ClickableSpan() {
override fun onClick(view: View) {
}
override fun updateDrawState(ds: TextPaint) {
ds.setColor(getColor(R.color.text_grey_blue))
ds.isUnderlineText=false
}
},7,13,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
sp.setSpan(object : ClickableSpan() {
override fun onClick(view: View) {
}
override fun updateDrawState(ds: TextPaint) {
ds.setColor(getColor(R.color.text_grey_blue))
ds.isUnderlineText=false
}
},14,20,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
binding.tvLoginAgree.text=sp
}
......
......@@ -5,6 +5,8 @@ import static me.goldze.mvvmhabit.utils.Utils.Interceptor_TOKEN;
import android.app.Application;
import android.os.Bundle;
import android.text.TextUtils;
import android.text.style.ClickableSpan;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
......@@ -35,6 +37,8 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> {
//密码的绑定
public ObservableField<String> password = new ObservableField<>("");
public boolean isAgree=false;
public LoginViewModel(@NonNull Application application, LoginRequest model) {
super(application, model);
}
......@@ -70,13 +74,19 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> {
public BindingCommand login = new BindingCommand(new BindingAction() {
@Override
public void call() {
if (!isAgree)
{
ToastUtils.showShort("请阅读并同意协议");
return;
}
if (TextUtils.isEmpty(userName.get().toString())) {
ToastUtils.showShort("请输入账号!");
} else if (TextUtils.isEmpty(password.get().toString())) {
ToastUtils.showShort("请输入密码!");
} else {
model.Login(/*userName.get().toString(), password.get().toString()*/"13922222222","123456")
model.Login(userName.get().toString(), password.get().toString())
.compose(RxUtils.schedulersTransformer()) //线程调度
// .compose(RxUtils.exceptionTransformer()) // 网络错误的异常转换, 这里可以换成自己的ExceptionHandle
.doOnSubscribe(LoginViewModel.this)
......@@ -106,6 +116,8 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> {
public void getuserInfo() {
model.getUserInfo()
.compose(RxUtils.schedulersTransformer()) //线程调度
// .compose(RxUtils.exceptionTransformer()) // 网络错误的异常转换, 这里可以换成自己的ExceptionHandle
......
......@@ -197,6 +197,12 @@ public class MerchantEnterViewModel extends BaseViewModel<MerchantEnterRequst> {
*/
public void register(View view)
{
if (!pwds.get().equals(registerBody.oPassword.get()))
{
ToastUtils.showShort("两次密码输入不一致!");
return;
}
model.register(registerBody)
.compose(RxUtils.schedulersTransformer()) //线程调度
.doOnSubscribe(MerchantEnterViewModel.this)
......
package com.xx.merchanthbh.ui.web
import android.os.Bundle
import com.xx.merchanthbh.BR
import com.xx.merchanthbh.R
import com.xx.merchanthbh.databinding.ActivityCommWebBinding
import me.goldze.mvvmhabit.base.BaseActivity
class CommWabActivity : BaseActivity<ActivityCommWebBinding, CommWebViewModel>() {
override fun initParam() {
super.initParam()
}
override fun initContentView(savedInstanceState: Bundle?): Int {
return R.layout.activity_comm_web
}
override fun initVariableId(): Int {
return BR.viewModel
}
override fun initData() {
super.initData()
viewModel.url=intent.getStringExtra("url")
viewModel.title.set(intent.getStringExtra("title"))
}
}
\ No newline at end of file
package com.xx.merchanthbh.ui.web;
import android.app.Application;
import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;
import com.xx.merchanthbh.data.http.BaseRespons;
import me.goldze.mvvmhabit.base.BaseViewModel;
public class CommWebViewModel extends BaseViewModel<BaseRespons> {
public String url="";
public ObservableField<String> title = new ObservableField<>("");
public CommWebViewModel(@NonNull Application application) {
super(application);
}
}
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:binding="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="com.xx.merchanthbh.ui.web.CommWebViewModel" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg_grey"
android:fitsSystemWindows="true"
android:orientation="vertical">
<com.xx.xxviewlibrary.witget.XxBar
android:layout_width="match_parent"
android:layout_height="55dp"
app:bar_title='@{@string/appeal_manager}' />
<wendu.dsbridge.DWebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/web_comm"/>
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -145,10 +145,11 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="我已阅读并同意《用户协议》、《隐私条款》以及《中国移动认证服务条款》"
android:text="我已阅读并同意《用户协议》、《隐私条款》"
app:layout_constraintLeft_toRightOf="@+id/iv_login_agreement"
android:layout_marginLeft="7dp"
app:layout_constraintRight_toRightOf="parent"
android:id="@+id/tv_login_agree"
app:layout_constraintTop_toTopOf="@+id/iv_login_agreement"/>
......
......@@ -76,6 +76,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
ed_content="@={viewModel.registerBody.oPassword}"
app:inputType="textPassword"
ed_title='@{"登录密码"}'
/>
<com.xx.xxviewlibrary.witget.XxFormEdit
......@@ -83,6 +84,7 @@
android:layout_height="wrap_content"
ed_title='@{"确认密码"}'
ed_content="@={viewModel.pwds}"
app:inputType="textPassword"
app:isBottom="true"
/>
......
......@@ -59,6 +59,7 @@ dependencies {
implementation 'androidx.navigation:navigation-ui-ktx:2.5.2'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
implementation project(path: ':dsbridge')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
......
......@@ -57,6 +57,7 @@ dependencies {
implementation 'androidx.navigation:navigation-ui-ktx:2.5.2'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
implementation project(path: ':dsbridge')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
......
package com.xx.hbhbcompany.ui.login
import android.os.Bundle
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.TextPaint
import android.text.style.ClickableSpan
import android.view.View
import com.xx.hbhbcompany.R
import com.xx.hbhbcompany.BR
import com.xx.hbhbcompany.data.http.requst.LoginRequest
......@@ -23,6 +28,55 @@ class LoginActivity() : BaseActivity<ActivityLoginBinding, LoginViewModel>() {
override fun initData() {
super.initData()
if (viewModel.isAgree)
{
binding.ivLoginAgreement.setImageDrawable(getDrawable(R.mipmap.login_icon_xuanze2))
}else{
binding.ivLoginAgreement.setImageDrawable(getDrawable(R.mipmap.login_icon_xuanze1))
}
binding.ivLoginAgreement.setOnClickListener()
{
if (viewModel.isAgree)
{
viewModel.isAgree=false
binding.ivLoginAgreement.setImageDrawable(getDrawable(R.mipmap.login_icon_xuanze1))
}else{
viewModel.isAgree=true
binding.ivLoginAgreement.setImageDrawable(getDrawable(R.mipmap.login_icon_xuanze2))
}
}
var sp: SpannableStringBuilder = SpannableStringBuilder("我已阅读并同意《用户协议》、《隐私条款》")
// sp.setSpan(ForegroundColorSpan(getColor(R.color.text_grey_blue)),7,20,Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
sp.setSpan(object : ClickableSpan() {
override fun onClick(view: View) {
}
override fun updateDrawState(ds: TextPaint) {
ds.setColor(getColor(R.color.text_grey_blue))
ds.isUnderlineText=false
}
},7,13, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
sp.setSpan(object : ClickableSpan() {
override fun onClick(view: View) {
}
override fun updateDrawState(ds: TextPaint) {
ds.setColor(getColor(R.color.text_grey_blue))
ds.isUnderlineText=false
}
},14,20, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
binding.tvLoginAgree.text=sp
}
......
......@@ -35,6 +35,7 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> {
//密码的绑定
public ObservableField<String> password = new ObservableField<>("");
public boolean isAgree=false;
public LoginViewModel(@NonNull Application application, LoginRequest model) {
super(application, model);
}
......@@ -52,6 +53,13 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> {
public BindingCommand login = new BindingCommand(new BindingAction() {
@Override
public void call() {
if (!isAgree)
{
ToastUtils.showShort("请阅读并同意协议");
return;
}
if (TextUtils.isEmpty(userName.get().toString())) {
ToastUtils.showShort("请输入账号!");
......
......@@ -134,9 +134,9 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="14sp"
android:text="我已阅读并同意《用户协议》、《隐私条款》以及《中国移动认证服务条款》"
app:layout_constraintLeft_toRightOf="@+id/iv_login_agreement"
android:layout_marginLeft="7dp"
android:id="@+id/tv_login_agree"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/iv_login_agreement"/>
......
......@@ -9,6 +9,8 @@
<color name="black">#222222</color>
<color name="white">#FFFFFFFF</color>
<color name="line_grey">#eeeeee</color>
<color name="text_grey_blue">#6076A6</color>
<color name="bg_grey">#F5F5F5</color>
<color name="light_blue_50">#FFE1F5FE</color>
......
......@@ -157,6 +157,7 @@ public class BaseViewModel<M extends BaseModel> extends AndroidViewModel impleme
{
Map<String, Object> photomap = new HashMap<>();
photomap.put("hasCamera", hasCamera);
photomap.put("maxCount", 1);
if (callback != null) {
photomap.put("callBack", callback);
}
......
......@@ -22,3 +22,4 @@ include ':app', ':mvvmhabit'
include ':xxviewlibrary'
include ':hbhbcompany'
include ':consumer'
include ':dsbridge'
......@@ -65,4 +65,5 @@ dependencies {
api rootProject.ext.dependencies["SmartRefreshBase"]
api rootProject.ext.dependencies["SmartRefreshHeader"]
api rootProject.ext.dependencies["SmartRefreshFooter"]
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.xx.xxviewlibrary.witget
import android.content.Context
import android.content.res.TypedArray
import android.text.Editable
import android.text.InputType
import android.text.TextUtils
import android.text.TextWatcher
import android.util.AttributeSet
......@@ -17,6 +18,7 @@ import androidx.databinding.InverseBindingAdapter
import androidx.databinding.InverseBindingListener
import com.xx.xxviewlibrary.R
class XxFormEdit constructor(context: Context?, attrs: AttributeSet?) : ConstraintLayout(context!!, attrs ) {
//标题
var tv_title: TextView? = null
......@@ -139,16 +141,20 @@ class XxFormEdit constructor(context: Context?, attrs: AttributeSet?) : Constra
v_line = view.findViewById(R.id.v_wxe_line)
tv_necessary = view.findViewById(R.id.tv_wxe_necessary)
iv_select = view.findViewById<ImageView>(R.id.iv_wxe_select)
if(attrs!=null)
{
var typedArray: TypedArray =
context.obtainStyledAttributes(attrs, R.styleable.xxFormEditStyle)
if (typedArray.getBoolean(R.styleable.xxFormEditStyle_isBottom, false)) {
v_line?.visibility = GONE
} else {
v_line?.visibility = VISIBLE
}
if (typedArray.getBoolean(R.styleable.xxFormEditStyle_necessary, true)) {
tv_necessary?.visibility = VISIBLE
} else {
......@@ -161,6 +167,9 @@ class XxFormEdit constructor(context: Context?, attrs: AttributeSet?) : Constra
tv_content?.visibility = GONE
iv_select?.visibility = GONE
et_contents?.visibility = GONE
et_content?.inputType=typedArray.getInt(R.styleable.xxFormEditStyle_inputType,
InputType.TYPE_CLASS_TEXT or InputType.TYPE_NUMBER_FLAG_DECIMAL)
et_content?.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
......
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