opt compile warn
This commit is contained in:
@@ -39,8 +39,8 @@ const val CarNet_Geo:String = "CarNet_Geo_Location" //上传服务端, type=1开
|
||||
const val CarNet_live_broadcast = "CarNet_live_broadcast" // 地图页面点击直播(在线可直播车机)
|
||||
//自定义埋点
|
||||
@DebugLog
|
||||
fun trackNormalEvent(event: String, data: MutableMap<String, Any>?, context: Context = AbsMogoApplication.getApp().applicationContext) {
|
||||
var data = data
|
||||
fun trackNormalEvent(event: String, _data: MutableMap<String, Any>?, context: Context = AbsMogoApplication.getApp().applicationContext) {
|
||||
var data = _data
|
||||
if (data == null) {
|
||||
data = HashMap()
|
||||
}
|
||||
|
||||
@@ -138,10 +138,10 @@ fun getCompressVideoPath(): String {
|
||||
* 保存图片到本地
|
||||
*/
|
||||
fun saveImageToSdcard(bmp: Bitmap): Boolean {
|
||||
var currentFile: File
|
||||
lateinit var fos: FileOutputStream
|
||||
val currentFile: File
|
||||
var fos: FileOutputStream? = null
|
||||
|
||||
var picFile = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
||||
val picFile = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
|
||||
picFile.mkdirs()
|
||||
|
||||
val builder = StringBuilder()
|
||||
@@ -162,9 +162,7 @@ fun saveImageToSdcard(bmp: Bitmap): Boolean {
|
||||
return false
|
||||
} finally {
|
||||
try {
|
||||
if (fos != null) {
|
||||
fos.close()
|
||||
}
|
||||
fos?.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
return false
|
||||
|
||||
@@ -72,7 +72,7 @@ class LocationUtil private constructor() {
|
||||
private var locationClient: AMapLocationClient? = null
|
||||
private var locationOption: AMapLocationClientOption? = null
|
||||
private var speedListener: SpeedListener? = null
|
||||
private var locationInfo: LocationInfo = LocationInfo()
|
||||
private var locationInfo: LocationInfo? = null
|
||||
private var speed: Float = 0.0f
|
||||
|
||||
fun initLocation() {
|
||||
@@ -125,24 +125,21 @@ class LocationUtil private constructor() {
|
||||
*/
|
||||
private var locationListener: AMapLocationListener = AMapLocationListener { location ->
|
||||
if (null != location) {
|
||||
locationInfo.longitude = location.longitude
|
||||
locationInfo.latitude = location.latitude
|
||||
locationInfo.address = location.address
|
||||
locationInfo.time = location.time
|
||||
locationInfo.provinceName = location.province
|
||||
locationInfo.cityName = location.city
|
||||
locationInfo.cityCode = location.cityCode
|
||||
locationInfo.areaName = location.district
|
||||
locationInfo.areaCode = location.adCode
|
||||
locationInfo.street = location.street
|
||||
locationInfo.direction = location.bearing
|
||||
listener?.let {
|
||||
it.onChanged(locationInfo)
|
||||
}
|
||||
locationInfo = LocationInfo()
|
||||
locationInfo!!.longitude = location.longitude
|
||||
locationInfo!!.latitude = location.latitude
|
||||
locationInfo!!.address = location.address
|
||||
locationInfo!!.time = location.time
|
||||
locationInfo!!.provinceName = location.province
|
||||
locationInfo!!.cityName = location.city
|
||||
locationInfo!!.cityCode = location.cityCode
|
||||
locationInfo!!.areaName = location.district
|
||||
locationInfo!!.areaCode = location.adCode
|
||||
locationInfo!!.street = location.street
|
||||
locationInfo!!.direction = location.bearing
|
||||
listener?.onChanged(locationInfo!!)
|
||||
speed = location.speed
|
||||
speedListener?.let {
|
||||
it.onSpeedGet(location.speed)
|
||||
}
|
||||
speedListener?.onSpeedGet(location.speed)
|
||||
} else {
|
||||
Log.d(TAG, "定位失败 -> location is null")
|
||||
}
|
||||
@@ -160,13 +157,12 @@ class LocationUtil private constructor() {
|
||||
|
||||
fun getLocationInfo(): LocationInfo {
|
||||
return if (null != locationInfo) {
|
||||
locationInfo
|
||||
locationInfo!!
|
||||
} else {
|
||||
if (null == locationClient) {
|
||||
locationClient = AMapLocationClient(mContext)
|
||||
this.locationClient = locationClient
|
||||
}
|
||||
var location = locationClient!!.lastKnownLocation
|
||||
val location = locationClient!!.lastKnownLocation
|
||||
location.toLocInfo(location)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zhidao.roadcondition.util
|
||||
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
@ObsoleteCoroutinesApi
|
||||
@PublishedApi
|
||||
internal var ThreadPool =
|
||||
newFixedThreadPoolContext(Runtime.getRuntime().availableProcessors() * 2, "ThreadPool")
|
||||
@@ -11,16 +12,17 @@ internal var ThreadPool =
|
||||
* 在主线程中顺序执行,协程函数,一般用于最外层
|
||||
* 该函数会阻塞代码继续执行
|
||||
*/
|
||||
inline fun taskBlockOnMainThread(delayTime: Long = 0, noinline job: suspend () -> Unit) = runBlocking {
|
||||
delay(delayTime)
|
||||
job()
|
||||
}
|
||||
//inline fun taskBlockOnMainThread(delayTime: Long = 0, noinline job: suspend () -> Unit) = runBlocking {
|
||||
// delay(delayTime)
|
||||
// job()
|
||||
//}
|
||||
|
||||
/**
|
||||
* 并发执行,常用于最外层
|
||||
* 特点带返回值
|
||||
*/
|
||||
inline fun <T> taskAsync(delayTime: Long = 0, noinline job: suspend () -> T) = GlobalScope.async(ThreadPool) {
|
||||
@ObsoleteCoroutinesApi
|
||||
fun <T> taskAsync(delayTime: Long = 0, job: suspend () -> T) = GlobalScope.async(ThreadPool) {
|
||||
delay(delayTime)
|
||||
job()
|
||||
}
|
||||
Reference in New Issue
Block a user