This commit is contained in:
lixiaopeng
2020-09-11 11:07:43 +08:00
parent a5a111dd73
commit 29b9a10f32
302 changed files with 13890 additions and 29 deletions

View File

@@ -4,6 +4,7 @@ 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
@@ -91,7 +92,8 @@ class CosStatusController : CosStatusCallback {
if (!isRetry) {
isRetry = true
taskAsync(5_000) { //去掉重试
taskAsync(5_000) {
//去掉重试
try {
uploadFile(mutableListOf(localPath as String), entity, mType, mainInfoId, mFromType, mLongitude, mLatitude)
} catch (e: Exception) {
@@ -142,20 +144,18 @@ class CosStatusController : CosStatusCallback {
val locationStr: String = Gson().toJson(locationInfo)
Log.d(TAG, "locationStr = " + locationStr)
//如果失败,需要提示失败弹框
if (locationInfo.address.isNullOrEmpty() || locationInfo.cityName.isNullOrEmpty() || locationInfo.cityCode.isNullOrEmpty()
|| locationInfo.latitude == 0.0 || locationInfo.areaName.isNullOrEmpty() || locationInfo.street.isNullOrEmpty()
|| locationInfo.areaCode.isNullOrEmpty() || locationInfo.provinceName.isNullOrEmpty()
) {
if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) {
sendGetInfoFailedReceiver("100")
}
} else {
//分享成功并打点如果是上报拥堵需要takeVideo
LatLngStickyEventBus.getInstance()
.postSticky(GetImageSuccessEvent(downloadUrl, mType))
//上传录像以及缩略图成功
sendInformation(INFO_TYPE_VIDEO, videoAndThumbMap)
}
// if (locationInfo.address.isNullOrEmpty() || locationInfo.cityName.isNullOrEmpty() || locationInfo.cityCode.isNullOrEmpty()
// || locationInfo.latitude == 0.0 || locationInfo.areaName.isNullOrEmpty() || locationInfo.street.isNullOrEmpty()
// || locationInfo.areaCode.isNullOrEmpty() || locationInfo.provinceName.isNullOrEmpty()
// ) {
// if (entity?.isCustom && mFromType != UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO) {
// sendGetInfoFailedReceiver("100")
// }
// } else {
//上传录像以及缩略图成功
sendInformation(INFO_TYPE_VIDEO, videoAndThumbMap)
// }
} else {
trackUploadCos(5)
}
@@ -204,20 +204,35 @@ class CosStatusController : CosStatusCallback {
//开始上传
entity?.isCustom?.let {
mainServiceHttpModel.sendInformationMessage(
type = type,
url = map,
isCustom = it,
poiType = poiType,
mainInfoId = mainInfoId,
longitude = longitude,
latitude = latitude
) { success ->
CosCallbackMapController.unregisterCallbacks(map)
CosCallbackMapController.mainService?.let {
CosCallbackMapController.mainService?.sendCustomResult(success)
type = type,
url = map,
isCustom = it,
poiType = poiType,
mainInfoId = mainInfoId,
longitude = longitude,
latitude = latitude
) { success ->
CosCallbackMapController.unregisterCallbacks(map)
CosCallbackMapController.mainService?.let {
CosCallbackMapController.mainService?.sendCustomResult(success)
}
Log.d(TAG, "type = $type ----success = $success")
if (success) {
//分享成功并打点如果是上报拥堵需要takeVideo
if (type == INFO_TYPE_VIDEO) {
try {
LatLngStickyEventBus.getInstance()
.postSticky(GetImageSuccessEvent("", poiType))
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
}
} else {
if (type == INFO_TYPE_VIDEO) {
TipToast.shortTip("分享失败,请检查网络")
}
}
}
}
}
}

View File

@@ -2,7 +2,10 @@ package com.zhidao.roadcondition.service
import android.util.Log
import com.mogo.commons.AbsMogoApplication
import com.zhidao.roadcondition.event.GetImageSuccessEvent
import com.zhidao.roadcondition.event.LatLngStickyEventBus
import com.zhidao.roadcondition.model.*
import com.zhidao.roadcondition.model.proxy.INFO_TYPE_VIDEO
import com.zhidao.roadcondition.net.request
import com.zhidao.roadcondition.util.*
import com.zhidao.roadcondition.util.StrategyPreferenceUtil.Companion.setStrategyFrequency
@@ -272,6 +275,12 @@ class MainServiceController {
geoLocation(type, url, locationInfo, isCustom, trafficInfoType, isShare, customSend, poiType,mainInfoId,longitude,latitude)
true
} else {
//如果两次都失败,直接上报服务端
postInformationMessage(
getInformationBody(type, url, locationInfo, isCustom, trafficInfoType, isShare, poiType,mainInfoId,longitude,latitude),
customSend
)
false
}
})
@@ -292,7 +301,6 @@ class MainServiceController {
trackUploadServer(1)
// CosStatusController().videoAndThumbMap.clear()
customSend?.invoke(true)
}
onError {
Log.i(TAG, "$it upload message ${it.message}")