Fix: Add null check for cached subscribe data and update SubscribeData fields
This commit is contained in:
+9
-2
@@ -83,8 +83,15 @@ class ProfileDesign (context: Context) : Design<ProfileDesign.Request>(context)
|
||||
|
||||
if ( APIGlobalObject.subData == null){
|
||||
val gson = Gson()
|
||||
val cached_userSubscritedata = gson.fromJson(PreferenceManager.cached_userSubscritedata, SubscribeResponse::class.java)
|
||||
APIGlobalObject.subData = cached_userSubscritedata.data
|
||||
val cachedStr = PreferenceManager.cached_userSubscritedata
|
||||
if (!cachedStr.isNullOrEmpty()) {
|
||||
try {
|
||||
val cached_userSubscritedata = gson.fromJson(cachedStr, SubscribeResponse::class.java)
|
||||
APIGlobalObject.subData = cached_userSubscritedata?.data
|
||||
} catch (e: Exception) {
|
||||
// 缓存数据格式不匹配,忽略
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.accountEmail = PreferenceManager.loginemail
|
||||
|
||||
|
||||
+9
-6
@@ -350,15 +350,18 @@ data class SubscribeResponse (
|
||||
data class SubscribeData (
|
||||
|
||||
@SerializedName("plan_id") val plan_id : Int?,
|
||||
@SerializedName("token") val token : String,
|
||||
@SerializedName("token") val token : String?,
|
||||
@SerializedName("expired_at") val expired_at : Long?,
|
||||
@SerializedName("u") val u : Long,
|
||||
@SerializedName("d") val d : Long,
|
||||
@SerializedName("u") val u : Long?,
|
||||
@SerializedName("d") val d : Long?,
|
||||
@SerializedName("transfer_enable") val transfer_enable : Long?,
|
||||
@SerializedName("email") val email : String,
|
||||
@SerializedName("uuid") val uuid : String,
|
||||
@SerializedName("email") val email : String?,
|
||||
@SerializedName("uuid") val uuid : String?,
|
||||
@SerializedName("device_limit") val device_limit : Int?,
|
||||
@SerializedName("speed_limit") val speed_limit : Int?,
|
||||
@SerializedName("next_reset_at") val next_reset_at : Long?,
|
||||
@SerializedName("plan") val plan : PlanData?,
|
||||
@SerializedName("subscribe_url") val subscribe_url : String,
|
||||
@SerializedName("subscribe_url") val subscribe_url : String?,
|
||||
@SerializedName("reset_day") val reset_day : String?
|
||||
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user