更新观看完成一个视频后更新 UI
This commit is contained in:
parent
63d636ff1a
commit
dc7ff87e33
|
|
@ -175,6 +175,19 @@ class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateDailyWatchUI() {
|
||||||
|
/*binding?.tvCashTotal?.text = buildString {
|
||||||
|
append(ResUtil.getString(R.string.cash))
|
||||||
|
append(" ")
|
||||||
|
append(AccountManager.getCash())
|
||||||
|
}*/
|
||||||
|
|
||||||
|
val statusBean = TaskManager.instance().dailyWatchStatus().getStatus()
|
||||||
|
mDailyWatchVideoTaskViewList.forEachIndexed { index, view ->
|
||||||
|
view.updateProgress(statusBean.getTodayWatchedCount())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateUIGoldTotal() {
|
private fun updateUIGoldTotal() {
|
||||||
binding?.tvGoldTotal?.text = AccountManager.getGold().toString()
|
binding?.tvGoldTotal?.text = AccountManager.getGold().toString()
|
||||||
}
|
}
|
||||||
|
|
@ -193,8 +206,13 @@ class TasksFragment : AppViewsFragment<ViewBinding, UiState, ViewModel>(), OnTab
|
||||||
VididinEvents.Event_Account_Cash_Changed -> {
|
VididinEvents.Event_Account_Cash_Changed -> {
|
||||||
updateUICashTotal()
|
updateUICashTotal()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VididinEvents.Event_Toady_Watched_Total -> {
|
||||||
|
updateDailyWatchUI()
|
||||||
}
|
}
|
||||||
}, VididinEvents.Event_Sign_State_Changed, VididinEvents.Event_Account_Cash_Changed, VididinEvents.Event_Account_Gold_Changed)
|
}
|
||||||
|
}, VididinEvents.Event_Sign_State_Changed, VididinEvents.Event_Account_Cash_Changed,
|
||||||
|
VididinEvents.Event_Account_Gold_Changed, VididinEvents.Event_Toady_Watched_Total)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateDailySignButUI() {
|
private fun updateDailySignButUI() {
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class DailyTaskItemView @JvmOverloads constructor(
|
||||||
fun updateProgress(finishVideoNum: Int) {
|
fun updateProgress(finishVideoNum: Int) {
|
||||||
val showWatchedNum = if (finishVideoNum > mNeedWatchTotal) mNeedWatchTotal else finishVideoNum
|
val showWatchedNum = if (finishVideoNum > mNeedWatchTotal) mNeedWatchTotal else finishVideoNum
|
||||||
mBinding.tvItemProgress.text = "($showWatchedNum/$mNeedWatchTotal)"
|
mBinding.tvItemProgress.text = "($showWatchedNum/$mNeedWatchTotal)"
|
||||||
mBinding.itemProgress.setProgress(showWatchedNum/mNeedWatchTotal)
|
mBinding.itemProgress.setProgress(100*showWatchedNum/mNeedWatchTotal)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,9 @@ abstract class BaseTaskHelper<T: Any> {
|
||||||
SpUtil.instance().putObject(mSpKey, mStateBean)
|
SpUtil.instance().putObject(mSpKey, mStateBean)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getStatus() : T {
|
||||||
|
return mStateBean
|
||||||
|
}
|
||||||
|
|
||||||
fun release() {
|
fun release() {
|
||||||
NotifyMan.instance().unregister(mEventCallback)
|
NotifyMan.instance().unregister(mEventCallback)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class DailyWatchVideoTaskHelper : BaseTaskHelper<DailyStateWatchVideoBean>() {
|
||||||
|
|
||||||
override fun loadTaskFromSp() {
|
override fun loadTaskFromSp() {
|
||||||
val spStateBean = SpUtil.instance().getObject<DailyStateWatchVideoBean>(mSpKey)
|
val spStateBean = SpUtil.instance().getObject<DailyStateWatchVideoBean>(mSpKey)
|
||||||
if (spStateBean == null || !isCurBeanInToday(spStateBean)) {
|
if (spStateBean == null || !isTodayStatusBean(spStateBean)) {
|
||||||
generateTodayTask()
|
generateTodayTask()
|
||||||
saveState2Sp()
|
saveState2Sp()
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -41,7 +41,7 @@ class DailyWatchVideoTaskHelper : BaseTaskHelper<DailyStateWatchVideoBean>() {
|
||||||
mStateBean = DailyStateWatchVideoBean(DateUtil.getCurTimeMs())
|
mStateBean = DailyStateWatchVideoBean(DateUtil.getCurTimeMs())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isCurBeanInToday(stateBean: DailyStateWatchVideoBean): Boolean {
|
private fun isTodayStatusBean(stateBean: DailyStateWatchVideoBean): Boolean {
|
||||||
return DateUtil.isToday(stateBean.todayStartMs)
|
return DateUtil.isToday(stateBean.todayStartMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,7 +49,7 @@ class DailyWatchVideoTaskHelper : BaseTaskHelper<DailyStateWatchVideoBean>() {
|
||||||
private fun handleVideoWatched(dataPair: Pair<String, Long>) {
|
private fun handleVideoWatched(dataPair: Pair<String, Long>) {
|
||||||
mStateBean.run {
|
mStateBean.run {
|
||||||
addWatchedVideoInfo(dataPair)
|
addWatchedVideoInfo(dataPair)
|
||||||
|
notifyEvents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@ data class DailyStateWatchVideoBean(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun getTodayWatchedCount(): Int {
|
||||||
|
return mWatchedMap.size
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue