区分分享优化需求范围,launcher不加此需求,独立app加此需求

This commit is contained in:
tongchenfei
2020-09-09 17:30:04 +08:00
parent 77b37219e0
commit 8600e2c3ac
4 changed files with 49 additions and 36 deletions

View File

@@ -19,32 +19,45 @@ import com.mogo.utils.logger.Logger
* 上报工具类
*/
object UploadHelper {
fun upload(context:Context, type: TanluUploadParams,forcePlayVoice:Boolean = false) {
if(ServiceApisManager.serviceApis.statusManagerApi.isUploading){
// 上报即成功,当前还有正在上报的事件,仅做界面展示,不做具体操作
ServiceApisManager.serviceApis.tanluUiApi.shareSuccess(type.eventType, type.location)
// Logger.d("UploadHelper", "正在上报===")
// TipToast.tip("正在上报,请稍后重试")
}else {
// 判断当前网络状态
if(NetworkUtils.isConnected(context)) {
// 有网就正常上报
fun upload(context: Context, type: TanluUploadParams, forcePlayVoice: Boolean = false) {
if (DebugConfig.isLauncher()) {
if (ServiceApisManager.serviceApis.statusManagerApi.isUploading) {
// 上报即成功,当前还有正在上报的事件,仅做界面展示,不做具体操作
Logger.d("UploadHelper", "正在上报===")
TipToast.tip("正在上报,请稍后重试")
} else {
ServiceApisManager.serviceApis.statusManagerApi.setUploadingStatus("CARD_TYPE_ROAD_CONDITION", true)
// if (DebugConfig.getAIType() == DebugConfig.AI_TYPE_TXZ || forcePlayVoice) {
// 因为思必驰语音分享时,语音助手会自己播报一段文字
// AIAssist.getInstance(context).speakTTSVoice("感谢分享,正在上传")
// }
// 上报即成功
ServiceApisManager.serviceApis.tanluUiApi.shareSuccess(type.eventType, type.location)
if (DebugConfig.getAIType() == DebugConfig.AI_TYPE_TXZ || forcePlayVoice) {
// 因为思必驰语音分享时,语音助手会自己播报一段文字
AIAssist.getInstance(context).speakTTSVoice("感谢分享,正在上传")
}
val location = ServiceApisManager.serviceApis.mapServiceApi.getSingletonLocationClient(context).lastKnowLocation
val latLon = MogoLatLng(location.latitude, location.longitude)
type.location = latLon
Logger.d("UploadHelper", "upload ----> $type")
ServiceApisManager.serviceApis.tanluApi.uploadRoadCondition(type)
}else{
// 没网就直接提示失败
AIAssist.getInstance(context).speakTTSVoice("分享失败,请检查网络")
TipToast.tip("分享失败,请检查网络", TipDrawable(context.resources.getDrawable(R.drawable.module_share_upload_fail)))
}
} else {
if (ServiceApisManager.serviceApis.statusManagerApi.isUploading) {
// 上报即成功,当前还有正在上报的事件,仅做界面展示,不做具体操作
ServiceApisManager.serviceApis.tanluUiApi.shareSuccess(type.eventType, type.location)
} else {
// 判断当前网络状态
if (NetworkUtils.isConnected(context)) {
// 有网就正常上报
ServiceApisManager.serviceApis.statusManagerApi.setUploadingStatus("CARD_TYPE_ROAD_CONDITION", true)
// 上报即成功
ServiceApisManager.serviceApis.tanluUiApi.shareSuccess(type.eventType, type.location)
val location = ServiceApisManager.serviceApis.mapServiceApi.getSingletonLocationClient(context).lastKnowLocation
val latLon = MogoLatLng(location.latitude, location.longitude)
type.location = latLon
Logger.d("UploadHelper", "upload ----> $type")
ServiceApisManager.serviceApis.tanluApi.uploadRoadCondition(type)
} else {
// 没网就直接提示失败
AIAssist.getInstance(context).speakTTSVoice("分享失败,请检查网络")
TipToast.tip("分享失败,请检查网络", TipDrawable(context.resources.getDrawable(R.drawable.module_share_upload_fail)))
}
}
}
}