| | |
| | | startActivity<ServiceActivity>() |
| | | } |
| | | iv_scan.setOnClickListener { |
| | | if (checkLogin()) |
| | | RxPermissions(this).request(Manifest.permission.CAMERA).subscribe { |
| | | if (it) |
| | | startActivity<ScanActivity>( |
| | | "startLat" to startLat, |
| | | "startLon" to startLon, |
| | | "startName" to startName |
| | | ) |
| | | else |
| | | myToast("请在应用权限页面开启相机权限") |
| | | if (checkLogin()) { |
| | | if (!RxPermissions(this).isGranted(Manifest.permission.CAMERA) //没有权限且明确拒绝就不再申请权限 |
| | | && SPUtils.instance().getBoolean(Const.User.IS_REFUSE_PERMISSION_CAMERA) |
| | | ) { |
| | | myToast("请在应用权限页面开启相机权限") |
| | | } else { |
| | | RxPermissions(this).request(Manifest.permission.CAMERA).subscribe { |
| | | if (it) |
| | | startActivity<ScanActivity>( |
| | | "startLat" to startLat, |
| | | "startLon" to startLon, |
| | | "startName" to startName |
| | | ) |
| | | else{ |
| | | myToast("请在应用权限页面开启相机权限") |
| | | SPUtils.instance().put(Const.User.IS_REFUSE_PERMISSION_CAMERA,true).apply() |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | isOpen = intent.getBooleanExtra("isOpen", false) |
| | | lat = intent.getDoubleExtra("lat", 0.0) |
| | | lon = intent.getDoubleExtra("lon", 0.0) |
| | | if (!isOpen){ |
| | | if (!isOpen) { |
| | | initLocation { |
| | | initLocationS { b, fucS -> |
| | | cl_title.visible() |
| | | initTwoView(b, fucS, FBApplication.lat, FBApplication.lon) |
| | | } |
| | | } |
| | | }else{ |
| | | } else { |
| | | cl_title.visible() |
| | | initTwoView(isOpen, func?: arrayListOf(), FBApplication.lat, FBApplication.lon) |
| | | initTwoView( |
| | | isOpen, |
| | | func ?: arrayListOf(), |
| | | if (lat != 0.0) lat else FBApplication.lat, |
| | | if (lon != 0.0) lon else FBApplication.lon |
| | | ) |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | private fun initLocation(function: () -> Unit) { |
| | | val disposable = |
| | | RxPermissions(this@MainActivity).request(Manifest.permission.ACCESS_FINE_LOCATION) |
| | | .subscribe { |
| | | if (it) { |
| | | function() |
| | | } else { |
| | | |
| | | if (!RxPermissions(this).isGranted(Manifest.permission.ACCESS_FINE_LOCATION) //没有权限且明确拒绝就不再申请权限 |
| | | && SPUtils.instance().getBoolean(Const.User.IS_REFUSE_PERMISSION_LOCATION) |
| | | ) { |
| | | initTwoView(false, arrayListOf(), 0.0, 0.0) |
| | | } else { |
| | | val disposable = |
| | | RxPermissions(this@MainActivity).request(Manifest.permission.ACCESS_FINE_LOCATION) |
| | | .subscribe { |
| | | if (it) { |
| | | function() |
| | | } else { |
| | | SPUtils.instance().put(Const.User.IS_REFUSE_PERMISSION_LOCATION, true) |
| | | .apply() |
| | | initTwoView(false, arrayListOf(), 0.0, 0.0) |
| | | } |
| | | } |
| | | } |
| | | onBindHelper(disposable) |
| | | onBindHelper(disposable) |
| | | } |
| | | } |
| | | |
| | | private fun showAlert() { |