第一次 识别并保存 之前参加过的项目
This commit is contained in:
parent
e28606c7d8
commit
04b35f09a0
|
|
@ -102,6 +102,8 @@ class ZeroBuyViewModel : ViewModel() {
|
|||
respObj?.user_id?.let {
|
||||
if (userId <= 0) {
|
||||
AccountManager.saveUserIdInfo(it)
|
||||
|
||||
saveHasJoinedZeroIds(it, respObj.current_purchases)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,5 +118,18 @@ class ZeroBuyViewModel : ViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun saveHasJoinedZeroIds(userId: Int, currentPurchases: List<ZeroBuyItem>) {
|
||||
val joinZeroBuyItemIds = SpUtil.instance().getList<Int>(SpUtil.KEY_ZEROBUY_JOINED_ACTIVITY_IDS).toMutableList()
|
||||
currentPurchases.forEach { zero ->
|
||||
zero.current_users?.let {
|
||||
if (it.contains(userId) && !joinZeroBuyItemIds.contains(userId)) {
|
||||
joinZeroBuyItemIds.add(zero.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SpUtil.instance().putList(SpUtil.KEY_ZEROBUY_JOINED_ACTIVITY_IDS, joinZeroBuyItemIds)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue