From 81ea7d321ed625cb725365bca6c0ce158b128ea7 Mon Sep 17 00:00:00 2001
From: liugl <liugl@sinata.cn>
Date: 星期二, 15 十二月 2020 18:19:24 +0800
Subject: [PATCH] 1:新增上线 6版
---
app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt | 195 ++++++++++++++++++++++++++++++++----------------
1 files changed, 131 insertions(+), 64 deletions(-)
diff --git a/app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt b/app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt
index d38a759..62b42e0 100644
--- a/app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt
+++ b/app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt
@@ -1,24 +1,20 @@
package com.okgoincar.slab
import android.content.Context
-import android.content.Intent
-import android.content.IntentFilter
-import android.os.Bundle
import android.os.Handler
import android.os.Looper
+import android.view.Gravity
+import android.view.KeyEvent
+import android.view.ViewGroup
+import android.widget.PopupWindow
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
-import cn.sinata.rxnetty.Cache.CacheUtil
import cn.sinata.rxnetty.NettyClient
import cn.sinata.xldutils.netstatus.NetUtils
import cn.sinata.xldutils.utils.*
import com.amap.api.location.AMapLocation
import com.amap.api.location.AMapLocationListener
-import com.okgoincar.netUtls.callNet
-import com.okgoincar.netUtls.getMapByAny
-import com.okgoincar.ui.adapter.SlabStartAdapter
-import com.okgoincar.utils.Cache.CacheKey
import com.google.gson.Gson
import com.okgoincar.R
import com.okgoincar.base.AMapKit
@@ -26,21 +22,22 @@
import com.okgoincar.base.MyApplication
import com.okgoincar.bean.*
import com.okgoincar.netUtls.Api
-import com.okgoincar.netUtls.sendAudio
+import com.okgoincar.netUtls.callNet
+import com.okgoincar.netUtls.createView
+import com.okgoincar.netUtls.getMapByAny
import com.okgoincar.slab.event.SlabMineEventActivity
import com.okgoincar.slab.util.DialogUtil
+import com.okgoincar.ui.adapter.SlabStartAdapter
+import com.okgoincar.utils.Cache.CacheKey
import com.okgoincar.utils.DateUtil
import com.okgoincar.utils.EasePopup.EasyPopup
+import com.okgoincar.utils.PackageUtil
import com.okgoincar.utils.download.DownloadUtil
import com.okgoincar.utils.glide.GlideUtil
import kotlinx.android.synthetic.main.dialog_sure_and_del_slab.view.*
-import kotlinx.android.synthetic.main.slab_activity_login.*
import kotlinx.android.synthetic.main.slab_activity_main.*
-import kotlinx.android.synthetic.main.slab_activity_main.tv_name
-import org.greenrobot.eventbus.EventBus
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
-import java.lang.Exception
class SlabMainActivity : MySlabBaseActivity(), AMapLocationListener {
@@ -91,8 +88,7 @@
}
override fun initView() {
- tv_title_top.text = "服 务 监 督 卡 I"
- if (NetUtils.isNetworkConnected(this)){
+ if (NetUtils.isNetworkConnected(this)) {
setTitleText("OK出行司机")
showHeader(false)
showTitle(false)
@@ -106,11 +102,11 @@
// showOrder("2221", "2", 100, 2)
callVersion()
}
- }else{
- toast("无网络")
+ } else {
+ showNoneNetDialog()
}
+ tv_server_ing.textColor(this, R.color.main_yellow)
}
-
private fun callPersion() {
@@ -121,36 +117,53 @@
}
}
- var popup:EasyPopup? = null
+ var popup: PopupWindow? = null
override fun onResume() {
super.onResume()
- if (!NetUtils.isNetworkConnected(this)){
- popup = getSlabDelAndSurePopWindow(this,"刷新","取消","网络不通畅,是否刷新页面?",{}){
- if (!NetUtils.isNetworkConnected(this)){
+ showNoneNetDialog()
+ try {
+ mainFragment?.refresh()
+ callPersion()
+ callHomeNUm()
+ } catch (e: Exception) {
+
+ }
+ }
+
+ fun showNoneNetDialog() {
+ if (!NetUtils.isNetworkConnected(this)) {
+ popup = getSlabDelAndSurePopWindow(this, "刷新", "取消", "网络不通畅,是否刷新页面?", {}) {
+ if (!NetUtils.isNetworkConnected(this)) {
toast("无网络")
- }else{
+ } else {
initView()
popup?.dismiss()
}
}
window.decorView.post {
- popup?.showCenter(window.decorView)
+ popup?.showAtLocation(window.decorView, Gravity.CENTER, 0, 0);
+// popup?.showCenter(window.decorView)
}
}
- try {
- mainFragment?.refresh()
- }catch (e:Exception){
-
- }
-
}
- fun getSlabDelAndSurePopWindow(context: Context,sureStr:String,cancelStr:String,content:String,clickClose :() -> Unit,clickSure:() -> Unit): EasyPopup {
- var dialog = DialogUtil.getPopupwindow(context, R.layout.dialog_sure_and_del_slab)
+ fun getSlabDelAndSurePopWindow(
+ context: Context,
+ sureStr: String,
+ cancelStr: String,
+ content: String,
+ clickClose: () -> Unit,
+ clickSure: () -> Unit
+ ): PopupWindow {
+ var dialog = PopupWindow(createView(R.layout.dialog_sure_and_del_slab,context))
+ dialog.width = ViewGroup.LayoutParams.MATCH_PARENT
+ dialog.height = ViewGroup.LayoutParams.MATCH_PARENT
+
var view = dialog.contentView
view.tv_close_base.text = cancelStr
view.tv_sure_base.text = sureStr
+ view.tv_close_base.gone()
view.tv_close_base.setOnClickListener {
dialog.dismiss()
clickClose()
@@ -163,13 +176,19 @@
}
-
-
private fun showUI(data: UserInfoBean?) {
data?.let {
- if (data.taxiAptitudeCard.length > 7){
- tv_code_num.text = "资格证号:"+data.taxiAptitudeCard.substring(0,3)+"*******"+data.taxiAptitudeCard.substring(data.taxiAptitudeCard.length-4,data.taxiAptitudeCard.length)
- }else{
+ textView_version.text = "版本-V" + PackageUtil.getVersionName(this)
+ tv_title_top.text = "服 务 监 督 卡"
+ if (data.taxiAptitudeCard.length > 7) {
+ tv_code_num.text = "资格证号:" + data.taxiAptitudeCard.substring(
+ 0,
+ 3
+ ) + "*******" + data.taxiAptitudeCard.substring(
+ data.taxiAptitudeCard.length - 4,
+ data.taxiAptitudeCard.length
+ )
+ } else {
tv_code_num.text = "资格证号:" + data.taxiAptitudeCard
}
tv_name.text = "姓名:" + it.name
@@ -182,8 +201,8 @@
) as RecyclerView.LayoutManager?
recycler_view_start.adapter = SlabStartAdapter(it.score.toDouble())
var company = it.company
- if (company.startsWith("广西")){
- company = company.substring(2,company.length)
+ if (company.startsWith("广西")) {
+ company = company.substring(2, company.length)
}
tv_company.text = "公司:" + company
tv_time.text = "发证日期:" + it.networkCarlssueDate
@@ -214,8 +233,10 @@
}
}
}
+ callHomeNUm()
+ }
-
+ fun callHomeNUm(){
callNet(true, Api.queryHomeNum, getMapByAny()) {
var data = gson.fromJson<MainInfoBean>(it, MainInfoBean::class.java)
if (!data.data.service.isNullOrEmpty() && data.data.service != "0")
@@ -235,10 +256,13 @@
tv_server_ing.textColor(this, R.color.main_yellow)
if (getNowTimeBlack()) {
tv_wait_server.textColor(this, R.color.white)
+ iv_small.textColor(this, R.color.white)
} else {
tv_wait_server.textColor(this, R.color.black)
+ iv_small.textColor(this, R.color.black)
}
mainFragment.state = 1
+ mainFragment.type = 1
mainFragment.autoRefresh()
}
@@ -246,10 +270,31 @@
tv_wait_server.textColor(this, R.color.main_yellow)
if (getNowTimeBlack()) {
tv_server_ing.textColor(this, R.color.white)
+ iv_small.textColor(this, R.color.white)
} else {
tv_server_ing.textColor(this, R.color.black)
+ iv_small.textColor(this, R.color.black)
}
mainFragment.state = 2
+ mainFragment.type = 1
+ mainFragment.autoRefresh()
+ }
+
+ tv_title_top.clickDelay {
+ showOrder("33","4",202,1)
+ }
+
+ iv_small.setOnClickListener {
+ iv_small.textColor(this, R.color.main_yellow)
+ if (getNowTimeBlack()) {
+ tv_server_ing.textColor(this, R.color.white)
+ tv_wait_server.textColor(this, R.color.white)
+ } else {
+ tv_server_ing.textColor(this, R.color.black)
+ tv_wait_server.textColor(this, R.color.black)
+ }
+ mainFragment.state = 1
+ mainFragment.type = 2
mainFragment.autoRefresh()
}
@@ -271,10 +316,6 @@
ll_task.clickDelay {
startActivity<SlabMineEventActivity>()
- }
-
- tv_title_top.clickDelay {
-
}
view_mode.clickDelay {
@@ -320,6 +361,9 @@
var mBackAppTime: Long = 0
override fun onBackPressed() {
+ if (popup != null && popup!!.isShowing) {
+ return
+ }
if (System.currentTimeMillis() - mBackAppTime > 2000) {
Toast.makeText(this, "再按一次退出程序", Toast.LENGTH_SHORT)
.show()
@@ -327,6 +371,13 @@
} else {
moveTaskToBack(true)
}
+ }
+
+ override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
+ if (popup != null && popup!!.isShowing) {
+ return false
+ }
+ return super.onKeyDown(keyCode, event)
}
override fun onEventMainThread(event: BaseEvent?) {
@@ -340,11 +391,16 @@
toast("收到显示屏信息")
}
}
+ BaseEvent.UPDATA_MAIN_CAR -> {
+ try {
+ mainFragment.refresh()
+ } catch (e: Exception) {
+ }
+ }
BaseEvent.ERROR_INFO -> {
try {
mainFragment.refresh()
- }catch (e:Exception){
-
+ } catch (e: Exception) {
}
}
}
@@ -361,7 +417,7 @@
CacheKey.putKeyStr("location", Gson().toJson(p0))
} else {
p0.let {
-// toast("定位失败" + it.errorCode.toString())
+ // toast("定位失败" + it.errorCode.toString())
}
}
}
@@ -373,16 +429,23 @@
if (bean.data.version != "" && bean.data.version != Utils.getAppVersion(this)) {
if (bean.data.mandatory == 0) {
var pop =
- DialogUtil.getSlabDelAndSurePopWindow(this, "确定", "取消", "有新版本是否更新", {}) {
+ DialogUtil.getSlabDelAndSurePopWindow(
+ true,
+ this,
+ "确定",
+ "取消",
+ "有新版本是否更新",
+ {}) {
DownloadUtil(this).downloadAPK(bean.data.url, "ok出行车载端")
}
pop.showCenter(window.decorView)
} else {
var pop = DialogUtil.getSlabDelAndSurePopWindow(
+ false,
this,
"确定",
"取消",
- "版本已过时,是否强制升级?",
+ "版本已过时,强制升级!",
{}) {
DownloadUtil(this).downloadAPK(bean.data.url, "ok出行车载端")
toast("后台开始下载,请等待")
@@ -400,21 +463,8 @@
var identification = CacheKey.getKeyStr("identification")
if (jobNum.isNotEmpty()) {
var map = getMapByAny()
- map["jobNum"] = jobNum
- callNet(true, Api.loginByJobNumber, map) {
- var bean = gson.fromJson<LoginBean>(it, LoginBean::class.java)
- CacheKey.putKeyStr("jobNum", jobNum)
- CacheKey.putKeyStr("appid", bean.data.appid)
- CacheKey.putKeyStr("token", bean.data.token)
- CacheKey.putKeyStr("userId", bean.data.id.toString())
- CacheKey.putKeyStr("serverId", bean.data.serverId.toString())
- CacheKey.putKeyStr("terminalName", bean.data.terminalId.toString())
- ok()
- }
- } else if (identification.isNotEmpty()) {
- var map = getMapByAny()
- map["identification"] = identification
- callNet(true, Api.loginByIdentification, map) {
+ map["taxiAptitudeCard"] = identification
+ callNet(this, Api.loginByTaxiAptitudeCard, map, {
var bean = Gson().fromJson<LoginBean>(it, LoginBean::class.java)
CacheKey.putKeyStr("identification", identification)
CacheKey.putKeyStr("appid", bean.data.appid)
@@ -423,6 +473,23 @@
CacheKey.putKeyStr("serverId", bean.data.serverId.toString())
CacheKey.putKeyStr("terminalName", bean.data.terminalId.toString())
ok()
+ }) {
+ ok()
+ }
+ } else if (identification.isNotEmpty()) {
+ var map = getMapByAny()
+ map["taxiAptitudeCard"] = identification
+ callNet(this, Api.loginByTaxiAptitudeCard, map, {
+ var bean = Gson().fromJson<LoginBean>(it, LoginBean::class.java)
+ CacheKey.putKeyStr("identification", identification)
+ CacheKey.putKeyStr("appid", bean.data.appid)
+ CacheKey.putKeyStr("token", bean.data.token)
+ CacheKey.putKeyStr("userId", bean.data.id.toString())
+ CacheKey.putKeyStr("serverId", bean.data.serverId.toString())
+ CacheKey.putKeyStr("terminalName", bean.data.terminalId.toString())
+ ok()
+ }) {
+ ok()
}
} else {
ok()
--
Gitblit v1.7.1