| | |
| | | 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.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 |
| | |
| | | } |
| | | |
| | | var homeDataBean: HomeDataBean? = null |
| | | /* var navigator: Navigator? = null |
| | | var vehicleReporter: RidesharingVehicleReporter? = null*/ |
| | | /* var navigator: Navigator? = null |
| | | var vehicleReporter: RidesharingVehicleReporter? = null*/ |
| | | |
| | | private val MSG_REFRESH_LOCATIAON = 1 |
| | | |
| | |
| | | |
| | | 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() ) |
| | | } |
| | | } |
| | | }*/ |
| | | /* 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司机)) |
| | | // setTitleText(getString(R.string.IGO司机)) |
| | | tv_Left.setDrawableLeft(R.mipmap.icon_nav_user) |
| | | // iv_right_title.setImageResource(R.mipmap.icon_nav_news) |
| | | // iv_right_title.setImageResource(R.mipmap.icon_nav_news) |
| | | |
| | | findViewById<View>(R.id.img_leftuser).setOnClickListener { |
| | | startActivity<MineActivity>() |
| | |
| | | // showOrder("","12634","1",10,1) |
| | | } |
| | | |
| | | // initDriver() |
| | | // initDriver() |
| | | MyApplication.isLogin = true |
| | | beOnDuty(false) |
| | | initCall() |
| | |
| | | /** |
| | | * 初始化司机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") |
| | | } |
| | | /* 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 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() |
| | |
| | | } |
| | | |
| | | private fun callTime(type: String) { |
| | | OrderTimeOutManager.instance.init() |
| | | var map = getMapByAny() |
| | | callNet(Api.getDriverOnlineTime, map) { |
| | | var bean = gson.fromJson<TimeBean>(it, TimeBean::class.java) |
| | |
| | | } |
| | | } |
| | | |
| | | var qeeOrderView = object : MyApplication.OrderStatueView { |
| | | private var qeeOrderView = object : MyApplication.OrderStatueView { |
| | | override fun orderInfo(data: OrderSimpleData?) { |
| | | data?.let { |
| | | when (it.orderType) { |
| | |
| | | |
| | | private fun checkGps() { |
| | | if (!AMapKit.isLocServiceEnable(this)) { |
| | | DialogUtil.getDelAndSureDialog(this, |
| | | DialogUtil.getDelAndSureDialog( |
| | | this, |
| | | getString(R.string.查看定位), |
| | | getString(R.string.退出), |
| | | getString( |
| | |
| | | } |
| | | |
| | | private fun callVersion() { |
| | | var map = getMapByAny() |
| | | val map = getMapByAny() |
| | | // map["id"] = CacheKey.getUserId() |
| | | callNet(Api.queryNewData, map) { |
| | | var data = gson.fromJson<VersionBean>(it, VersionBean::class.java) |
| | | callNet(isUseAllTrustService = true, showDialog = true, api = Api.queryNewData, map = map, clickAction = { |
| | | val 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("已经是最新版本") |
| | | when (data.data.mandatory) { |
| | | 2 -> { |
| | | DialogUtil.getDelAndSureDialog( |
| | | this, |
| | | getString(R.string.新版本更新), |
| | | data.data.content, |
| | | {}, |
| | | { |
| | | browse(data.data.url) |
| | | }) |
| | | } |
| | | |
| | | 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("已经是最新版本") |
| | | } |
| | | }) { _, _ -> |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | @SuppressLint("MissingPermission", "CheckResult") |
| | | private fun initLocation() { |
| | | val fragment = map_view as SupportMapFragment |
| | | AMapKit.initMap(fragment) { |
| | | AMapKit.initMap(fragment) { it -> |
| | | // 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) |
| | | } |
| | | } |
| | | |
| | | aMap.isMyLocationEnabled = true |
| | | aMap.setOnMyLocationChangeListener { |
| | | it?.let { |
| | | Log.e("定位==============》", "${it.latitude},${it.longitude}") |
| | | MyApplication.setLocation(it.latitude, it.longitude) |
| | | } |
| | | } |
| | | |
| | | // val fusedLocationClient = LocationServices.getFusedLocationProviderClient(this) |
| | | // val locationRequest = LocationRequest.create().apply { |
| | |
| | | // } |
| | | // }, Looper.getMainLooper() |
| | | // ) |
| | | |
| | | } else { |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | fun beOnDuty(b: Boolean) { |
| | | if (b) { |
| | | // avv_anim.visible() |
| | | // tv_up_avv.visible() |
| | | // avv_anim.visible() |
| | | // tv_up_avv.visible() |
| | | } else { |
| | | avv_anim.gone() |
| | | tv_up_avv.gone() |
| | |
| | | */ |
| | | private fun getFormantDay(time: Long): String { |
| | | val language = SPUtils.getString(Const.language) |
| | | return if (language == "en") time.toTimeEnglish() else if (language == "fr") time.toTimeFrench() else time.toTime( |
| | | return if (language == Const.Language.ENGLISH) time.toTimeEnglish() else if (language == Const.Language.FRENCH) time.toTimeFrench() else time.toTime( |
| | | "MM月dd日" |
| | | ) |
| | | } |
| | |
| | | clickCallOrder() |
| | | } |
| | | |
| | | private fun clickCallOrder(){ |
| | | private fun clickCallOrder() { |
| | | tv_car.clickDelay { |
| | | if (homeDataBean?.data?.work == 1) { |
| | | callNet(Api.work, getMapByAny()) { |
| | |
| | | if (user.data == null) { |
| | | return@callNet |
| | | } |
| | | val min = 40000 |
| | | if (user.data.accountBalance < min) { |
| | | showNoticeAccountBalanceDialog(min) |
| | | if (!user.data.couldTakeOrder()) { |
| | | showNoticeAccountBalanceDialog(user.data.orderMinBalance) |
| | | return@callNet |
| | | } |
| | | effectiveCallback.invoke() |
| | |
| | | |
| | | /**显示提示账户余额弹窗 |
| | | * @param min 最低金额*/ |
| | | private fun showNoticeAccountBalanceDialog(min: Int) { |
| | | private fun showNoticeAccountBalanceDialog(min: String) { |
| | | val l = SPUtils.getString(Const.language) |
| | | val sure: String |
| | | val cancel: String |
| | | val content: String |
| | | val warn: String |
| | | when (l) { |
| | | "fr" -> { |
| | | 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" |
| | | content = "Solde inférieur à FCFA$min, s'il vous plaît recharger d'abord" |
| | | } |
| | | |
| | | "ch", "zh" -> { |
| | | Const.Language.CHINESE, "zh" -> { |
| | | sure = getString(R.string.充值) |
| | | cancel = "关闭" |
| | | warn = "提示" |
| | | content = "余额不足${min}西法,请先充值" |
| | | content = "余额不足FCFA${min},请先充值" |
| | | } |
| | | |
| | | else -> { |
| | | sure = getString(R.string.充值) |
| | | cancel = "Close" |
| | | warn = "Reminder" |
| | | content = "The balance is less than $min Spanish francs, please recharge first" |
| | | content = "The balance is less than FCFA$min, please recharge first" |
| | | } |
| | | } |
| | | val delAndSureDialog = getDelAndSureDialog( |
| | |
| | | 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){ |
| | | "fr"->{ |
| | | 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" |
| | | 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" |
| | | } |
| | | "ch","zh"->{ |
| | | |
| | | Const.Language.CHINESE, "zh" -> { |
| | | pay = "支付" |
| | | off = "关闭" |
| | | warn = "提示" |
| | | msg = "您有一笔结算费待支付,须支付后才能接单,请尽快支付" |
| | | } |
| | | else->{ |
| | | |
| | | 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" |
| | | 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, |
| | | val delAndSureDialog = getDelAndSureDialog( |
| | | this, |
| | | pay, |
| | | off, |
| | | msg, |
| | |
| | | when (event!!.code) { |
| | | BaseEvent.START_CAR -> { |
| | | beOnDuty(true) |
| | | /* if (vehicleReporter == null) { |
| | | initDriver() |
| | | }*/ |
| | | /* if (vehicleReporter == null) { |
| | | initDriver() |
| | | }*/ |
| | | initCall() |
| | | } |
| | | |
| | |
| | | BaseEvent.OFF_LINE -> { |
| | | Thread() { |
| | | try { |
| | | /* vehicleReporter?.disableLocationTracking() |
| | | RidesharingDriverApi.clearInstance()*/ |
| | | /* vehicleReporter?.disableLocationTracking() |
| | | RidesharingDriverApi.clearInstance()*/ |
| | | } catch (e: Exception) { |
| | | } |
| | | }.start() |
| | |
| | | } |
| | | |
| | | |
| | | /* 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 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() |
| | | }*/ |
| | | MyApplication.removeOrderView(qeeOrderView) |
| | | } |
| | | } |