From 68d7250b95451272aaa7cf359fd68b98d91b4d56 Mon Sep 17 00:00:00 2001 From: liugl <liugl@sinata.cn> Date: 星期二, 11 八月 2020 11:31:41 +0800 Subject: [PATCH] 1:乘客付款不播报,下单播报延时,3断网后重连接不了单 --- app/src/main/java/com/okgoincar/utils/UtilKt.kt | 41 ++++++++++++++++++++++++++++++----------- 1 files changed, 30 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/okgoincar/utils/UtilKt.kt b/app/src/main/java/com/okgoincar/utils/UtilKt.kt index e42e00d..be8d1f9 100644 --- a/app/src/main/java/com/okgoincar/utils/UtilKt.kt +++ b/app/src/main/java/com/okgoincar/utils/UtilKt.kt @@ -24,6 +24,7 @@ import cn.sinata.xldutils.utils.ViewClickDelay.lastClickTime import cn.sinata.xldutils.xldUtils import com.okgoincar.base.MyApplication +import com.okgoincar.utils.Cache.CacheKey import org.jetbrains.anko.internals.AnkoInternals import java.lang.NumberFormatException import java.util.* @@ -293,11 +294,12 @@ Log.e("OkTrip----trip", "--------" + msg) } -fun getFormatOne(value:Double?):String{ - return Formatter().format("%.1f",value).toString() +fun getFormatOne(value: Double?): String { + return Formatter().format("%.1f", value).toString() } -fun getFormatTwo(value:Double?):String{ - return Formatter().format("%.2f",value).toString() + +fun getFormatTwo(value: Double?): String { + return Formatter().format("%.2f", value).toString() } //多个参数 @@ -307,15 +309,32 @@ // } //}) -fun getNowTimeBlack():Boolean{ - var hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) - if (hour < 7 || hour >= 18){ -// if (hour < 7 || hour >= 12){ + +fun getNowTimeBlack(): Boolean { + var hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) //此时的小时 + var dayNow = Calendar.getInstance().get(Calendar.DAY_OF_MONTH)//此时的天数 + var date = CacheKey.getKeyStr("date_mode") //记录为点击切换的时间Long + var mode = CacheKey.getKeyStr("mode_now_time") ///记录为点击切换的颜色 1 白色 2 黑色 + + if (date.isEmpty()) { + if (hour < 7 || hour >= 18) { return true + } + return false + } else { + var time: Long = date.toLong() + var calendar = Calendar.getInstance() + calendar.timeInMillis = time + var day = calendar.get(Calendar.DAY_OF_MONTH) + if (day != dayNow) { + CacheKey.putKeyStr("date_mode", "") + return getNowTimeBlack() + } else { + return mode != "1" + } } - return false } -fun toast(s:String){ - Toast.makeText(MyApplication.appContext,s,Toast.LENGTH_SHORT).show() +fun toast(s: String) { + Toast.makeText(MyApplication.appContext, s, Toast.LENGTH_SHORT).show() } \ No newline at end of file -- Gitblit v1.7.1