This commit is contained in:
parent
a0ee013152
commit
06fc43a454
|
|
@ -28,6 +28,9 @@ data class ZeroBuyItem (
|
||||||
val winners: List<Int>? = null,
|
val winners: List<Int>? = null,
|
||||||
val redeem_code: String? = null,
|
val redeem_code: String? = null,
|
||||||
val completed: Boolean = false,
|
val completed: Boolean = false,
|
||||||
|
|
||||||
|
// Not from server
|
||||||
|
var mCountDownTimeStr: String = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.gamedog.vididin.features.zero
|
package com.gamedog.vididin.features.zero
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.CountDownTimer
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
|
@ -27,6 +28,42 @@ class ZeroItemAdapter(private val joinCallback: (itemId: Int)->Unit) : ListAdapt
|
||||||
holder.bind(getItem(position))
|
holder.bind(getItem(position))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getJoinedIdList(): List<Int> {
|
||||||
|
return SpUtil.instance().getList<Int>(SpUtil.KEY_ZEROBUY_JOINED_ACTIVITY_IDS)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startCountDownTimer(targetTimeMs: Long) {
|
||||||
|
val countDownDuration = targetTimeMs - System.currentTimeMillis()
|
||||||
|
|
||||||
|
val mCountDownTimer = object : CountDownTimer(countDownDuration, 1000) {
|
||||||
|
override fun onTick(millisUntilFinished: Long) {
|
||||||
|
val joinedIds = getJoinedIdList()
|
||||||
|
|
||||||
|
currentList.forEach { item->
|
||||||
|
if (joinedIds.contains(item.id) && !item.completed) {
|
||||||
|
var remainSec = (item.end_time - System.currentTimeMillis()) / 1000
|
||||||
|
//item.mCountDownTimeStr =
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*long totalSeconds = millisUntilFinished / 1000;
|
||||||
|
long minutes = totalSeconds / 60;
|
||||||
|
long seconds = totalSeconds % 60;
|
||||||
|
String timeText = String . format ("%02d:%02d", minutes, seconds);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onFinish() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mCountDownTimer.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun submitList(list: List<ZeroBuyItem?>?) {
|
||||||
|
val sortedList = list?.sortedBy { it?.end_time }
|
||||||
|
super.submitList(sortedList)
|
||||||
|
}
|
||||||
|
|
||||||
inner class ViewHolder(private val binding: ViewBinding) : RecyclerView.ViewHolder(binding.root) {
|
inner class ViewHolder(private val binding: ViewBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||||
fun bind(item: ZeroBuyItem) {
|
fun bind(item: ZeroBuyItem) {
|
||||||
binding.tvTitle.text = item.title
|
binding.tvTitle.text = item.title
|
||||||
|
|
@ -50,12 +87,12 @@ class ZeroItemAdapter(private val joinCallback: (itemId: Int)->Unit) : ListAdapt
|
||||||
|
|
||||||
|
|
||||||
// judge state
|
// judge state
|
||||||
val joinedIds = SpUtil.instance().getList<Int>(SpUtil.KEY_ZEROBUY_JOINED_ACTIVITY_IDS)
|
val joinedIds = getJoinedIdList()
|
||||||
val hasJoined = joinedIds.contains(item.id)
|
val hasJoined = joinedIds.contains(item.id)
|
||||||
val hasCompleted = item.completed
|
val hasCompleted = item.completed
|
||||||
flBottomBut.isVisible = !hasJoined
|
flBottomBut.isVisible = !hasJoined
|
||||||
tvParticipateAlready.isVisible = hasJoined
|
tvParticipateAlready.isVisible = hasJoined
|
||||||
tvRemainTime.isVisible = hasJoined && !hasCompleted
|
//tvRemainTime.isVisible = hasJoined && !hasCompleted
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ android:layout_height="wrap_content" >
|
||||||
android:paddingTop="15dp"
|
android:paddingTop="15dp"
|
||||||
android:background="@drawable/zero_bg_4_items"
|
android:background="@drawable/zero_bg_4_items"
|
||||||
android:layout_marginHorizontal="15dp"
|
android:layout_marginHorizontal="15dp"
|
||||||
android:layout_marginBottom="20dp"
|
android:layout_marginBottom="10dp"
|
||||||
>
|
>
|
||||||
<!--第一行两个-->
|
<!--第一行两个-->
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:text="@string/participar_ed"
|
android:text="@string/participar_ed"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatTextView
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
|
@ -109,6 +110,7 @@
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
android:text="@string/remain_time"
|
android:text="@string/remain_time"
|
||||||
|
android:visibility="gone"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
|
|
||||||
|
|
@ -94,18 +94,23 @@ class CustomTitleBar @JvmOverloads constructor(
|
||||||
layoutParam.marginEnd = 15.dp
|
layoutParam.marginEnd = 15.dp
|
||||||
layoutParam.gravity = Gravity.CENTER_VERTICAL
|
layoutParam.gravity = Gravity.CENTER_VERTICAL
|
||||||
|
|
||||||
|
newImageView.isClickable = true
|
||||||
|
newImageView.setOnClickListener { onClicked }
|
||||||
|
|
||||||
mBinding.llRightRoot.addView(newImageView, layoutParam)
|
mBinding.llRightRoot.addView(newImageView, layoutParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addRightText(textRes: Int, onClicked: ()->Unit) {
|
fun addRightText(textRes: Int, onClicked: ()->Unit) {
|
||||||
val newImageView = AppCompatTextView(context)
|
val newTextView = AppCompatTextView(context)
|
||||||
newImageView.text = ResUtil.getString(textRes)
|
newTextView.text = ResUtil.getString(textRes)
|
||||||
|
|
||||||
var layoutParam = LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)
|
var layoutParam = LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)
|
||||||
layoutParam.marginEnd = 15.dp
|
layoutParam.marginEnd = 15.dp
|
||||||
layoutParam.gravity = Gravity.CENTER_VERTICAL
|
layoutParam.gravity = Gravity.CENTER_VERTICAL
|
||||||
|
newTextView.isClickable = true
|
||||||
|
newTextView.setOnClickListener { onClicked }
|
||||||
|
|
||||||
mBinding.llRightRoot.addView(newImageView, layoutParam)
|
mBinding.llRightRoot.addView(newTextView, layoutParam)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue