| | |
| | | package com.kuanzhai.driver.ui |
| | | |
| | | import android.util.Log |
| | | import android.view.View |
| | | import android.widget.Toast |
| | | import cn.sinata.xldutils.utils.* |
| | | import cn.sinata.xldutils.utils.clickDelay |
| | | import cn.sinata.xldutils.utils.setDrawableTop |
| | | import cn.sinata.xldutils.utils.textColor |
| | | import com.kuanzhai.driver.R |
| | | import com.kuanzhai.driver.base.MyBaseActivity |
| | | import com.kuanzhai.driver.bean.ModuleBean |
| | |
| | | import com.kuanzhai.driver.ui.main.MainPubFragment |
| | | import com.kuanzhai.driver.ui.mine.MineActivity |
| | | import com.kuanzhai.driver.utils.Cache.CacheKey |
| | | import com.kuanzhai.driver.utils.Cache.CacheKey.getKeyStr |
| | | import io.rong.imlib.RongIMClient |
| | | import kotlinx.android.synthetic.main.activity_main_tab.* |
| | | |
| | | class MainTabActivity: MyBaseActivity() { |
| | |
| | | override fun initView() { |
| | | showHeader(false) |
| | | showTitle(false) |
| | | |
| | | RongIMClient.connect(getKeyStr("rongToken"), object : RongIMClient.ConnectCallback() { |
| | | override fun onSuccess(s: String) { |
| | | Log.e("RongTag", "融云服务已连接") |
| | | } |
| | | |
| | | override fun onError(connectionErrorCode: RongIMClient.ConnectionErrorCode) { |
| | | Log.e("RongTag", "融云服务连接失败:$connectionErrorCode") |
| | | } |
| | | |
| | | override fun onDatabaseOpened(databaseOpenStatus: RongIMClient.DatabaseOpenStatus) {} |
| | | }) |
| | | |
| | | allGray() |
| | | callMine() |
| | | tv_main.textColor(this,R.color.main_yellow_shen) |
| | | tv_main.textColor(this, R.color.main_yellow_shen) |
| | | tv_main.setDrawableTop(R.mipmap.tab_home_green) |
| | | addFragment(mainFragment,R.id.container) |
| | | addFragment(mainFragment, R.id.container) |
| | | callModule() |
| | | } |
| | | |
| | |
| | | |
| | | private fun callMine() { |
| | | var map = getMapByAny() |
| | | callNet(false,Api.queryInfo, map) { |
| | | callNet(false, Api.queryInfo, map) { |
| | | var user = gson.fromJson<UserBean>(it, UserBean::class.java) |
| | | CacheKey.saveUserInfo(user.data) |
| | | } |
| | |
| | | override fun setOnclick() { |
| | | tv_main.clickDelay { |
| | | allGray() |
| | | tv_main.textColor(this,R.color.main_yellow_shen) |
| | | tv_main.textColor(this, R.color.main_yellow_shen) |
| | | tv_main.setDrawableTop(R.mipmap.tab_home_green) |
| | | addFragment(mainFragment,R.id.container) |
| | | addFragment(mainFragment, R.id.container) |
| | | // showOrder("1323","1",100,1) |
| | | } |
| | | tv_driver.clickDelay { |
| | | allGray() |
| | | tv_driver.textColor(this,R.color.main_yellow_shen) |
| | | tv_driver.textColor(this, R.color.main_yellow_shen) |
| | | tv_driver.setDrawableTop(R.mipmap.tab_driver_server_yes) |
| | | addFragment(driverServerFragment,R.id.container) |
| | | addFragment(driverServerFragment, R.id.container) |
| | | } |
| | | tv_mine.clickDelay { |
| | | allGray() |
| | | tv_mine.textColor(this,R.color.main_yellow_shen) |
| | | tv_mine.textColor(this, R.color.main_yellow_shen) |
| | | tv_mine.setDrawableTop(R.mipmap.tab_user_green) |
| | | addFragment(mineFragment,R.id.container) |
| | | addFragment(mineFragment, R.id.container) |
| | | } |
| | | } |
| | | |
| | | private fun allGray() { |
| | | tv_main.textColor(this,R.color.tab_gray) |
| | | tv_driver.textColor(this,R.color.tab_gray) |
| | | tv_mine.textColor(this,R.color.tab_gray) |
| | | tv_main.textColor(this, R.color.tab_gray) |
| | | tv_driver.textColor(this, R.color.tab_gray) |
| | | tv_mine.textColor(this, R.color.tab_gray) |
| | | tv_main.setDrawableTop(R.mipmap.tab_home_gray) |
| | | tv_driver.setDrawableTop(R.mipmap.tab_driver_server_null) |
| | | tv_mine.setDrawableTop(R.mipmap.tab_user_gray) |
| | |
| | | */ |
| | | private fun callModule() { |
| | | var map = getMapByAny() |
| | | callNet(Api.getShowModular,map){ |
| | | callNet(Api.getShowModular, map){ |
| | | var module = gson.fromJson<ModuleBean>(it, ModuleBean::class.java) |
| | | tv_driver.visibility = if (module.data.filter { it.driverShow == 1 }.isNotEmpty()) View.VISIBLE else View.GONE //如果子菜单全隐藏,则整个模块隐藏 |
| | | } |