forked from github/szkolny
[APIv2/Librus] Use apply in getting lucky numbers
This commit is contained in:
parent
f79263e628
commit
c03eca3804
@ -25,19 +25,19 @@ class LibrusApiLuckyNumber(override val data: DataLibrus,
|
|||||||
if (json.isJsonNull) {
|
if (json.isJsonNull) {
|
||||||
profile?.luckyNumberEnabled = false
|
profile?.luckyNumberEnabled = false
|
||||||
} else {
|
} else {
|
||||||
profile?.also { profile ->
|
profile?.apply {
|
||||||
profile.luckyNumber = -1
|
luckyNumber = -1
|
||||||
profile.luckyNumberDate = Date.getToday()
|
luckyNumberDate = Date.getToday()
|
||||||
|
|
||||||
json.getJsonObject("LuckyNumber")?.also { luckyNumber ->
|
json.getJsonObject("LuckyNumber")?.also { luckyNumberEl ->
|
||||||
profile.luckyNumber = luckyNumber.getInt("LuckyNumber") ?: -1
|
luckyNumber = luckyNumberEl.getInt("LuckyNumber") ?: -1
|
||||||
profile.luckyNumberDate = Date.fromY_m_d(luckyNumber.getString("LuckyNumberDay"))
|
luckyNumberDate = Date.fromY_m_d(luckyNumberEl.getString("LuckyNumberDay"))
|
||||||
}
|
}
|
||||||
|
|
||||||
data.luckyNumberList.add(LuckyNumber(
|
data.luckyNumberList.add(LuckyNumber(
|
||||||
profileId,
|
profileId,
|
||||||
profile.luckyNumberDate ?: Date.getToday(),
|
luckyNumberDate ?: Date.getToday(),
|
||||||
profile.luckyNumber
|
luckyNumber
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user