|
|
@@ -15,6 +15,7 @@ import com.adealink.frame.router.annotation.BindExtra
|
|
|
import com.adealink.frame.router.annotation.RouterUri
|
|
|
import com.adealink.frame.util.formatTime
|
|
|
import com.adealink.frame.util.onClick
|
|
|
+import com.adealink.frame.util.removeUiCallbacks
|
|
|
import com.adealink.frame.util.statusBarHeight
|
|
|
import com.adealink.weparty.commonui.BaseActivity
|
|
|
import com.adealink.weparty.commonui.ext.dp
|
|
|
@@ -26,10 +27,10 @@ import com.adealink.weparty.commonui.toast.util.showFailedToast
|
|
|
import com.adealink.weparty.commonui.widget.CommonDialog
|
|
|
import com.adealink.weparty.module.image.data.PhotoData
|
|
|
import com.adealink.weparty.module.order.Order
|
|
|
+import com.adealink.weparty.module.order.data.ORDER_EXPIRED_TS
|
|
|
import com.adealink.weparty.module.order.data.OrderDetailData
|
|
|
import com.adealink.weparty.module.order.data.OrderDetailInfo
|
|
|
import com.adealink.weparty.module.order.data.OrderStatus
|
|
|
-import com.adealink.weparty.module.order.util.getUserOrderStatusIcon
|
|
|
import com.adealink.weparty.module.order.util.getUserOrderStatusText
|
|
|
import com.adealink.weparty.order.databinding.ActivityOrderDetailBinding
|
|
|
import com.adealink.weparty.order.dialog.EvaluateOrderDialog
|
|
|
@@ -43,6 +44,8 @@ import com.adealink.weparty.order.viewmodel.OrderViewModelFactory
|
|
|
import com.adealink.weparty.order.viewmodel.UserOrderViewModel
|
|
|
import com.adealink.weparty.util.TIME_FORMAT_DMY_HMS
|
|
|
import com.adealink.weparty.util.goImagePreviewActivity
|
|
|
+import okhttp3.internal.format
|
|
|
+import kotlin.math.max
|
|
|
import com.adealink.weparty.R as APP_R
|
|
|
|
|
|
@RouterUri(path = [Order.Detail.PATH], desc = "订单详情")
|
|
|
@@ -255,6 +258,102 @@ class OrderDetailActivity : BaseActivity() {
|
|
|
} else {
|
|
|
binding.clUserRefund.gone()
|
|
|
}
|
|
|
+
|
|
|
+ if (data?.order?.isPendingAccept() == true) {
|
|
|
+ val endTs = data.order.createTime + ORDER_EXPIRED_TS
|
|
|
+ this.countDownSecond = max(endTs - System.currentTimeMillis(), 0) / 1000
|
|
|
+ startReplyCountDown(0)
|
|
|
+ } else {
|
|
|
+ this.countDownSecond = 0
|
|
|
+ stopReplyCountDown()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private fun getUserOrderStatusIcon(
|
|
|
+ status: OrderStatus?,
|
|
|
+ isRefundApply: Boolean? //是否处于申请退款中
|
|
|
+ ): Int {
|
|
|
+ if (isRefundApply == true) {
|
|
|
+ return R.drawable.order_status_in_progress_ic
|
|
|
+ }
|
|
|
+ return when (status) {
|
|
|
+ OrderStatus.CREATE_ORDER -> {
|
|
|
+ R.drawable.order_status_in_progress_ic
|
|
|
+ }
|
|
|
+
|
|
|
+ OrderStatus.WAIT_FOR_ACCEPT -> {
|
|
|
+ R.drawable.order_status_in_progress_ic
|
|
|
+ }
|
|
|
+
|
|
|
+ OrderStatus.PLAYMATE_ACCEPT -> {
|
|
|
+ R.drawable.order_status_accept_ic
|
|
|
+ }
|
|
|
+
|
|
|
+ OrderStatus.PLAYMATE_IN_SERVICE -> {
|
|
|
+ R.drawable.order_status_in_progress_ic
|
|
|
+ }
|
|
|
+
|
|
|
+ OrderStatus.PLAYMATE_END_SERVICE -> {
|
|
|
+ R.drawable.order_status_in_progress_ic
|
|
|
+ }
|
|
|
+
|
|
|
+ OrderStatus.PLAYMATE_REFUSE -> {
|
|
|
+ R.drawable.order_status_cancel_ic
|
|
|
+ }
|
|
|
+
|
|
|
+ OrderStatus.COMPLETE -> {
|
|
|
+ R.drawable.order_status_finish_ic
|
|
|
+ }
|
|
|
+
|
|
|
+ OrderStatus.USER_REFUND -> {
|
|
|
+ R.drawable.order_status_finish_ic
|
|
|
+ }
|
|
|
+
|
|
|
+ OrderStatus.USER_CANCEL -> {
|
|
|
+ R.drawable.order_status_cancel_ic
|
|
|
+ }
|
|
|
+
|
|
|
+ null -> {
|
|
|
+ R.drawable.order_status_in_progress_ic
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private var countDownSecond: Long = 0
|
|
|
+
|
|
|
+ private val countDownRunnable = Runnable {
|
|
|
+ updateCountDownText()
|
|
|
+ countDownSecond = max(0, countDownSecond - 1)
|
|
|
+ startReplyCountDown(1000)
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun startReplyCountDown(delay: Long = 1000) {
|
|
|
+ if (orderDetail?.order?.isPendingAccept() == false) {
|
|
|
+ binding.tvAcceptCountDown.gone()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ binding.tvAcceptCountDown.show()
|
|
|
+ updateCountDownText()
|
|
|
+ if (countDownSecond >= 0) {
|
|
|
+ removeUiCallbacks(countDownRunnable)
|
|
|
+ com.adealink.frame.util.runOnUiThread(countDownRunnable, delay)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun stopReplyCountDown() {
|
|
|
+ binding.tvAcceptCountDown.gone()
|
|
|
+ removeUiCallbacks(countDownRunnable)
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
+ private fun updateCountDownText() {
|
|
|
+ val minute = countDownSecond / 60
|
|
|
+ val second = countDownSecond % 60
|
|
|
+ binding.tvAcceptCountDown.text = getCompatString(
|
|
|
+ R.string.order_auto_cancel_title,
|
|
|
+ "${format("%02d", minute)}:${format("%02d", second)}"
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
private fun clickCancel() {
|