唐浩
昨天 3d631dbadf98f3f77c6e955cb36219217ef73ab5
app/src/main/java/com/ziang/driver/netUtls/NetKit.kt
@@ -47,6 +47,10 @@
            clickAction(responseString)
        }
        override fun onError(e: Throwable) {
            super.onError(e)
        }
    })
}
@@ -71,9 +75,9 @@
fun getAppId(): String {
    var appid = CacheKey.getKeyStr("appid")
    if (appid.isEmpty()){
    if (appid.isEmpty()) {
        return ""
    } else{
    } else {
        return appid
    }
}
@@ -122,6 +126,35 @@
        override fun onError(code: Int, msg: String?, resposeString: String?) {
            super.onError(code, msg, resposeString)
            clickActionError(msg)
        }
    })
}
fun MyBaseActivity.callNetAndError(
    b: Boolean,
    api: String,
    map: HashMap<String?, Any?>,
    clickAction: (responseString: String?) -> Unit,
    clickActionError: (errorString: String?) -> Unit
) {
    if (b)
        this.showDialog()
    if (api.startsWith("api")) {
        map["appid"] = getAppId()
        var sign = DES.getSign(map)
        map["sign"] = sign
    }
    HttpManager.getInstance().post(api, map, object : MyObserver(this) {
        override fun success(responseString: String?) {
            if (b)
                dismissDialog()
            clickAction(responseString)
        }
        override fun onError(code: Int, msg: String?, resposeString: String?) {
//            super.onError(code, msg, resposeString)
            clickActionError(msg)
        }
    })
@@ -207,6 +240,39 @@
}
fun MyBaseFragment.callNet(
    b: Boolean,
    api: String,
    map: HashMap<String?, Any?>,
    clickAction: (responseString: String?) -> Unit,
    clickActionError: (errorString: String?) -> Unit
) {
    if (b) {
        this.showDialog()
    }
    if (api.startsWith("api")) {
        map["appid"] = getAppId()
        var sign = DES.getSign(map)
        map["sign"] = sign
    }
    HttpManager.getInstance().post(api, map, object : MyObserver(this) {
        override fun success(responseString: String?) {
            if (b) {
                dismissDialog()
            }
            clickAction(responseString)
        }
        override fun onError(code: Int, msg: String?, resposeString: String?) {
            super.onError(code, msg, resposeString)
            clickActionError(msg)
        }
    })
}
fun callNet(
    context: Context,
    api: String,
@@ -251,7 +317,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() {