liugl
2020-07-30 25eca75a51c6b73b3bf6b515e92975e0cbc130c2
app/src/main/java/com/okgoincar/slab/SlabMainActivity.kt
@@ -1,10 +1,16 @@
package com.okgoincar.slab
import android.content.Intent
import android.content.IntentFilter
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import cn.sinata.rxnetty.NettyClient
import cn.sinata.xldutils.utils.clickDelay
import cn.sinata.xldutils.utils.getNowTimeBlack
import cn.sinata.xldutils.utils.textColor
import com.amap.api.location.AMapLocation
import com.amap.api.location.AMapLocationListener
@@ -41,14 +47,39 @@
        setContentView(R.layout.slab_activity_main)
    }
    override fun setBlackMode(b: Boolean?) {
        super.setBlackMode(b)
        if (b!!) {
        if (b!!) { //晚上
            ct_bg.setBackgroundResource(R.color.black_191919)
            ll_top.setBackgroundResource(R.drawable.bg_green_top_black)
            ll_top.setBackgroundResource(R.drawable.bg_gray_top)
            tv_server_ing.textColor(this,R.color.write)
            iv_small.textColor(this,R.color.write)
            tv_wait_server.textColor(this,R.color.write)
            tv_code_num.textColor(this,R.color.write)
            tv_name.textColor(this,R.color.write)
            tv_car_num.textColor(this,R.color.write)
            tv_star_num.textColor(this,R.color.write)
            tv_current_time.textColor(this,R.color.write)
            tv_company.textColor(this,R.color.write)
            tv_time.textColor(this,R.color.write)
            tv_car_statue.textColor(this,R.color.write)
            tv_title.textColor(this,R.color.slab_yellow_zhong)
        } else {
            ll_top.setBackgroundResource(R.drawable.bg_green_top)
            ct_bg.setBackgroundResource(R.drawable.bg_slab_main)
            ct_bg.setBackgroundResource(R.drawable.write)
            tv_server_ing.textColor(this,R.color.black)
            iv_small.textColor(this,R.color.black)
            tv_wait_server.textColor(this,R.color.black)
            tv_code_num.textColor(this,R.color.black)
            tv_name.textColor(this,R.color.black)
            tv_car_num.textColor(this,R.color.black)
            tv_star_num.textColor(this,R.color.black)
            tv_current_time.textColor(this,R.color.black)
            tv_company.textColor(this,R.color.black)
            tv_time.textColor(this,R.color.black)
            tv_car_statue.textColor(this,R.color.black)
            tv_title.textColor(this,R.color.yellow_ffa72d)
        }
    }
@@ -62,6 +93,7 @@
        initCall()
        NettyClient.getInstance().startService()
        callPersion()
        showOrder("2221","2",100,2)
    }
    private fun callPersion() {
@@ -79,7 +111,7 @@
    private fun showUI(data: UserInfoBean?) {
        data?.let {
            tv_code_num.text = "证号:" + data.taxiAptitudeCard
            tv_code_num.text = "资格证号:" + data.taxiAptitudeCard
            tv_name.text = "姓名:" + it.name
            tv_car_num.text = "车牌:" + it.licensePlate
            recycler_view_start.layoutManager =
@@ -91,7 +123,7 @@
            recycler_view_start.adapter = SlabStartAdapter(it.score.toDouble())
            tv_company.text = "公司:" + it.company
            tv_time.text = "发证日期:" + it.networkCarlssueDate
            GlideUtil.load(this, it.avatar, iv_head, 1)
            GlideUtil.load(this, it.avatar, iv_head, 8)
            tv_current_time.text = DateUtil.getTime(
                DateUtil.TYPE7,
                System.currentTimeMillis()
@@ -108,7 +140,14 @@
            if (data.data.work == 1){
                MyApplication.getTTsManager().setVideoText("您正在上班中")
            }else{
                MyApplication.getTTsManager().setVideoText("您已下班")
//                MyApplication.getTTsManager().setVideoText("您已下班")
                var mapC = getMapByAny()
                mapC["type"] = "2"
                callNet(true, Api.work2, mapC) {
                    homeDataBean?.data?.work = 1
                    tv_car.text = "收车"
                    MyApplication.getTTsManager().setVideoText("您正在上班中")
                }
            }
        }
@@ -130,19 +169,41 @@
    override fun setOnclick() {
        tv_server_ing.setOnClickListener {
            tv_server_ing.textColor(this, R.color.main_yellow)
            tv_wait_server.textColor(this, R.color.white)
            if (getNowTimeBlack()){
                tv_wait_server.textColor(this, R.color.white)
            }else{
                tv_wait_server.textColor(this, R.color.black)
            }
            mainFragment.state = 1
            mainFragment.autoRefresh()
        }
        tv_wait_server.setOnClickListener {
            tv_server_ing.textColor(this, R.color.white)
            tv_wait_server.textColor(this, R.color.main_yellow)
            if (getNowTimeBlack()){
                tv_server_ing.textColor(this, R.color.white)
            }else{
                tv_server_ing.textColor(this, R.color.black)
            }
            mainFragment.state = 2
            mainFragment.autoRefresh()
        }
        tv_name.clickDelay {
            toast("点亮网约")
        }
        tv_car_num.clickDelay {
        }
        tv_star_num.clickDelay {
        }
        tv_more.clickDelay {
            startActivity<SlabOrderListActivity>()
        }
        ll_task.clickDelay {
@@ -151,21 +212,21 @@
        tv_car.clickDelay {
            if (homeDataBean?.data?.work == 1) {
                callNet(true, Api.work2, getMapByAny()) {
                    homeDataBean?.data?.work = 2
                    tv_car.text = "出车"
                    MyApplication.getTTsManager().setVideoText("您已下班")
                }
            } else {
                var map = getMapByAny()
                map["type"] = "2"
                callNet(true, Api.work2, map) {
                    homeDataBean?.data?.work = 1
                    tv_car.text = "收车"
                    MyApplication.getTTsManager().setVideoText("您正在上班中")
                }
            }
//            if (homeDataBean?.data?.work == 1) {
//                callNet(true, Api.work2, getMapByAny()) {
//                    homeDataBean?.data?.work = 2
//                    tv_car.text = "出车"
//                    MyApplication.getTTsManager().setVideoText("您已下班")
//                }
//            } else {
//                var map = getMapByAny()
//                map["type"] = "2"
//                callNet(true, Api.work2, map) {
//                    homeDataBean?.data?.work = 1
//                    tv_car.text = "收车"
//                    MyApplication.getTTsManager().setVideoText("您正在上班中")
//                }
//            }
        }
    }
@@ -190,13 +251,27 @@
            BaseEvent.START_CAR -> {
                initCall()
            }
            BaseEvent.REQUEST_CAR_INFO -> {
                Handler(Looper.getMainLooper()).post {
                    toast("收到显示屏信息")
                }
            }
        }
    }
    override fun onLocationChanged(p0: AMapLocation?) {
        if (p0?.errorCode == 0) {
        if (p0 == null){
            toast("高德位置是空的")
            return
        }
        if (p0.errorCode == 0) {
            toast("定位成功")
            MyApplication.aMapLocation = p0
            CacheKey.putKeyStr("location", Gson().toJson(p0))
        }else{
            p0.let {
                toast("定位失败"+it.errorCode.toString())
            }
        }
    }
}