bug修复- 福利界面标题未居中,倒计时未加进去
This commit is contained in:
parent
64aa22a0de
commit
03b5f0fba1
|
|
@ -8,15 +8,12 @@ import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import com.ama.core.architecture.appBase.AppViewsActivity
|
import com.ama.core.architecture.appBase.AppViewsActivity
|
||||||
import com.ama.core.architecture.ext.toast
|
|
||||||
import com.ama.core.architecture.util.AndroidUtil
|
import com.ama.core.architecture.util.AndroidUtil
|
||||||
import com.ama.core.architecture.util.ResUtil
|
import com.ama.core.architecture.util.ResUtil
|
||||||
import com.ama.core.architecture.util.eventbus.NotifyMan
|
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
|
||||||
import com.gamedog.vididin.VidiConst
|
import com.gamedog.vididin.VidiConst
|
||||||
import com.vididin.real.money.game.R
|
import com.vididin.real.money.game.R
|
||||||
import com.gamedog.vididin.VididinEvents
|
import com.gamedog.vididin.VididinEvents
|
||||||
import com.gamedog.vididin.core.login.login.AccountManager
|
|
||||||
import com.gamedog.vididin.features.benefit.widget.BenefitTaskItemView
|
import com.gamedog.vididin.features.benefit.widget.BenefitTaskItemView
|
||||||
import com.gamedog.vididin.main.fragments.task.DailySignDialog
|
import com.gamedog.vididin.main.fragments.task.DailySignDialog
|
||||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
package com.gamedog.vididin.features.benefit.widget
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.CountDownTimer
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import com.ama.core.architecture.util.DateUtil
|
||||||
|
import com.gamedog.vididin.manager.TaskManager
|
||||||
|
import com.vididin.real.money.game.databinding.BenefitCountdownTimerViewBinding
|
||||||
|
|
||||||
|
|
||||||
|
class CounterDownTimerView @JvmOverloads constructor(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
|
defStyleAttr: Int = 0
|
||||||
|
) : LinearLayout(context, attrs, defStyleAttr) {
|
||||||
|
private lateinit var mTimer: CountDownTimer
|
||||||
|
private var mBinding: BenefitCountdownTimerViewBinding
|
||||||
|
|
||||||
|
|
||||||
|
init {
|
||||||
|
mBinding = BenefitCountdownTimerViewBinding.inflate(LayoutInflater.from(context), this, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onAttachedToWindow() {
|
||||||
|
super.onAttachedToWindow()
|
||||||
|
startTimer()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startTimer() {
|
||||||
|
val startMs = TaskManager.instance().boxTaskStatus().getAllBoxStartTimeMs()
|
||||||
|
val totalMs = TaskManager.instance().boxTaskStatus().getAllBoxTotalDurationMs()
|
||||||
|
|
||||||
|
val restMs = startMs + totalMs - System.currentTimeMillis()
|
||||||
|
|
||||||
|
mTimer = object : CountDownTimer(restMs, 1000) {
|
||||||
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
|
val resultList = DateUtil.formatMs2HMS(millisUntilFinished)
|
||||||
|
mBinding.tvHour.text = resultList[0].toString()
|
||||||
|
mBinding.tvMin.text = resultList[1].toString()
|
||||||
|
mBinding.tvSecond.text = resultList[2].toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFinish() {
|
||||||
|
}
|
||||||
|
}.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDetachedFromWindow() {
|
||||||
|
super.onDetachedFromWindow()
|
||||||
|
if (mTimer != null) {
|
||||||
|
mTimer.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -148,6 +148,18 @@ class BoxTaskHelper: BaseTaskHelper<TaskStateBoxRoot, BoxTaskRoot>() {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getAllBoxTotalDurationMs(): Long {
|
||||||
|
var totalDays = 0L
|
||||||
|
mStateBean.tasks.forEach {
|
||||||
|
totalDays += it.duration_days
|
||||||
|
}
|
||||||
|
return totalDays * 24 * 3600000
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getAllBoxStartTimeMs(): Long {
|
||||||
|
return mStateBean.startMs
|
||||||
|
}
|
||||||
|
|
||||||
fun isBoxAllFinished(boxIndex: Int) : Boolean {
|
fun isBoxAllFinished(boxIndex: Int) : Boolean {
|
||||||
val stateEnum = getBoxStateEnum(boxIndex)
|
val stateEnum = getBoxStateEnum(boxIndex)
|
||||||
return stateEnum == STATE_FINISH || stateEnum == STATE_CLAIMED
|
return stateEnum == STATE_FINISH || stateEnum == STATE_CLAIMED
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape android:shape="rectangle"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<stroke android:width="2dp" android:color="#ffffffff" />
|
||||||
|
<solid android:color="#ffffd3d3" />
|
||||||
|
<corners android:topLeftRadius="5dp" android:topRightRadius="5dp" android:bottomLeftRadius="5dp" android:bottomRightRadius="5dp" />
|
||||||
|
</shape>
|
||||||
|
|
||||||
|
|
@ -60,11 +60,17 @@
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
<com.gamedog.vididin.features.benefit.widget.CounterDownTimerView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_centerInParent="true">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_hour"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="hour"
|
||||||
|
android:background="@drawable/bg_benefit_timer_item"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/red_28"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_min"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:layout_marginHorizontal="@dimen/dp20"
|
||||||
|
android:text="min"
|
||||||
|
android:background="@drawable/bg_benefit_timer_item"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/red_28"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_second"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:text="sec"
|
||||||
|
android:background="@drawable/bg_benefit_timer_item"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/red_28"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
@ -215,6 +215,18 @@ class DateUtil private constructor() {
|
||||||
return ((calendarCurrent.timeInMillis - calendarStart.timeInMillis) / MS_NUM_ONE_DAY).toInt()
|
return ((calendarCurrent.timeInMillis - calendarStart.timeInMillis) / MS_NUM_ONE_DAY).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun formatMs2HMS(msNum: Long): List<Long> {
|
||||||
|
val resultList = mutableListOf<Long>()
|
||||||
|
val hours = msNum / (3600000)
|
||||||
|
val minute = (msNum - hours * 3600000) / (60000)
|
||||||
|
val second = (msNum - hours * 3600000 - minute * 60000) / (1000)
|
||||||
|
|
||||||
|
resultList.add(hours)
|
||||||
|
resultList.add(minute)
|
||||||
|
resultList.add(second)
|
||||||
|
return resultList
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue