code style changed and fix bug of aspectJ
This commit is contained in:
@@ -28,15 +28,15 @@ import kotlin.math.abs
|
||||
* @since 2019-10-30
|
||||
*/
|
||||
object CarCorderController : TakePhotoCallback, TakeVideoCallback {
|
||||
const val TAG: String = "CarCorderController"
|
||||
private lateinit var zdCarCoderController: ZdCarCoderController
|
||||
val TAG: String = this.javaClass.simpleName
|
||||
var outputVideoPath: String = ""
|
||||
var mType: String = "" //1 上报拥堵, 2 封路和查车
|
||||
var mainInfoId: Long = 0
|
||||
var mFromType: String = ""
|
||||
private var outputVideoPath: String = ""
|
||||
private var mType: String = "" //1 上报拥堵, 2 封路和查车
|
||||
private var mainInfoId: Long = 0
|
||||
private var mFromType: String = ""
|
||||
private var mLongitude: Double = 0.0
|
||||
private var mLatitude: Double = 0.0
|
||||
var mSpeed: Float = 0f
|
||||
private var mSpeed: Float = 0f
|
||||
|
||||
private var getVideoFailed: (() -> Unit)? = null
|
||||
private var interceptors: ArrayList<TakePhotoInterceptor> = ArrayList(1)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.zhidao.roadcondition.service
|
||||
|
||||
import android.util.Log
|
||||
import com.zhidao.cosupload.callback.CosStatusCallback
|
||||
import com.zhidao.cosupload.callback.CosStatusCallbackManager
|
||||
|
||||
@@ -11,9 +10,7 @@ import com.zhidao.cosupload.callback.CosStatusCallbackManager
|
||||
*/
|
||||
object CosCallbackMapController : CosStatusCallback {
|
||||
|
||||
val TAG = "CosCallbackMapController"
|
||||
|
||||
val map: MutableMap<String, CosStatusCallback> = mutableMapOf()
|
||||
private val map: MutableMap<String, CosStatusCallback> = mutableMapOf()
|
||||
|
||||
var uploadFailed: (() -> Unit)? = null
|
||||
|
||||
@@ -58,9 +55,7 @@ object CosCallbackMapController : CosStatusCallback {
|
||||
}
|
||||
|
||||
override fun uploadCosFailed(cosPath: String?, eventId: String?, localPath: String?) {
|
||||
map[localPath]?.let {
|
||||
it.uploadCosFailed(cosPath, eventId, localPath)
|
||||
}
|
||||
map[localPath]?.uploadCosFailed(cosPath, eventId, localPath)
|
||||
}
|
||||
|
||||
override fun uploadCosCompleted(
|
||||
@@ -69,15 +64,11 @@ object CosCallbackMapController : CosStatusCallback {
|
||||
downloadUrl: String?,
|
||||
localPath: String?
|
||||
) {
|
||||
map[localPath]?.let {
|
||||
it.uploadCosCompleted(cosPath, eventId, downloadUrl, localPath)
|
||||
}
|
||||
map[localPath]?.uploadCosCompleted(cosPath, eventId, downloadUrl, localPath)
|
||||
}
|
||||
|
||||
override fun onProgress(localPath: String?, progress: Float) {
|
||||
map[localPath]?.let {
|
||||
it.onProgress(localPath, progress)
|
||||
}
|
||||
map[localPath]?.onProgress(localPath, progress)
|
||||
}
|
||||
|
||||
fun release() {
|
||||
|
||||
@@ -4,11 +4,9 @@ import android.content.Intent
|
||||
import android.util.Log
|
||||
import com.google.gson.Gson
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.utils.TipToast
|
||||
import com.zhidao.cosupload.DbPriorityConfig
|
||||
import com.zhidao.cosupload.callback.CosStatusCallback
|
||||
import com.zhidao.cosupload.manager.CosUploadManagerImpl
|
||||
import com.zhidao.roadcondition.constant.*
|
||||
import com.zhidao.roadcondition.event.GetImageSuccessEvent
|
||||
import com.zhidao.roadcondition.event.LatLngStickyEventBus
|
||||
import com.zhidao.roadcondition.model.proxy.INFO_TYPE_IMG
|
||||
@@ -25,11 +23,15 @@ import com.zhidao.roadcondition.util.trackNormalEvent
|
||||
* @since 2019-10-30
|
||||
*/
|
||||
class CosStatusController : CosStatusCallback {
|
||||
val TAG: String = this.javaClass.simpleName
|
||||
|
||||
companion object{
|
||||
const val TAG: String = "CosStatusController"
|
||||
}
|
||||
|
||||
//存储单次请求的视频和缩略图url
|
||||
var videoAndThumbMap: MutableMap<String, String> = mutableMapOf()
|
||||
private var videoAndThumbMap: MutableMap<String, String> = mutableMapOf()
|
||||
//图片上传的eventId
|
||||
lateinit var mPicEventId: String
|
||||
private lateinit var mPicEventId: String
|
||||
private var isRetry = false //是否重试上传过图片
|
||||
|
||||
private var mainServiceHttpModel = MainServiceController()
|
||||
@@ -41,7 +43,7 @@ class CosStatusController : CosStatusCallback {
|
||||
private var mFromType: String = ""
|
||||
private var mLongitude: Double = 0.0
|
||||
private var mLatitude: Double = 0.0
|
||||
var mSpeed: Float = 0f
|
||||
private var mSpeed: Float = 0f
|
||||
|
||||
//上传文件
|
||||
fun uploadFile(picPath: MutableList<String?>?, entity: TakeEntity, type: String, mainInfoId: Long,
|
||||
@@ -123,7 +125,7 @@ class CosStatusController : CosStatusCallback {
|
||||
videoAndThumbMap["thumb"] = downloadUrl!!
|
||||
Log.i(TAG, "videoAndThumbMap add thumb")
|
||||
}
|
||||
Log.d(TAG, "videoAndThumbMap ${videoAndThumbMap}")
|
||||
Log.d(TAG, "videoAndThumbMap $videoAndThumbMap")
|
||||
if (videoAndThumbMap.size == 2) {
|
||||
trackUploadCos(4)
|
||||
Log.d(TAG, "videoAndThumbMap.size == 2 ")
|
||||
|
||||
@@ -10,8 +10,8 @@ import java.util.*
|
||||
*/
|
||||
object CustomStatusHandler {
|
||||
|
||||
val takePhotoStatusQueue: Queue<Boolean> = ArrayDeque(5)
|
||||
val takeVideoStatusQueue: Queue<TakeEntity> = ArrayDeque(5)
|
||||
private val takePhotoStatusQueue: Queue<Boolean> = ArrayDeque(5)
|
||||
private val takeVideoStatusQueue: Queue<TakeEntity> = ArrayDeque(5)
|
||||
|
||||
fun offerPhotoStatus(status: Boolean) {
|
||||
takePhotoStatusQueue.offer(status)
|
||||
|
||||
@@ -6,9 +6,6 @@ import android.content.Intent
|
||||
import android.os.IBinder
|
||||
import android.util.Log
|
||||
import com.zhidao.roadcondition.util.*
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.io.File
|
||||
import java.lang.Exception
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.zhidao.roadcondition.util.*
|
||||
*/
|
||||
object InformationUploadController {
|
||||
|
||||
val TAG : String = this.javaClass.simpleName
|
||||
private val TAG : String = this.javaClass.simpleName
|
||||
|
||||
private var mainServiceHttpModel = MainServiceController()
|
||||
|
||||
@@ -110,9 +110,7 @@ object InformationUploadController {
|
||||
|
||||
fun release(id: Long) {
|
||||
val target = informationCache.remove(id)
|
||||
target?.let {
|
||||
it.release()
|
||||
}
|
||||
target?.release()
|
||||
}
|
||||
|
||||
private fun recordUploadTime() {
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrateg
|
||||
import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.getStrategyType
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.functions.Consumer
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.util.concurrent.TimeUnit
|
||||
@@ -61,22 +60,21 @@ class MainService : Service() {
|
||||
|
||||
//是否已经获取过策略
|
||||
var isGetStrategies: Boolean = false
|
||||
val TAG: String = this.javaClass.simpleName
|
||||
private val TAG: String = this.javaClass.simpleName
|
||||
|
||||
//1是一次性,2是周期性
|
||||
var picType: Int = 0
|
||||
var videoType: Int = 0
|
||||
var shareType: String = "type"
|
||||
var fromType: String = ""
|
||||
var isCustom: Boolean = false
|
||||
var speed: Float = 0f
|
||||
private var picType: Int = 0
|
||||
private var videoType: Int = 0
|
||||
private var shareType: String = "type"
|
||||
private var fromType: String = ""
|
||||
private var isCustom: Boolean = false
|
||||
private var speed: Float = 0f
|
||||
|
||||
var params: UploadParams? = null
|
||||
var mainInfoId: Long = 0
|
||||
private var params: UploadParams? = null
|
||||
private var mainInfoId: Long = 0
|
||||
private var mLongitude: Double = 0.0
|
||||
private var mLatitude: Double = 0.0
|
||||
lateinit var serviceApis: IMogoServiceApis
|
||||
|
||||
private lateinit var serviceApis: IMogoServiceApis
|
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||
//清理多媒体资源和sp策略数据
|
||||
@@ -86,10 +84,8 @@ class MainService : Service() {
|
||||
//参数说明:appKey: app唯一标识(比如:包名)
|
||||
CosUploadManagerImpl.getInstance(AbsMogoApplication.getApp().applicationContext)
|
||||
.init(BuildConfig.APPLICATION_ID, 0)
|
||||
//初始化语音
|
||||
VoiceController.initVoice()
|
||||
serviceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(this) as IMogoServiceApis
|
||||
speed = serviceApis.getMapServiceApi().getSingletonLocationClient(this).getLastKnowLocation().getSpeed()
|
||||
speed = serviceApis.mapServiceApi.getSingletonLocationClient(this).lastKnowLocation.speed
|
||||
Log.d(TAG, "onStartCommand speed = $speed")
|
||||
if (intent != null) {
|
||||
params = intent.getParcelableExtra("params")
|
||||
@@ -115,7 +111,7 @@ class MainService : Service() {
|
||||
}
|
||||
|
||||
//定时任务回调广播
|
||||
var mAlarmBroadCast: BroadcastReceiver = object : BroadcastReceiver() {
|
||||
private var mAlarmBroadCast: BroadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(p0: Context?, p1: Intent) {
|
||||
Log.d(TAG, "receive alarm!!!!!!!!!!AlarmType===${p1.getIntExtra("AlarmType", 1)}")
|
||||
if (p1.action == alarmBroadAction) {
|
||||
@@ -178,14 +174,14 @@ class MainService : Service() {
|
||||
// mainServiceHttpModel.getSplashConfig()
|
||||
}
|
||||
|
||||
var id: Long = System.currentTimeMillis()
|
||||
private var id: Long = System.currentTimeMillis()
|
||||
|
||||
/**
|
||||
* 获取图片成功
|
||||
*/
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true, priority = 98)
|
||||
fun getImageEvent(getImageSuccessEvent: GetImageSuccessEvent) {
|
||||
var info = LocationUtil.getInstance().getLocationInfo()
|
||||
val info = LocationUtil.getInstance().getLocationInfo()
|
||||
Log.d("MainService", "getImageEvent long = ${info.longitude} ----> lat= ${info.latitude}")
|
||||
Log.d(
|
||||
"MainService",
|
||||
@@ -209,7 +205,7 @@ class MainService : Service() {
|
||||
* 初始化定位监听
|
||||
*/
|
||||
private fun initLocationListener() {
|
||||
var isOpen = SharedPrefsMgr.getInstance(AbsMogoApplication.getApp().applicationContext).getBoolean("KEY_SERVER_REPORTSTRATEGY_SWITCH", false)
|
||||
val isOpen = SharedPrefsMgr.getInstance(AbsMogoApplication.getApp().applicationContext).getBoolean("KEY_SERVER_REPORTSTRATEGY_SWITCH", false)
|
||||
Logger.d("EntrancePresenter", " initLocationListener ---- isOpen = $isOpen")
|
||||
//开始开始监听速度,只要超过一次5公里每小时则即开始获取策略进行本地上报 只有release才加此判断,qa环境方便测试
|
||||
LocationUtil.getInstance().setonSpeedlistenner(object : LocationUtil.SpeedListener {
|
||||
@@ -277,9 +273,9 @@ class MainService : Service() {
|
||||
//目前不支持连拍,只能定时2秒拍一张 第一期每次只拍一张
|
||||
Observable.intervalRange(0, 1, 0, 2_000, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(Consumer {
|
||||
.subscribe {
|
||||
CarCorderController.takePhoto(1, 1, false, isCustom, TANLU_ROAD_CURRENT, mainInfoId, fromType, mLongitude, mLatitude, speed)
|
||||
})
|
||||
}
|
||||
// }
|
||||
|
||||
postPhotoAlarmTask(isInterval)
|
||||
@@ -310,7 +306,7 @@ class MainService : Service() {
|
||||
intent.action = alarmBroadAction
|
||||
intent.putExtra("number", getLong(PIC_NUMBER, PIC_NUMBER_DEFAULT))
|
||||
intent.putExtra("AlarmType", AlarmTypePic)
|
||||
var pendingIntent = PendingIntent.getBroadcast(this, AlarmTypePic, intent, 0)
|
||||
val pendingIntent = PendingIntent.getBroadcast(this, AlarmTypePic, intent, 0)
|
||||
Log.d(
|
||||
"MainService",
|
||||
"postPhotoAlarmTask time =" + getStrategyInterval(
|
||||
@@ -342,7 +338,7 @@ class MainService : Service() {
|
||||
"duration", (VIDEO_DURATION_DEFAULT / 1000).toInt()
|
||||
)
|
||||
videoIntent.putExtra("AlarmType", AlarmTypeVideo)
|
||||
var videoPendingIntent =
|
||||
val videoPendingIntent =
|
||||
PendingIntent.getBroadcast(this, AlarmTypeVideo, videoIntent, 0)
|
||||
Log.d(
|
||||
"MainService",
|
||||
|
||||
@@ -18,20 +18,20 @@ import kotlinx.coroutines.runBlocking
|
||||
class MainServiceController {
|
||||
|
||||
companion object {
|
||||
var TAG = this::class.java.name
|
||||
const val TAG = "MainServiceController"
|
||||
}
|
||||
|
||||
//逆地理编码是否重试
|
||||
private var geoRetryed = false
|
||||
private var geoRetry = false
|
||||
private var mFromType: String = ""
|
||||
private var mPoiType: String = ""
|
||||
|
||||
private val strategyeModel by lazy { StrategyServiceModel() }
|
||||
private val strategyModel by lazy { StrategyServiceModel() }
|
||||
|
||||
fun initStrategies(initFinish: (() -> Unit)? = null) {
|
||||
request<BaseResponse<Results>> {
|
||||
loader {
|
||||
strategyeModel.getCityStrategy()
|
||||
strategyModel.getCityStrategy()
|
||||
}
|
||||
onSuccess {
|
||||
it.result.let { strategy ->
|
||||
@@ -184,7 +184,7 @@ class MainServiceController {
|
||||
}, {
|
||||
//转换失败的情况下再重试一次
|
||||
Log.d(TAG, "geoLocation -------true-->")
|
||||
geoRetryed = if (!geoRetryed) {
|
||||
geoRetry = if (!geoRetry) {
|
||||
geoLocation(type, url, locationInfo, isCustom, trafficInfoType, isShare, customSend, poiType,mainInfoId,speed, longitude,latitude)
|
||||
true
|
||||
} else {
|
||||
@@ -207,7 +207,7 @@ class MainServiceController {
|
||||
trackUploadServer(3)
|
||||
request<BaseResponse<UploadResult>> {
|
||||
loader {
|
||||
strategyeModel.uploadInformation(informationBody)
|
||||
strategyModel.uploadInformation(informationBody)
|
||||
}
|
||||
onSuccess {
|
||||
Log.i(TAG, "upload success id = " + it.result.id)
|
||||
@@ -230,7 +230,7 @@ class MainServiceController {
|
||||
|
||||
private fun sendUgcStatusReceiver(id: Long, type: String?, fromType: String?) {
|
||||
Log.d(TAG, "sendUgcStatusReceiver id = $id ---type = $type --fromType = $fromType ")
|
||||
var intent = Intent()
|
||||
val intent = Intent()
|
||||
intent.action = "com.v2x.ugc.upload.status"
|
||||
intent.putExtra("id", id)
|
||||
intent.putExtra("type", type)
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.zhidao.roadcondition.service
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.mogo.map.MogoLatLng
|
||||
|
||||
class UploadParams(val eventType: String, val fromType: String, val duration: Int, val parentId: Long, val lat: Double, val lon: Double) : Parcelable {
|
||||
constructor(parcel: Parcel) : this(
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.zhidao.roadcondition.service
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.zhidao.auto.platform.voice.VoiceClient
|
||||
import java.lang.Exception
|
||||
|
||||
/**
|
||||
* @description 声音控制类
|
||||
*
|
||||
* @author lixiaopeng
|
||||
* @since 2019-11-01
|
||||
*/
|
||||
object VoiceController {
|
||||
private lateinit var voiceClient: VoiceClient
|
||||
|
||||
fun initVoice() {
|
||||
voiceClient = VoiceClient(AbsMogoApplication.getApp().applicationContext)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置语音命令回调接口
|
||||
* @param callBack
|
||||
*/
|
||||
fun setCallBack(callBack: VoiceClient.VoiceCmdCallBack) {
|
||||
voiceClient.setCallBack(callBack)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param speakText 语音播报内容
|
||||
*/
|
||||
fun speakVoice(speakText: String) {
|
||||
voiceClient.speakDefault(speakText)
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册免唤醒命令
|
||||
* @param customType 命令
|
||||
* @param customWakeupCmd 命令对应的唤醒词集合
|
||||
*/
|
||||
fun registerCustomWakeupCmd(customType: String, customWakeupCmd: Array<String>) {
|
||||
voiceClient.registerCustomWakeupCmd(customType, customWakeupCmd)
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消免唤醒命令
|
||||
* @param customType 命令
|
||||
*/
|
||||
fun unRegisterCustomWakeupCmd(customType: String) {
|
||||
try {
|
||||
voiceClient.unRegisterCustomWakeupCmd(customType)
|
||||
} catch (e:Exception){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放资源(界面销毁的时候调用)
|
||||
*/
|
||||
fun release() {
|
||||
voiceClient.release()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user