package com.driver.igotrip.ui.main
|
|
import android.Manifest
|
import android.annotation.SuppressLint
|
import android.content.ActivityNotFoundException
|
import android.content.Intent
|
import android.os.Bundle
|
import android.os.Handler
|
import android.os.Looper
|
import android.os.Message
|
import android.provider.Settings
|
import android.util.Log
|
import android.view.View
|
import android.widget.ImageView
|
import android.widget.LinearLayout
|
import android.widget.TextView
|
import android.widget.Toast
|
import cn.sinata.rxnetty.NettyClient
|
import cn.sinata.xldutils.utils.SPUtils
|
import cn.sinata.xldutils.utils.Utils
|
import cn.sinata.xldutils.utils.clickDelay
|
import cn.sinata.xldutils.utils.doubleOne
|
import cn.sinata.xldutils.utils.getVersionName
|
import cn.sinata.xldutils.utils.gone
|
import cn.sinata.xldutils.utils.setDrawableLeft
|
import cn.sinata.xldutils.utils.textColor
|
import com.driver.igotrip.BuildConfig
|
import com.driver.igotrip.R
|
import com.driver.igotrip.base.BaseEvent
|
import com.driver.igotrip.base.Const
|
import com.driver.igotrip.base.MyApplication
|
import com.driver.igotrip.base.MyBaseActivity
|
import com.driver.igotrip.base.OrderTimeOutManager
|
import com.driver.igotrip.base.gaode.AMapKit
|
import com.driver.igotrip.bean.BooleanBean
|
import com.driver.igotrip.bean.HomeDataBean
|
import com.driver.igotrip.bean.MyCarBean
|
import com.driver.igotrip.bean.OrderSimpleData
|
import com.driver.igotrip.bean.SelectServerModeBean
|
import com.driver.igotrip.bean.TimeBean
|
import com.driver.igotrip.bean.UpCarInfo
|
import com.driver.igotrip.bean.UserBean
|
import com.driver.igotrip.bean.VersionBean
|
import com.driver.igotrip.netUtls.Api
|
import com.driver.igotrip.netUtls.callNet
|
import com.driver.igotrip.netUtls.getMapByAny
|
import com.driver.igotrip.ui.DialogUtil
|
import com.driver.igotrip.ui.DialogUtil.getDelAndSureDialog
|
import com.driver.igotrip.ui.main.event.MineEventActivity
|
import com.driver.igotrip.ui.mine.BalanceTopupActivity
|
import com.driver.igotrip.ui.mine.ChangeCarActivity
|
import com.driver.igotrip.ui.mine.DriverAttestationActivity
|
import com.driver.igotrip.ui.mine.MineActivity
|
import com.driver.igotrip.ui.mine.MsgActivity
|
import com.driver.igotrip.ui.mine.OfflinePayActivity
|
import com.driver.igotrip.utils.Cache.CacheKey
|
import com.driver.igotrip.utils.DateUtil
|
import com.driver.mask_talk.utils.toTime
|
import com.driver.mask_talk.utils.toTimeEnglish
|
import com.driver.mask_talk.utils.toTimeFrench
|
import com.google.android.gms.maps.GoogleMap
|
import com.google.android.gms.maps.SupportMapFragment
|
import com.google.android.gms.maps.model.LatLng
|
import com.google.gson.Gson
|
import com.tbruyelle.rxpermissions2.RxPermissions
|
import com.wang.avi.AVLoadingIndicatorView
|
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.Subscribe
|
import org.jetbrains.anko.browse
|
import org.jetbrains.anko.find
|
import org.jetbrains.anko.startActivity
|
import org.jetbrains.anko.toast
|
|
|
class MainActivity : MyBaseActivity()/*, DriverContext.DriverStatusListener*/ {
|
|
val mainFragment by lazy {
|
MainFragment()
|
}
|
|
var homeDataBean: HomeDataBean? = null
|
/* var navigator: Navigator? = null
|
var vehicleReporter: RidesharingVehicleReporter? = null*/
|
|
private val MSG_REFRESH_LOCATIAON = 1
|
|
private val iv_main_icon by lazy { find<ImageView>(R.id.iv_main_icon) }
|
private val tv_active by lazy { find<TextView>(R.id.tv_active) }
|
private val tv_today_time by lazy { find<TextView>(R.id.tv_today_time) }
|
private val tv_week_time by lazy { find<TextView>(R.id.tv_week_time) }
|
private val tv_month_time by lazy { find<TextView>(R.id.tv_month_time) }
|
private val map_view by lazy { supportFragmentManager.findFragmentById(R.id.map_view) }
|
private val avv_anim by lazy { find<AVLoadingIndicatorView>(R.id.avv_anim) }
|
private val tv_up_avv by lazy { find<TextView>(R.id.tv_up_avv) }
|
private val tv_order_num by lazy { find<TextView>(R.id.tv_order_num) }
|
private val tv_month_order by lazy { find<TextView>(R.id.tv_month_order) }
|
private val tv_task by lazy { find<TextView>(R.id.tv_task) }
|
private val tv_car_num by lazy { find<TextView>(R.id.tv_car_num) }
|
private val tv_core by lazy { find<TextView>(R.id.tv_core) }
|
private val tv_lien_name by lazy { find<TextView>(R.id.tv_lien_name) }
|
private val tv_time by lazy { find<TextView>(R.id.tv_time) }
|
private val tv_car by lazy { find<TextView>(R.id.tv_car) }
|
private val tv_server_ing by lazy { find<TextView>(R.id.tv_server_ing) }
|
private val tv_history_order by lazy { find<TextView>(R.id.tv_history_order) }
|
private val tv_wait_server by lazy { find<TextView>(R.id.tv_wait_server) }
|
private val ll_task by lazy { find<LinearLayout>(R.id.ll_task) }
|
|
private val handler by lazy {
|
object : Handler(Looper.getMainLooper()) {
|
override fun handleMessage(msg: Message) {
|
super.handleMessage(msg)
|
if (msg.what == MSG_REFRESH_LOCATIAON) { //刷新位置信息 Refresh location information
|
// AMapKit.initLocation(this@MainActivity){
|
// MyApplication.aMapLocation = it
|
// }
|
}
|
}
|
}
|
}
|
|
|
override fun setContentView() {
|
setContentView(R.layout.activity_main)
|
/* lifecycleScope.launch {
|
while (true){
|
delay(5000)
|
var map = getMapByAny()
|
callNet(false,getDriverOrderMessage, map) {
|
Log.e("长连接接口消息: ",it.toString() )
|
}
|
}
|
}*/
|
}
|
|
override fun initView() {
|
// setTitleText(getString(R.string.IGO司机))
|
tv_Left.setDrawableLeft(R.mipmap.icon_nav_user)
|
// iv_right_title.setImageResource(R.mipmap.icon_nav_news)
|
|
findViewById<View>(R.id.img_leftuser).setOnClickListener {
|
startActivity<MineActivity>()
|
}
|
|
findViewById<View>(R.id.iv_right_titlenew).setOnClickListener {
|
startActivity<MsgActivity>()
|
}
|
addFragment(mainFragment, R.id.rl_container)
|
// AMapKit.initLocation(this){
|
// MyApplication.aMapLocation = it
|
// }
|
iv_main_icon.clickDelay {
|
// AMapKit.initLocation(this){
|
// MyApplication.aMapLocation = it
|
// }
|
// showOrder("","12634","1",10,1)
|
}
|
|
// initDriver()
|
MyApplication.isLogin = true
|
beOnDuty(false)
|
initCall()
|
NettyClient.getInstance().startService()
|
callVersion()
|
checkGps()
|
MyApplication.addOrderView(qeeOrderView)
|
callcarAll()
|
toastTo()
|
callTime("1")
|
|
showTitle(false)
|
showHeader(false)
|
|
/*lifecycleScope.launch {
|
while (true){
|
|
var map = getMapByAny()
|
callNet(showDialog=false,getDriverOrderMessage, map) {
|
Log.e("获取消息: ",it .toString())
|
}
|
|
delay(5000)
|
}
|
}*/
|
}
|
|
/**
|
* 初始化司机sdk
|
*/
|
/* private fun initDriver() {
|
if (CacheKey.getKeyStr("vehicleId").isNullOrEmpty())
|
return
|
NavigationApi.getNavigator(
|
this, // Activity
|
object : NavigationApi.NavigatorListener {
|
override fun onError(p0: Int) {
|
Log.e(Const.GoogleDriver.TAG, "初始化司机sdk失败$p0")
|
}
|
|
override fun onNavigatorReady(navigator: Navigator) {
|
// Keep a reference to the Navigator (used to configure and start nav)
|
this@MainActivity.navigator = navigator
|
Log.e(Const.GoogleDriver.TAG, "初始化司机sdk成功")
|
val driverContext =
|
DriverContext.builder(application)
|
//.setProviderId("i-go-odrd-testing")
|
.setProviderId("gopost-475301")
|
.setVehicleId(CacheKey.getKeyStr("vehicleId"))
|
.setAuthTokenFactory(JsonAuthTokenFactory())
|
.setNavigator(navigator)
|
.setRoadSnappedLocationProvider(
|
NavigationApi.getRoadSnappedLocationProvider(
|
application
|
)
|
)
|
.setDriverStatusListener(this@MainActivity)
|
.build()
|
val ridesharingDriverApi = RidesharingDriverApi.createInstance(driverContext)
|
vehicleReporter = ridesharingDriverApi.ridesharingVehicleReporter
|
vehicleReporter!!.enableLocationTracking()
|
}
|
}
|
)
|
}*/
|
|
override fun onRestart() {
|
super.onRestart()
|
callTime("1")
|
}
|
|
@Subscribe
|
fun onStopLocation(e: BaseEvent) {
|
if (e.code == 542)
|
handler?.removeMessages(MSG_REFRESH_LOCATIAON)
|
}
|
|
private fun callTime(type: String) {
|
OrderTimeOutManager.instance.init()
|
var map = getMapByAny()
|
callNet(Api.getDriverOnlineTime, map) {
|
var bean = gson.fromJson<TimeBean>(it, TimeBean::class.java)
|
if (bean.data.attendance == 0.0) {
|
tv_active.text = "0.0h"
|
} else {
|
tv_active.text = doubleOne(bean.data.attendance / 60 / 60) + "h"
|
}
|
if (bean.data.today == 0.0) {
|
tv_today_time.text = "0.0h"
|
} else {
|
tv_today_time.text = doubleOne(bean.data.today / 60 / 60) + "h"
|
}
|
if (bean.data.thisWeek == 0.0) {
|
tv_week_time.text = "0.0h"
|
} else {
|
tv_week_time.text = doubleOne(bean.data.thisWeek / 60 / 60) + "h"
|
}
|
if (bean.data.thisMonth == 0.0) {
|
tv_month_time.text = "0.0h"
|
} else {
|
tv_month_time.text = doubleOne(bean.data.thisMonth / 60 / 60) + "h"
|
}
|
|
}
|
}
|
|
|
private fun toastTo() {
|
var jumpCode = CacheKey.getKeyStr("jumpCode")
|
if (jumpCode == "100000") {
|
DialogUtil.getDelAndSureDialog(this, getString(R.string.是否完善个人资料), {}, {
|
startActivity<DriverAttestationActivity>()
|
})
|
}
|
}
|
|
private fun callcarAll() {
|
callNet(Api.queryMyCar, getMapByAny()) {
|
var bean = gson.fromJson<MyCarBean>(it, MyCarBean::class.java)
|
if (bean.data.car.isNullOrEmpty()) {
|
DialogUtil.getDelAndSureDialog(this, getString(R.string.您还没有完善车辆信息), {}, {
|
startActivity<ChangeCarActivity>()
|
})
|
}
|
}
|
}
|
|
var qeeOrderView = object : MyApplication.OrderStatueView {
|
override fun orderInfo(data: OrderSimpleData?) {
|
data?.let {
|
when (it.orderType) {
|
1, 2, 3 -> {
|
if (it.status == 10 || it.status == 12) {
|
Handler(Looper.getMainLooper()).post {
|
mainFragment?.refresh()
|
// MyApplication.getTTsManager().setVideoText(getString(R.string.有用户订单被取消或改派))
|
}
|
}
|
}
|
}
|
|
}
|
}
|
}
|
|
private fun checkGps() {
|
if (!AMapKit.isLocServiceEnable(this)) {
|
DialogUtil.getDelAndSureDialog(this,
|
getString(R.string.查看定位),
|
getString(R.string.退出),
|
getString(
|
R.string.您暂未开启手机定位
|
),
|
{
|
onBackPressed()
|
}) {
|
val intent = Intent()
|
intent.action = Settings.ACTION_LOCATION_SOURCE_SETTINGS;
|
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK;
|
try {
|
startActivity(intent)
|
} catch (ex: ActivityNotFoundException) { //如果页面无法打开,进入设置页面
|
intent.action = Settings.ACTION_SETTINGS
|
try {
|
startActivity(intent)
|
} catch (e: Exception) {
|
e.printStackTrace()
|
}
|
}
|
}
|
}
|
|
// if (!MyUtils.canBackgroundStart(this)) {
|
// DialogUtil.getDelAndSureDialog(this, getString(R.string.前往开启), getString(R.string.退出), getString(
|
// R.string.可能导致无法接单), {
|
// onBackPressed()
|
// }) {
|
// MyUtils.toSettingPro(this)
|
// }
|
// }
|
}
|
|
private fun callVersion() {
|
var map = getMapByAny()
|
// map["id"] = CacheKey.getUserId()
|
callNet(Api.queryNewData, map) {
|
var data = gson.fromJson<VersionBean>(it, VersionBean::class.java)
|
if (data.data.version != "" && data.data.version != getVersionName()) {
|
if (data.data.mandatory == 2) {
|
DialogUtil.getDelAndSureDialog(
|
this,
|
getString(R.string.新版本更新),
|
data.data.content,
|
{},
|
{
|
browse(data.data.url)
|
})
|
} else if (data.data.mandatory == 1) {
|
DialogUtil.getDelAndSureDialog(
|
this,
|
getString(R.string.新版本更新),
|
data.data.content,
|
{
|
EventBus.getDefault().post(BaseEvent(BaseEvent.OUT_APP))
|
},
|
{
|
browse(data.data.url)
|
})
|
} else {
|
// toast("已经是最新版本")
|
}
|
} else {
|
// toast("已经是最新版本")
|
}
|
}
|
}
|
|
lateinit var aMap: GoogleMap
|
override fun onCreate(savedInstanceState: Bundle?) {
|
super.onCreate(savedInstanceState)
|
if (CacheKey.getKeyStr(Const.REFUSE_LOCATION)
|
.isNotEmpty() && !RxPermissions(this).isGranted(
|
Manifest.permission.ACCESS_FINE_LOCATION
|
)
|
) {
|
toast("Without positioning permission, you will not be able to receive new order push notifications")
|
} else {
|
if (!RxPermissions(this).isGranted(Manifest.permission.ACCESS_FINE_LOCATION)) {
|
DialogUtil.getDelAndSureDialog(
|
this,
|
getString(R.string.确认),
|
getString(R.string.拒绝权限),
|
getString(R.string.定位权限说明),
|
{
|
}) {
|
val subscribe =
|
RxPermissions(this).request(Manifest.permission.ACCESS_FINE_LOCATION)
|
.subscribe {
|
if (!it) {
|
toast("Without positioning permission, you will not be able to receive new order push notifications")
|
CacheKey.putKeyStr(Const.REFUSE_LOCATION, "1")
|
} else
|
initLocation()
|
}
|
}
|
} else
|
initLocation()
|
}
|
}
|
|
@SuppressLint("MissingPermission", "CheckResult")
|
private fun initLocation() {
|
val fragment = map_view as SupportMapFragment
|
AMapKit.initMap(fragment) {
|
// zmc-remark 测试代码 给个初始位置
|
// MyApplication.aMapLocation = LatLng(30.659221715540937,104.06676612263988)
|
|
aMap = it
|
RxPermissions(this).request(Manifest.permission.ACCESS_FINE_LOCATION).subscribe {
|
if (it) {
|
aMap.isMyLocationEnabled = true
|
aMap.setOnMyLocationChangeListener {
|
it.let { latlon ->
|
Log.e("定位==============》", "${it.latitude},${it.longitude}")
|
MyApplication.aMapLocation = LatLng(it.latitude, it.longitude)
|
}
|
}
|
|
|
// val fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
|
// val locationRequest = LocationRequest.create().apply {
|
// interval = 10000 // 10秒间隔
|
// priority = LocationRequest.PRIORITY_HIGH_ACCURACY
|
// }
|
//
|
// fusedLocationClient.requestLocationUpdates(locationRequest,
|
// object : LocationCallback() {
|
// override fun onLocationResult(it: LocationResult) {
|
// // 处理位置更新
|
// Log.e("定位 by fusedLocationClient ==============》","${it.lastLocation?.latitude},${it.lastLocation?.longitude}")
|
// }
|
// }, Looper.getMainLooper()
|
// )
|
|
} else {
|
|
}
|
}
|
}
|
}
|
|
|
override fun onResume() {
|
super.onResume()
|
mainFragment?.refresh()
|
callNet(Api.needToSettle, getMapByAny()) {
|
var bean = gson.fromJson(it, BooleanBean::class.java).data
|
if (bean) {
|
showPayDialog()
|
}
|
}
|
}
|
|
fun beOnDuty(b: Boolean) {
|
if (b) {
|
// avv_anim.visible()
|
// tv_up_avv.visible()
|
} else {
|
avv_anim.gone()
|
tv_up_avv.gone()
|
}
|
}
|
|
|
private fun initCall() {
|
var map = getMapByAny()
|
callNet(Api.queryHomeData, map) {
|
var data = gson.fromJson<HomeDataBean>(it, HomeDataBean::class.java)
|
homeDataBean = data
|
clickCallOrder()
|
tv_order_num.text = data.data.dayNum.toString()
|
tv_month_order.text = data.data.mouthNum.toString()
|
// tv_grade.text = getFormatOne(data.data.score)
|
tv_task.text = data.data.activity.toString()
|
tv_car_num.text = data.data.licensePlate
|
tv_core.text = doubleOne(data.data.score).toString()
|
tv_lien_name.text = data.data.brand.toString()
|
tv_car.text =
|
if (data.data.work == 1) getString(R.string.下班) else getString(R.string.出车)
|
if (data.data.work == 1) {
|
/*try {
|
vehicleReporter?.setVehicleState(RidesharingVehicleReporter.VehicleState.ONLINE)
|
} catch (e: Exception) {
|
|
}*/
|
// MyApplication.getTTsManager().setVideoText(getString(R.string.您正在上班中))
|
beOnDuty(true)
|
} else {
|
// MyApplication.getTTsManager().setVideoText(getString(R.string.您已下班))
|
beOnDuty(false)
|
}
|
tv_time.text = getFormantDay(System.currentTimeMillis()) + " " + DateUtil.getWeek(
|
this,
|
System.currentTimeMillis()
|
)
|
}
|
}
|
|
fun callNum() {
|
var map = getMapByAny()
|
callNet(Api.queryHomeData, map) {
|
var data = gson.fromJson<HomeDataBean>(it, HomeDataBean::class.java)
|
homeDataBean = data
|
tv_order_num.text = data.data.dayNum.toString()
|
tv_month_order.text = data.data.mouthNum.toString()
|
// tv_grade.text = getFormatOne(data.data.score)
|
tv_task.text = data.data.activity.toString()
|
tv_car_num.text = data.data.licensePlate
|
tv_lien_name.text = data.data.brand.toString()
|
tv_time.text = getFormantDay(System.currentTimeMillis()) + " " + DateUtil.getWeek(
|
this,
|
System.currentTimeMillis()
|
)
|
}
|
}
|
|
/**
|
* 根据语言格式化日期显示
|
*/
|
private fun getFormantDay(time: Long): String {
|
val language = SPUtils.getString(Const.language)
|
return if (language == Const.Language.ENGLISH) time.toTimeEnglish() else if (language == Const.Language.FRENCH) time.toTimeFrench() else time.toTime(
|
"MM月dd日"
|
)
|
}
|
|
|
override fun setOnclick() {
|
tv_server_ing.setOnClickListener {
|
tv_server_ing.textColor(this, R.color.blue_1)
|
tv_wait_server.textColor(this, R.color.main_gray)
|
mainFragment.state = 1
|
mainFragment.autoRefresh()
|
}
|
|
tv_wait_server.setOnClickListener {
|
tv_server_ing.textColor(this, R.color.main_gray)
|
tv_wait_server.textColor(this, R.color.blue_1)
|
mainFragment.state = 2
|
mainFragment.autoRefresh()
|
}
|
|
|
tv_Left.clickDelay {
|
startActivity<MineActivity>()
|
}
|
|
iv_right_title.clickDelay {
|
|
}
|
|
tv_history_order.clickDelay {
|
startActivity<HistoryOrderActivity>()
|
}
|
|
ll_task.clickDelay {
|
startActivity<MineEventActivity>()
|
}
|
|
clickCallOrder()
|
}
|
|
private fun clickCallOrder(){
|
tv_car.clickDelay {
|
if (homeDataBean?.data?.work == 1) {
|
callNet(Api.work, getMapByAny()) {
|
homeDataBean?.data?.work = 2
|
tv_car.text = getString(R.string.出车)
|
beOnDuty(false)
|
val bean = Gson().fromJson<UpCarInfo>(it, UpCarInfo::class.java)
|
MyApplication.getTTsManager().setVideoText(bean.data?.audioUrl)
|
}
|
} else {
|
callNet(Api.needToSettle, getMapByAny()) {
|
var bean = gson.fromJson(it, BooleanBean::class.java).data
|
if (bean) {
|
showPayDialog()
|
} else {
|
judgeAccountEffective {
|
callNet(Api.queryMyBusiness, getMapByAny()) {
|
var bean = gson.fromJson(it, SelectServerModeBean::class.java).data
|
if (bean.isEmpty()) {
|
toast(getString(R.string.请选择接单业务))
|
return@callNet
|
}
|
if (bean.size > 1) {
|
startActivity<SelectServerModeActivity>()
|
} else {
|
var map = getMapByAny()
|
map["type"] = bean[0].id
|
callNet(Api.work, map) {
|
var carinfo = gson.fromJson<UpCarInfo>(
|
it,
|
UpCarInfo::class.java
|
)
|
if (carinfo.data?.jumpCode == "200000") {
|
DialogUtil.getDelAndSureDialog(
|
this,
|
getString(R.string.您还没有完善车辆信息),
|
{},
|
{
|
startActivity<ChangeCarActivity>()
|
})
|
} else {
|
toast(getString(R.string.上班成功))
|
beOnDuty(true)
|
MyApplication.getTTsManager()
|
.setVideoText(carinfo.data?.audioUrl)
|
CacheKey.putKeyStr(
|
"vehicleId",
|
carinfo.data?.vehicleId ?: ""
|
)
|
EventBus.getDefault()
|
.post(BaseEvent(BaseEvent.START_CAR))
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
|
/**判断账户是否有效
|
* @param effectiveCallback 能够操作的回调*/
|
private fun judgeAccountEffective(effectiveCallback: () -> Unit) {
|
callNet(Api.queryInfo, getMapByAny()) {
|
val user = gson.fromJson<UserBean>(it, UserBean::class.java)
|
if (user.data == null) {
|
return@callNet
|
}
|
val min = 40000
|
if (user.data.accountBalance < min) {
|
showNoticeAccountBalanceDialog(min)
|
return@callNet
|
}
|
effectiveCallback.invoke()
|
}
|
}
|
|
/**显示提示账户余额弹窗
|
* @param min 最低金额*/
|
private fun showNoticeAccountBalanceDialog(min: Int) {
|
val l = SPUtils.getString(Const.language)
|
val sure: String
|
val cancel: String
|
val content: String
|
val warn: String
|
when (l) {
|
Const.Language.FRENCH -> {
|
sure = getString(R.string.充值)
|
cancel = "Fermer"
|
warn = "Rappel"
|
content = "Solde inférieur à $min xifa, s'il vous plaît recharger d'abord"
|
}
|
|
Const.Language.CHINESE, "zh" -> {
|
sure = getString(R.string.充值)
|
cancel = "关闭"
|
warn = "提示"
|
content = "余额不足${min}西法,请先充值"
|
}
|
|
else -> {
|
sure = getString(R.string.充值)
|
cancel = "Close"
|
warn = "Reminder"
|
content = "The balance is less than $min Spanish francs, please recharge first"
|
}
|
}
|
val delAndSureDialog = getDelAndSureDialog(
|
this,
|
sure,
|
cancel,
|
content,
|
{}) {
|
startActivity<BalanceTopupActivity>()
|
}
|
delAndSureDialog.window?.decorView?.let {
|
it.find<TextView>(R.id.tv_hint_base).text = warn
|
}
|
}
|
private fun showPayDialog() {
|
val l = SPUtils.getString(Const.language)
|
val pay:String
|
val off:String
|
val msg:String
|
val warn:String
|
when(l){
|
Const.Language.FRENCH->{
|
pay = "Payer"
|
off = "Fermer"
|
warn = "Rappel"
|
msg = "Vous avez des frais de règlement en attente de paiement, vous ne pouvez recevoir des commandes qu’après paiement, veuillez payer dès que possible"
|
}
|
Const.Language.CHINESE,"zh"->{
|
pay = "支付"
|
off = "关闭"
|
warn = "提示"
|
msg = "您有一笔结算费待支付,须支付后才能接单,请尽快支付"
|
}
|
else->{
|
pay = "Pay"
|
off = "Close"
|
warn = "Reminder"
|
msg = "You have a settlement fee pending payment, you can only receive orders after payment, please pay as soon as possible"
|
}
|
}
|
val delAndSureDialog = getDelAndSureDialog(this,
|
pay,
|
off,
|
msg,
|
{}) {
|
startActivity<OfflinePayActivity>()
|
}
|
delAndSureDialog.window?.decorView?.let {
|
it.find<TextView>(R.id.tv_hint_base).text = warn
|
}
|
}
|
|
|
private
|
var mBackAppTime: Long = 0
|
|
override fun onBackPressed() {
|
if (System.currentTimeMillis() - mBackAppTime > 2000) {
|
Toast.makeText(this, getString(R.string.再按一次退出程序), Toast.LENGTH_SHORT).show()
|
mBackAppTime = System.currentTimeMillis()
|
} else {
|
closeAll()
|
MyApplication.hasAutoGoTripping = false
|
}
|
}
|
|
override fun onEventMainThread(event: BaseEvent?) {
|
super.onEventMainThread(event)
|
when (event!!.code) {
|
BaseEvent.START_CAR -> {
|
beOnDuty(true)
|
/* if (vehicleReporter == null) {
|
initDriver()
|
}*/
|
initCall()
|
}
|
|
BaseEvent.CHANGE_CAR_SUCCESS -> {
|
initCall()
|
}
|
|
BaseEvent.CALL_NUM_MAIN -> {
|
callNum()
|
}
|
|
BaseEvent.REFREASH_MAIN -> {
|
mainFragment?.refresh()
|
}
|
|
BaseEvent.OFF_LINE -> {
|
Thread() {
|
try {
|
/* vehicleReporter?.disableLocationTracking()
|
RidesharingDriverApi.clearInstance()*/
|
} catch (e: Exception) {
|
}
|
}.start()
|
}
|
|
BaseEvent.FORCED_OFFLINE -> {
|
initCall()
|
}
|
}
|
}
|
|
override fun onStop() {
|
super.onStop()
|
}
|
|
|
/* override fun updateStatus(
|
p0: DriverContext.DriverStatusListener.StatusLevel,
|
p1: DriverContext.DriverStatusListener.StatusCode,
|
p2: String,
|
p3: Throwable?,
|
) {
|
Log.e(
|
Const.GoogleDriver.TAG,
|
"StatusLevel:${p0.name},StatusCode:${p1},p2:${p2},错误信息:${p3?.message}"
|
)
|
}
|
|
override fun onDestroy() {
|
super.onDestroy()
|
RidesharingDriverApi.clearInstance()
|
}*/
|
}
|