diff --git a/login/src/debug/java/login/LoginActivity.kt b/login/src/debug/java/login/LoginActivity.kt index a76a5b1..d199167 100644 --- a/login/src/debug/java/login/LoginActivity.kt +++ b/login/src/debug/java/login/LoginActivity.kt @@ -49,7 +49,7 @@ class LoginActivity : BaseActivity() { LogUtils.i("登录结果:${it}") //将数据保存到数据库里 - DbHelper.insertUserInfo(context, UserInfo(1, LoginRsp(it.id, it.isBindPhone, it.logo_url, it.token, it.username))) + DbHelper.insertUserInfo(context, it) //关闭Activity finish() } diff --git a/login/src/debug/java/login/net/LoginRsp.kt b/login/src/debug/java/login/net/LoginRsp.kt index 165b353..436b8ce 100644 --- a/login/src/debug/java/login/net/LoginRsp.kt +++ b/login/src/debug/java/login/net/LoginRsp.kt @@ -23,4 +23,4 @@ data class RegisterRsp( * 手机号和密码登录 接口响应 * */ //Room类型别名 -typealias LoginRsp = UserInfo.LoginRsp \ No newline at end of file +typealias LoginRsp = UserInfo \ No newline at end of file diff --git a/mine/src/main/java/com/cniao5/mine/MineViewModel.kt b/mine/src/main/java/com/cniao5/mine/MineViewModel.kt index bd2e4e3..77be101 100644 --- a/mine/src/main/java/com/cniao5/mine/MineViewModel.kt +++ b/mine/src/main/java/com/cniao5/mine/MineViewModel.kt @@ -10,6 +10,9 @@ import com.test.service.repo.UserInfo * */ class MineViewModel: BaseViewModel() { + /* + * MutableLiveData:整个实体类或者数据类型变化后才通知.不会细节到某个字段。 + * */ val liveUser = MutableLiveData() } \ No newline at end of file diff --git a/mine/src/main/res/layout/fragment_mine.xml b/mine/src/main/res/layout/fragment_mine.xml index 316105d..450ec82 100644 --- a/mine/src/main/res/layout/fragment_mine.xml +++ b/mine/src/main/res/layout/fragment_mine.xml @@ -35,7 +35,7 @@ app:layout_constraintStart_toStartOf="@id/v_bg_header_mine" app:layout_constraintTop_toTopOf="@id/v_bg_header_mine" app:shapeAppearanceOverlay="@style/circleImageStyle" - app:srcCompat="@{vm.liveUser.loginRsp.logo_url,default=@drawable/icon_default_header}" + app:srcCompat="@{vm.liveUser.logo_url,default=@drawable/icon_default_header}" /> @@ -52,7 +52,7 @@ app:layout_constraintStart_toEndOf="@id/iv_user_icon_mine" app:layout_constraintTop_toTopOf="@id/iv_user_icon_mine" tools:text="菜鸟窝" - android:text="@{vm.liveUser.loginRsp.username??`NameOfNull`}" + android:text="@{vm.liveUser.username??`NameOfNull`}" />