opt compile warn
This commit is contained in:
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -77,6 +77,7 @@
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
<option name="useQualifiedModuleNames" value="true" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
package com.zhidao.roadcondition.model
|
||||
|
||||
class CityStrategy {
|
||||
|
||||
var video: Video
|
||||
var pic: Pic
|
||||
|
||||
constructor(video: Video, pic: Pic) {
|
||||
this.video = video
|
||||
this.pic = pic
|
||||
}
|
||||
class CityStrategy(video: Video, pic: Pic) {
|
||||
var video: Video? = video
|
||||
var pic: Pic? = pic
|
||||
}
|
||||
|
||||
fun Video.getMaxSpeed(): Int {
|
||||
|
||||
@@ -3,6 +3,4 @@ package com.zhidao.roadcondition.model
|
||||
/**
|
||||
* 城市策略实体
|
||||
*/
|
||||
class Results(var cityStrategy: CityStrategy) {
|
||||
|
||||
}
|
||||
class Results(var cityStrategy: CityStrategy)
|
||||
@@ -18,7 +18,7 @@ class ResponseFunction<T> : Function<BaseResponse<T>, T> {
|
||||
}
|
||||
|
||||
override fun apply(t: BaseResponse<T>): T {
|
||||
if (t == null || !t.isSuccess(baseUrl)) {
|
||||
if (!t.isSuccess(baseUrl)) {
|
||||
throw ApiException(t.code, t.msg)
|
||||
}
|
||||
return t.result
|
||||
|
||||
@@ -45,7 +45,7 @@ object CosCallbackMapController : CosStatusCallback {
|
||||
|
||||
fun unregisterCallbacks(paths: Map<String, String>?) {
|
||||
paths?.let {
|
||||
it?.keys?.let { keys ->
|
||||
it.keys.let { keys ->
|
||||
keys.forEach { path ->
|
||||
unregisterCallback(path)
|
||||
}
|
||||
@@ -54,9 +54,7 @@ object CosCallbackMapController : CosStatusCallback {
|
||||
}
|
||||
|
||||
override fun onStartUpload(eventId: String?, localPath: String?) {
|
||||
map[localPath]?.let {
|
||||
it.onStartUpload(eventId, localPath)
|
||||
}
|
||||
map[localPath]?.onStartUpload(eventId, localPath)
|
||||
}
|
||||
|
||||
override fun uploadCosFailed(cosPath: String?, eventId: String?, localPath: String?) {
|
||||
|
||||
@@ -75,7 +75,7 @@ class CosStatusController : CosStatusCallback {
|
||||
|
||||
private fun sendGetInfoFailedReceiver(type: String) {
|
||||
Log.d(CarCorderController.TAG, "sendGetInfoFailedReceiver ------>")
|
||||
var intent = Intent()
|
||||
val intent = Intent()
|
||||
intent.action = "com.zhidao.roadcondition.getinfo.failed"
|
||||
intent.putExtra("type", type)
|
||||
AbsMogoApplication.getApp().applicationContext.sendBroadcast(intent)
|
||||
@@ -95,11 +95,11 @@ class CosStatusController : CosStatusCallback {
|
||||
// }
|
||||
// }
|
||||
} else {
|
||||
if (localPath!!.endsWith("mp4") || localPath!!.contains("Thumbnail")) {
|
||||
if (localPath!!.endsWith("mp4") || localPath.contains("Thumbnail")) {
|
||||
CosCallbackMapController.uploadFailed?.invoke()
|
||||
}
|
||||
CosCallbackMapController.unregisterCallback(localPath)
|
||||
InformationUploadController.release(entity?.id)
|
||||
InformationUploadController.release(entity.id)
|
||||
// deletePicFile(localPath)
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ class CosStatusController : CosStatusCallback {
|
||||
Log.d(TAG, "uploadCosCompleted downloadUrl = $downloadUrl")
|
||||
Log.d(TAG, "uploadCosCompleted cosPath = $cosPath")
|
||||
trackUploadCos(1)
|
||||
if (localPath!!.endsWith("mp4") || localPath!!.contains("Thumbnail")) {
|
||||
if (localPath!!.endsWith("mp4") || localPath.contains("Thumbnail")) {
|
||||
//如果是视频文件或者缩略图文件
|
||||
if (localPath.endsWith("mp4")) {
|
||||
videoAndThumbMap["video"] = downloadUrl!!
|
||||
@@ -127,7 +127,7 @@ class CosStatusController : CosStatusCallback {
|
||||
if (videoAndThumbMap.size == 2) {
|
||||
trackUploadCos(4)
|
||||
Log.d(TAG, "videoAndThumbMap.size == 2 ")
|
||||
var locationInfo = LocationUtil.getInstance().getLocationInfo()
|
||||
val locationInfo = LocationUtil.getInstance().getLocationInfo()
|
||||
val locationStr: String = Gson().toJson(locationInfo)
|
||||
Log.d(TAG, "locationStr = $locationStr")
|
||||
//上传录像以及缩略图成功
|
||||
@@ -155,7 +155,7 @@ class CosStatusController : CosStatusCallback {
|
||||
}
|
||||
|
||||
private fun sendInformation(type: Int, map: Map<String, String>) {
|
||||
Log.d(TAG, "isCustomSend = ${entity?.isCustom}")
|
||||
Log.d(TAG, "isCustomSend = ${entity.isCustom}")
|
||||
// if (entity?.isCustom) {
|
||||
// InformationUploadController.cosResourceReady(type, map, entity?.isCustom, entity?.id) {
|
||||
// CosCallbackMapController.mainService?.sendCustomResult(it)
|
||||
|
||||
@@ -75,7 +75,7 @@ object InformationUploadController {
|
||||
}
|
||||
}
|
||||
|
||||
private fun tryUploadInformation(ir: InformationResource?) {
|
||||
// private fun tryUploadInformation(ir: InformationResource?) {
|
||||
// synchronized(locker) {
|
||||
// ir?.let {
|
||||
// if (!it.isReady()) {
|
||||
@@ -106,7 +106,7 @@ object InformationUploadController {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
// }
|
||||
|
||||
fun release(id: Long) {
|
||||
val target = informationCache.remove(id)
|
||||
|
||||
@@ -132,11 +132,10 @@ class MainService : Service() {
|
||||
if (p1.action == alarmBroadAction) {
|
||||
if (p1.getIntExtra("AlarmType", 1) == AlarmTypePic) {
|
||||
//拍照
|
||||
var number = p1.getLongExtra("number", 1)
|
||||
takePhoto(number, true)
|
||||
takePhoto(true)
|
||||
} else {
|
||||
//录像
|
||||
var duration = p1.getIntExtra("duration", 3)
|
||||
val duration = p1.getIntExtra("duration", 3)
|
||||
takeVideo(duration, true)
|
||||
}
|
||||
}
|
||||
@@ -211,7 +210,7 @@ class MainService : Service() {
|
||||
// )
|
||||
}
|
||||
|
||||
private fun sendMarkerInfoReceiver(lat: Double, lon: Double, imageUrl: String?, type: String?) {
|
||||
// private fun sendMarkerInfoReceiver(lat: Double, lon: Double, imageUrl: String?, type: String?) {
|
||||
// Log.e("MainService", "sendMarkerInfoReceiver ------> type = $type ")
|
||||
// Log.e("MainService", "sendMarkerInfoReceiver ------> fromType = $fromType ")
|
||||
// Log.e("MainService", "sendMarkerInfoReceiver ------> isCustom = $isCustom ")
|
||||
@@ -224,7 +223,7 @@ class MainService : Service() {
|
||||
// intent.putExtra("custom", isCustom)
|
||||
// intent.putExtra("fromType", fromType)
|
||||
// sendBroadcast(intent)
|
||||
}
|
||||
// }
|
||||
|
||||
/**
|
||||
* 初始化定位监听
|
||||
@@ -266,7 +265,7 @@ class MainService : Service() {
|
||||
Log.d("MainService", "handleReportStrategy picType = $picType ---videoType = $videoType")
|
||||
shareType = TANLU_ROAD_CURRENT
|
||||
if (picType == 1) {
|
||||
takePhoto(1)
|
||||
takePhoto()
|
||||
} else if (picType == 2) {
|
||||
postPhotoAlarmTask(true)
|
||||
}
|
||||
@@ -291,7 +290,7 @@ class MainService : Service() {
|
||||
}
|
||||
|
||||
//获取图片
|
||||
private fun takePhoto(picNum: Long, isInterval: Boolean = false, isCustom: Boolean = false) {
|
||||
private fun takePhoto( isInterval: Boolean = false, isCustom: Boolean = false) {
|
||||
Log.d("MainService", "takePhoto -----1----->")
|
||||
//判断是否授权
|
||||
// if (isAuthorization(BaseApplication.getAppContext())) {
|
||||
|
||||
@@ -18,7 +18,7 @@ import kotlinx.coroutines.runBlocking
|
||||
class MainServiceController {
|
||||
|
||||
companion object {
|
||||
var TAG = this.javaClass.name
|
||||
var TAG = this::class.java.name
|
||||
}
|
||||
|
||||
//逆地理编码是否重试
|
||||
@@ -57,69 +57,69 @@ class MainServiceController {
|
||||
}
|
||||
|
||||
//将数据同步到sharePreference中
|
||||
fun syncStrategiesData(strategy: CityStrategy) {
|
||||
if (strategy?.pic != null && strategy.video!=null) {
|
||||
setStrategyType(AbsMogoApplication.getApp().applicationContext, strategy.pic.strategyType, "pic")
|
||||
setStrategyType(AbsMogoApplication.getApp().applicationContext, strategy.video.strategyType, "video")
|
||||
private fun syncStrategiesData(strategy: CityStrategy) {
|
||||
if (strategy.pic != null && strategy.video!=null) {
|
||||
setStrategyType(AbsMogoApplication.getApp().applicationContext, strategy.pic!!.strategyType, "pic")
|
||||
setStrategyType(AbsMogoApplication.getApp().applicationContext, strategy.video!!.strategyType, "video")
|
||||
setStrategyFrequency(
|
||||
AbsMogoApplication.getApp().applicationContext,
|
||||
strategy.pic.strategyType,
|
||||
strategy.pic!!.strategyType,
|
||||
"pic",
|
||||
strategy.pic.reportType
|
||||
strategy.pic!!.reportType
|
||||
)
|
||||
setStrategyFrequency(
|
||||
AbsMogoApplication.getApp().applicationContext,
|
||||
strategy.video.strategyType,
|
||||
strategy.video!!.strategyType,
|
||||
"video",
|
||||
strategy.video.reportType
|
||||
strategy.video!!.reportType
|
||||
)
|
||||
setStrategyInterval(
|
||||
AbsMogoApplication.getApp().applicationContext,
|
||||
strategy.pic.strategyType,
|
||||
strategy.pic!!.strategyType,
|
||||
"pic",
|
||||
strategy.pic.reportTimeInterval * 60 * 1000L
|
||||
strategy.pic!!.reportTimeInterval * 60 * 1000L
|
||||
)
|
||||
setStrategyInterval(
|
||||
AbsMogoApplication.getApp().applicationContext,
|
||||
strategy.video.strategyType,
|
||||
strategy.video!!.strategyType,
|
||||
"video",
|
||||
strategy.video.reportTimeInterval * 60 * 1000L
|
||||
strategy.video!!.reportTimeInterval * 60 * 1000L
|
||||
)
|
||||
setStrategyValidity(
|
||||
AbsMogoApplication.getApp().applicationContext,
|
||||
strategy.pic.strategyType,
|
||||
strategy.pic!!.strategyType,
|
||||
"pic",
|
||||
strategy.pic.infoTimeout
|
||||
strategy.pic!!.infoTimeout
|
||||
)
|
||||
setStrategyValidity(
|
||||
AbsMogoApplication.getApp().applicationContext,
|
||||
strategy.video.strategyType,
|
||||
strategy.video!!.strategyType,
|
||||
"video",
|
||||
strategy.video.infoTimeout
|
||||
strategy.video!!.infoTimeout
|
||||
)
|
||||
setStrategyMaxSpeed(
|
||||
AbsMogoApplication.getApp().applicationContext,
|
||||
strategy.pic.strategyType,
|
||||
strategy.pic!!.strategyType,
|
||||
"pic",
|
||||
strategy.pic.getMaxSpeed()
|
||||
strategy.pic!!.getMaxSpeed()
|
||||
)
|
||||
setStrategyMaxSpeed(
|
||||
AbsMogoApplication.getApp().applicationContext,
|
||||
strategy.video.strategyType,
|
||||
strategy.video!!.strategyType,
|
||||
"video",
|
||||
strategy.video.getMaxSpeed()
|
||||
strategy.video!!.getMaxSpeed()
|
||||
)
|
||||
setStrategyMinSpeed(
|
||||
AbsMogoApplication.getApp().applicationContext,
|
||||
strategy.pic.strategyType,
|
||||
strategy.pic!!.strategyType,
|
||||
"pic",
|
||||
strategy.pic.minSpeed
|
||||
strategy.pic!!.minSpeed
|
||||
)
|
||||
setStrategyMinSpeed(
|
||||
AbsMogoApplication.getApp().applicationContext,
|
||||
strategy.video.strategyType,
|
||||
strategy.video!!.strategyType,
|
||||
"video",
|
||||
strategy.video.minSpeed
|
||||
strategy.video!!.minSpeed
|
||||
)
|
||||
} else {
|
||||
Log.d(TAG, "strategy Data is null")
|
||||
@@ -145,8 +145,8 @@ class MainServiceController {
|
||||
mFromType = fromType
|
||||
mPoiType = poiType
|
||||
|
||||
var locationInfo = LocationUtil.getInstance().getLocationInfo()
|
||||
if (locationInfo.address.isNullOrEmpty()) {
|
||||
val locationInfo = LocationUtil.getInstance().getLocationInfo()
|
||||
if (locationInfo.address.isEmpty()) {
|
||||
Log.d(TAG, " sendInformationMessage locationInfo.address = $locationInfo.address")
|
||||
trackUploadGeo(1)
|
||||
geoLocation(type, url, locationInfo, isCustom,trafficInfoType, isShare, customSend,poiType,mainInfoId,speed, longitude,latitude)
|
||||
@@ -210,11 +210,9 @@ class MainServiceController {
|
||||
strategyeModel.uploadInformation(informationBody)
|
||||
}
|
||||
onSuccess {
|
||||
if (it.result != null) {
|
||||
Log.i(TAG, "upload success id = " + it.result.id)
|
||||
if (mFromType == "6") {
|
||||
sendUgcStatusReceiver(it.result.id, mPoiType, mFromType)
|
||||
}
|
||||
Log.i(TAG, "upload success id = " + it.result.id)
|
||||
if (mFromType == "6") {
|
||||
sendUgcStatusReceiver(it.result.id, mPoiType, mFromType)
|
||||
}
|
||||
trackUploadServer(1)
|
||||
customSend?.invoke(true)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
@@ -276,11 +276,11 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
|
||||
loadSurroundingDetail(data)
|
||||
}
|
||||
|
||||
private fun loadSurroundingDetail(detailData: SurroundingConstruction) {
|
||||
private fun loadSurroundingDetail(detailData: SurroundingConstruction?) {
|
||||
showBaseUi(false)
|
||||
if (detailData != null) {
|
||||
markerExploreWays.clear()
|
||||
markerExploreWays.addAll(detailData.getConstrutList().toMutableList())
|
||||
markerExploreWays.addAll(detailData.construtList.toMutableList())
|
||||
mSurroundingDetailAdapter.notifyDataSetChanged()
|
||||
|
||||
val originStr = String.format(context!!.resources.getString(R.string.v2x_surrounding_detail_top_brief), markerExploreWays.size)
|
||||
@@ -320,8 +320,7 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
|
||||
}
|
||||
|
||||
private fun getTypeName(type: String): String? {
|
||||
var typeName = ""
|
||||
typeName = when (type) {
|
||||
return when (type) {
|
||||
MarkerPoiTypeEnum.ROAD_CLOSED -> "封路"
|
||||
MarkerPoiTypeEnum.FOURS_ICE -> "道路结冰"
|
||||
MarkerPoiTypeEnum.FOURS_FOG -> "浓雾"
|
||||
@@ -333,7 +332,6 @@ class V2XEventPanelFragment : MvpFragment<V2XEventPanelFragment, EventPanelPrese
|
||||
MarkerPoiTypeEnum.FOURS_LIVING -> "实时路况"
|
||||
else -> "实时路况"
|
||||
}
|
||||
return typeName
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user