18034727885
2026-08-07 bbc64160643c4ed818eb574831dc303b0a979089
app/src/main/java/com/driver/igotrip/netUtls/NetKit.kt
@@ -7,12 +7,10 @@
import android.view.LayoutInflater
import android.view.View
import cn.sinata.xldutils.activitys.BaseActivity
import cn.sinata.xldutils.utils.Base64
import com.driver.igotrip.base.MyBaseActivity
import com.driver.igotrip.base.MyBaseFragment
import com.driver.igotrip.utils.Cache.CacheKey
import com.driver.igotrip.utils.DES
import kotlin.collections.HashMap
fun delayTo(time: Long, clickAction: () -> Unit) {
    Handler(Looper.getMainLooper()).postDelayed({
@@ -34,6 +32,16 @@
    map: HashMap<String?, Any?>,
    clickAction: (responseString: String?) -> Unit
) {
    callNet(showDialog, api, map, clickAction) { _, _ -> }
}
fun BaseActivity.callNet(
    showDialog: Boolean,
    api: String,
    map: HashMap<String?, Any?>,
    clickAction: (responseString: String?) -> Unit,
    clickActionError: (code: Int, errorString: String?) -> Unit
) {
    if (showDialog)
        showDialog()
    if (api.startsWith("api")) {
@@ -48,6 +56,10 @@
            clickAction(responseString)
        }
        override fun onError(code: Int, msg: String?, resposeString: String?) {
            super.onError(code, msg, resposeString)
            clickActionError(code, msg)
        }
    })
}
@@ -73,9 +85,9 @@
fun getAppId(): String {
    var appid = CacheKey.getKeyStr("appid")
    if (appid.isEmpty()){
    if (appid.isEmpty()) {
        return ""
    } else{
    } else {
        return appid
    }
}
@@ -92,17 +104,16 @@
    return CacheKey.getKeyStr("token")
}
fun MyBaseActivity.callNet(
    api: String,
    map: HashMap<String?, Any?>,
    clickAction: (responseString: String?) -> Unit,
    clickActionError: (errorString: String?) -> Unit
    clickActionError: (code: Int, msg: String?) -> Unit
) {
    this.showDialog()
    if (api.startsWith("api")) {
        map["appid"] = getAppId()
        var sign = DES.getSign(map)
        val sign = DES.getSign(map)
        map["sign"] = sign
    }
    HttpManager.getInstance().post(api, map, object : MyObserver(this) {
@@ -113,7 +124,7 @@
        override fun onError(code: Int, msg: String?, resposeString: String?) {
            super.onError(code, msg, resposeString)
            clickActionError(msg)
            clickActionError(code, msg)
        }
    })
@@ -195,7 +206,7 @@
    api: String,
    map: HashMap<String?, Any?>,
    clickAction: (responseString: String?) -> Unit,
    errorAction: () -> Unit,showError:Boolean = true
    errorAction: (code: Int, msg: String?) -> Unit, showError: Boolean = true
) {
    if (api.startsWith("api")) {
        map["appid"] = getAppId()
@@ -210,7 +221,7 @@
        override fun onError(code: Int, msg: String?, resposeString: String?) {
            if (showError)
                super.onError(code, msg, resposeString)
            errorAction()
            errorAction(code, msg)
        }
    })
}
@@ -263,7 +274,7 @@
}
fun timeOver(timeDown:Long,click: (mill: Int) -> Unit): CountDownTimer {
fun timeOver(timeDown: Long, click: (mill: Int) -> Unit): CountDownTimer {
    val timer by lazy {
        object : CountDownTimer(timeDown, 1000) {
            override fun onFinish() {