From bd6a8872438a35d47821c5d5da7fe149e5fed3ab Mon Sep 17 00:00:00 2001
From: lmw <125975490@qq.com>
Date: 星期三, 21 六月 2023 09:53:36 +0800
Subject: [PATCH] 处理收不到广播

---
 app/src/main/java/com/okgoincar/utils/UtilKt.kt |   76 ++++++++++++++++++++++++++++++++------
 1 files changed, 64 insertions(+), 12 deletions(-)

diff --git a/app/src/main/java/com/okgoincar/utils/UtilKt.kt b/app/src/main/java/com/okgoincar/utils/UtilKt.kt
index a390495..c07b2e3 100644
--- a/app/src/main/java/com/okgoincar/utils/UtilKt.kt
+++ b/app/src/main/java/com/okgoincar/utils/UtilKt.kt
@@ -23,7 +23,13 @@
 import cn.sinata.xldutils.utils.ViewClickDelay.hash
 import cn.sinata.xldutils.utils.ViewClickDelay.lastClickTime
 import cn.sinata.xldutils.xldUtils
+import com.google.gson.Gson
 import com.okgoincar.base.MyApplication
+import com.okgoincar.bean.OrderBean
+import com.okgoincar.netUtls.Api
+import com.okgoincar.netUtls.callNet
+import com.okgoincar.netUtls.getMapByAny
+import com.okgoincar.utils.Cache.CacheKey
 import org.jetbrains.anko.internals.AnkoInternals
 import java.lang.NumberFormatException
 import java.util.*
@@ -229,6 +235,11 @@
 }
 
 
+fun TextView.setDrawableNull() {
+    this.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null)
+}
+
+
 fun TextView.setDrawableBottom(drawableResourseId: Int) {
     val topAct: Drawable = context.resources.getDrawable(drawableResourseId)
     this.setCompoundDrawablesWithIntrinsicBounds(null, null, null, topAct)
@@ -243,7 +254,6 @@
     val topAct: Drawable = context.resources.getDrawable(drawableResourseId)
     this.setCompoundDrawablesWithIntrinsicBounds(null, topAct, null, null)
 }
-
 
 fun TextView.setColor(context: Context, resourse: Int) {
     this.setTextColor(ContextCompat.getColor(context, resourse))
@@ -289,11 +299,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()
 }
 
 //多个参数
@@ -303,14 +314,55 @@
 //    }
 //})
 
-fun getNowTimeBlack():Boolean{
-    var hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY)
-    if (hour < 7 || hour >= 18){
-        return true
+
+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()
+interface Isyy{
+    fun isYy(b:Boolean)
+}
+
+fun calldetailOrderIsYy(context: Context,orderId:String,orderType:String,isyy: Isyy){
+    var map = getMapByAny()
+    map["orderId"] = orderId
+    map["orderType"] = orderType
+    map["lat"] = MyApplication.getLocation().latitude
+    map["lon"] = MyApplication.getLocation().longitude
+    callNet(context, Api.queryPushOrder, map) {
+        val data = Gson().fromJson<OrderBean>(it, OrderBean::class.java).data
+        data?.let {
+            if(it.reservation != 2){
+                isyy.isYy(true)
+            }else{
+                isyy.isYy(false)
+            }
+
+        }
+    }
+}
+
+fun toast(s: String) {
+    Toast.makeText(MyApplication.appContext, s, Toast.LENGTH_SHORT).show()
 }
\ No newline at end of file

--
Gitblit v1.7.1