From aaadcd1b0131392be5573a1fc6b3e92f08c5cb87 Mon Sep 17 00:00:00 2001
From: liugl <liugl@sinata.cn>
Date: 星期二, 29 十二月 2020 09:26:27 +0800
Subject: [PATCH] 1:新增上线
---
app/src/main/java/com/okgoincar/utils/UtilKt.kt | 75 +++++++++++++++++++++++++++++++------
1 files changed, 63 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 7defe80..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,15 +314,55 @@
// }
//})
-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()
+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