| | |
| | | package com.fuban.driver.ui.main |
| | | |
| | | import android.Manifest |
| | | import android.content.ActivityNotFoundException |
| | | import android.content.Intent |
| | | import android.os.Handler |
| | |
| | | import com.fuban.driver.utils.download.DownloadUtil |
| | | import com.google.gson.Gson |
| | | import com.lljjcoder.style.citylist.Toast.ToastUtils |
| | | import com.tbruyelle.rxpermissions2.RxPermissions |
| | | import kotlinx.android.synthetic.main.activity_main.* |
| | | import kotlinx.android.synthetic.main.app_title.* |
| | | import org.greenrobot.eventbus.EventBus |
| | |
| | | } |
| | | |
| | | override fun initView() { |
| | | MyApplication.canPlayVoice = true |
| | | // var packageName = "com.android.providers.downloads"; |
| | | // var intent = Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| | | // intent.setData(Uri.parse("package:" + packageName)); |
| | | // startActivity(intent); |
| | | ActivityCompat.requestPermissions(this, Const.PERMISSIONS_LIST, 101); |
| | | setTitleText("福伴出行司机") |
| | | if (CacheKey.getKeyStr(Const.REFUSE_LOCATION).isNotEmpty()&&!RxPermissions(this).isGranted(Manifest.permission.ACCESS_FINE_LOCATION)){ |
| | | toast("没有定位权限,您将无法收到新订单推送") |
| | | }else{ |
| | | if (!RxPermissions(this).isGranted(Manifest.permission.ACCESS_FINE_LOCATION)){ |
| | | DialogUtil.getDelAndSureDialog(this,"去授权","否","《福伴司机》需要获取您的当前位置信息,用于查询当前城市是否开通服务,我们会将您的位置实时上传至后端为您匹配和推送附近订单。如果拒绝定位权限,您将无法正常接单。",{ |
| | | }){ |
| | | val subscribe = |
| | | RxPermissions(this).request(Manifest.permission.ACCESS_FINE_LOCATION).subscribe { |
| | | if (!it){ |
| | | toast("没有定位权限,您将无法收到新订单推送") |
| | | CacheKey.putKeyStr(Const.REFUSE_LOCATION,"1") |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | setTitleText("福伴司机") |
| | | tv_Left.setDrawableLeft(R.mipmap.icon_nav_user) |
| | | iv_right_title.setImageResource(R.mipmap.icon_nav_news) |
| | | addFragment(mainFragment, R.id.rl_container) |
| | |
| | | MyApplication.addOrderView(qeeOrderView) |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | var qeeOrderView = object : MyApplication.OrderStatueView { |
| | | override fun orderInfo(data: OrderSimpleData?) { |
| | |
| | | if (data.data.version != "" && data.data.version != Utils.getAppVersion(this)) { |
| | | if (data.data.mandatory == 2) { |
| | | DialogUtil.getDelAndSureDialog(this, "有新版本是否更新?", {}, { |
| | | DownloadUtil(this).downloadAPK(data.data.url, "福伴出行司机端") |
| | | DownloadUtil(this).downloadAPK(data.data.url, "福伴司机端") |
| | | }) |
| | | } else if (data.data.mandatory == 1) { |
| | | DialogUtil.getDelAndSureDialog(this, "版本已过时,是否强制升级?", { |
| | | EventBus.getDefault().post(BaseEvent(BaseEvent.OUT_APP)) |
| | | }, { |
| | | DownloadUtil(this).downloadAPK(data.data.url, "福伴出行司机端") |
| | | DownloadUtil(this).downloadAPK(data.data.url, "福伴司机端") |
| | | ToastUtils.showShortToast(this, "后台开始下载,请等待") |
| | | }) |
| | | }else{ |
| | |
| | | CacheKey.putKeyStr("location",Gson().toJson(p0)) |
| | | } |
| | | } |
| | | |
| | | override fun onDestroy() { |
| | | super.onDestroy() |
| | | MyApplication.canPlayVoice = false |
| | | } |
| | | } |