Commit 8a206296 by konghaorui

UserRouterImpl 模块增加判空、升级版本

parent 85cfa249
......@@ -42,13 +42,13 @@ ext {
ydlPublishVersion = [
// -------------- 业务模块 --------------
//第三步 若干
"m-confide" : "0.0.16",
"m-consultant" : "0.0.23",
"m-course" : "0.0.9",
"m-fm" : "0.0.12",
"m-muse" : "0.0.8",
"m-tests" : "0.0.5",
"m-user" : "0.0.26",
"m-confide" : "0.0.18",
"m-consultant" : "0.0.25",
"m-course" : "0.0.11",
"m-fm" : "0.0.14",
"m-muse" : "0.0.10",
"m-tests" : "0.0.7",
"m-user" : "0.0.28",
//-------------- 业务模块 API 层 --------------
"m-audioim-api" : "0.0.1",
"m-confide-api" : "0.0.1",
......@@ -57,18 +57,18 @@ ext {
"m-fm-api" : "0.0.2",
"m-muse-api" : "0.0.1",
"m-tests-api" : "0.0.1",
"m-user-api" : "0.0.5",
"m-user-api" : "0.0.7",
//-------------- 功能组件 --------------
//第一步
"ydl-platform" : "0.0.22",
"ydl-platform" : "0.0.24",
//第二步 若干
"ydl-webview" : "0.0.21",
"ydl-media" : "0.0.10",
"ydl-pay" : "0.0.7",
"m-audioim" : "0.0.13",
"ydl-webview" : "0.0.24",
"ydl-media" : "0.0.12",
"ydl-pay" : "0.0.9",
"m-audioim" : "0.0.15",
//以下 几乎不会动
"router" : "0.0.1",
"ydl-net" : "0.0.1",
"ydl-net" : "0.0.2",
"ydl-utils" : "0.0.2",
"ydl-flutter-base": "0.0.3",
]
......@@ -91,18 +91,18 @@ ext {
"m-fm-api" : "0.0.2",
"m-muse-api" : "0.0.1",
"m-tests-api" : "0.0.1",
"m-user-api" : "0.0.5",
"m-user-api" : "0.0.7",
//-------------- 功能组件 --------------
//第一步
"ydl-platform" : "0.0.21",
"ydl-platform" : "0.0.24",
//第二步 若干
"ydl-webview" : "0.0.21",
"ydl-media" : "0.0.10",
"ydl-pay" : "0.0.7",
"m-audioim" : "0.0.13",
"ydl-webview" : "0.0.24",
"ydl-media" : "0.0.12",
"ydl-pay" : "0.0.9",
"m-audioim" : "0.0.15",
//以下 几乎不会动
"router" : "0.0.1",
"ydl-net" : "0.0.1",
"ydl-net" : "0.0.2",
"ydl-utils" : "0.0.2",
"ydl-flutter-base": "0.0.3",
]
......@@ -235,10 +235,10 @@ ext {
"imagepicker" : "com.ydl:imagepicker:1.0.6",
"protector" : "com.ydl:protector:1.0.1-SNAPSHOT@aar",
"ydl-hnet" : "com.ydl:h-net:0.0.8",
"ydl-utils" : "com.ydl:ydl-utils:0.0.2",
"ydl-net" : "com.ydl:ydl-net:0.0.1",
"ydl-user-router" : "com.ydl:router:1.0.0-SNAPSHOT@aar",
"ydl-device" : "com.ydl:device-id:0.0.7@aar",
"ydl-net" : "com.ydl:ydl-net:${ydlCompileVersion["ydl-net"]}",
"ydl-utils" : "com.ydl:ydl-utils:${ydlCompileVersion["ydl-utils"]}",
//flutter功能组件升级===>发布ydl-flutter-base组件===>引用flutter相关的业务模块
"ydl-flutter" : "com.ydl:ydl-flutter:0.0.7@aar",
......
......@@ -24,7 +24,7 @@ modular {
groupId = "com.ydl"
artifactId = "m-user-api"
//开发时注释掉版本号,发布api时打开
version = rootProject.ext.ydlPublishVersion[childProject.getName()+"-api"]
//version = rootProject.ext.ydlPublishVersion[childProject.getName()+"-api"]
// API 层打包时需要引入的依赖
apiDependencies {
implementation "com.google.code.gson:gson:2.8.2"
......
......@@ -64,9 +64,8 @@ object UserHelper {
try {
return SharedPreferencesEditor.getFileString(user_info_name_sp, user_info_key_sp)
} catch (e: Exception) {
userTemp = UserResponseBean()
return ""
}
return gson.toJson(userTemp)
}
fun updateUserinfo(userInfo: UserResponseBean.UserInfo?) {
......@@ -139,8 +138,7 @@ object UserHelper {
try {
return SharedPreferencesEditor.getFileString(user_setting_name_sp, user_setting_key_sp)
} catch (e: Exception) {
userSetting = UserSettingBean()
return ""
}
return gson.toJson(userSetting)
}
}
\ No newline at end of file
......@@ -27,16 +27,26 @@ import com.yidianling.user.ui.login.RegisterAndLoginActivity
class UserRouterImp : IUserRouter {
val gson: Gson = Gson()
override fun getUserSetting(): UserSetting {
return gson.fromJson(UserHelper.getUserSettingStr(), UserSetting::class.java)
override fun getUserSetting(): UserSetting? {
var infoStr = UserHelper.getUserSettingStr()
if (TextUtils.isEmpty(infoStr)){
return null
}
return gson.fromJson(infoStr, UserSetting::class.java)
}
override fun updateUserInfoSp(userInfo: UserResponse.UserInfo?) {
val info:UserResponseBean.UserInfo = gson.fromJson(gson.toJson(userInfo), UserResponseBean.UserInfo::class.java)
if (userInfo==null){
return
}
val info:UserResponseBean.UserInfo = gson.fromJson( gson.toJson(userInfo), UserResponseBean.UserInfo::class.java)
UserHelper.updateUserinfo(info)
}
override fun updateUserSetingSp(userSetting: UserSetting?) {
if (userSetting==null){
return
}
val info:UserSettingBean= gson.fromJson(gson.toJson(userSetting), UserSettingBean::class.java)
UserHelper.updateUserSetting(info)
}
......@@ -50,8 +60,12 @@ class UserRouterImp : IUserRouter {
UserHelper.setUserinfo(info)
}
override fun getUserResponse(): UserResponse {
return gson.fromJson(UserHelper.getUserInfoStr(), UserResponse::class.java)
override fun getUserResponse(): UserResponse? {
var infoStr = UserHelper.getUserInfoStr()
if (TextUtils.isEmpty(infoStr)){
return null
}
return gson.fromJson(infoStr,UserResponse::class.java)
}
override fun isLogin(): Boolean {
......
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