From c84fc33bf01cfa90f9c003a54aaf32fb5afa6590 Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Mon, 2 Nov 2020 19:41:24 +0800 Subject: [PATCH] opt --- .../module/share/StrategyShareProvider.kt | 37 ++----------------- .../com/mogo/module/share/TanluManager.java | 30 +++++++++++++++ .../share/manager/ServiceApisManager.kt | 2 + .../mogo/module/share/manager/UploadHelper.kt | 6 ++- .../tanlu/fragment/TanluCardViewProvider.java | 30 +++++++-------- 5 files changed, 54 insertions(+), 51 deletions(-) diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt index 6f8a8c123e..69324701cc 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt @@ -1,27 +1,18 @@ package com.mogo.module.share import android.content.Context -import android.content.Intent import com.alibaba.android.arouter.facade.annotation.Route +import com.alibaba.android.arouter.facade.template.IProvider import com.alibaba.android.arouter.launcher.ARouter -import com.mogo.map.MogoLatLng import com.mogo.module.share.adas.AdasFrontCarDistanceY -import com.mogo.module.share.bean.event.MarkerInfo import com.mogo.module.share.constant.ACCIDENT_STRATEGY_SHARE_PUSH_TYPE import com.mogo.module.share.constant.S_TAG import com.mogo.module.share.strategyreceiver.AccidentStrategyReceiver import com.mogo.module.share.strategyreceiver.BlockStrategy import com.mogo.service.IMogoServiceApis import com.mogo.service.MogoServicePaths -import com.mogo.service.share.IMogoTanluUiProvider import com.mogo.utils.logger.Logger import com.mogo.utils.network.utils.GsonUtil -import io.reactivex.Single -import io.reactivex.SingleEmitter -import io.reactivex.SingleOnSubscribe -import io.reactivex.android.schedulers.AndroidSchedulers -import io.reactivex.schedulers.Schedulers -import org.greenrobot.eventbus.EventBus import org.json.JSONObject /** @@ -30,14 +21,13 @@ import org.json.JSONObject * @author tongchenfei */ @Route(path = MogoServicePaths.PATH_STRATEGY_SHARE) -class StrategyShareProvider : IMogoTanluUiProvider { +class StrategyShareProvider : IProvider { private lateinit var blockStrategy: BlockStrategy - private lateinit var mContext: Context; override fun init(context: Context) { TanluServiceManager.init(context) TanluManager.getInstance(context).init() - mContext = context + Logger.d(S_TAG, "策略上报Provider初始化====") val apis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context) as IMogoServiceApis blockStrategy = BlockStrategy(context, apis) @@ -71,25 +61,4 @@ class StrategyShareProvider : IMogoTanluUiProvider { } - override fun searchRoadCondition(intentStr: String, data: String, city: String, keywords: String) { - val disposable = Single.create(SingleOnSubscribe { emitter: SingleEmitter -> - Logger.d(S_TAG, "searchRoadCondition---> intentStr: " + intentStr + " data: " + data + " " + - "city: " + city + " keywords: " + keywords) - val intent = Intent(intentStr) - intent.putExtra("data", data) - intent.putExtra("city", city) - intent.putExtra("keywords", keywords) - Thread.sleep(3000) - emitter.onSuccess(intent) - }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe { intent: Intent? -> - Logger.d(S_TAG, "searchRoadCondition---go real share") - TanluManager.getInstance(mContext).realShare(intentStr, intent) - } - } - - override fun shareSuccess(poiType: String?, location: MogoLatLng) { - val markerInfo = MarkerInfo(poiType, "", location.lon, location.lat, true, "1") - EventBus.getDefault().post(markerInfo) - } - } \ No newline at end of file diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/TanluManager.java b/modules/mogo-module-share/src/main/java/com/mogo/module/share/TanluManager.java index 4dcaa17c9b..7ac8253c63 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/TanluManager.java +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/TanluManager.java @@ -61,6 +61,12 @@ import java.util.List; import java.util.Map; import java.util.Random; +import io.reactivex.Single; +import io.reactivex.SingleOnSubscribe; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.schedulers.Schedulers; + import static com.mogo.module.share.constant.ShareConstants.SPECIFIEDROAD_SEARCH; import static com.mogo.module.share.constant.ShareConstants.TXZ_SPECIFIEDROAD_SEARCH; import static com.mogo.module.share.constant.ShareConstants.TYPE_NAME_BLOCK; @@ -132,6 +138,30 @@ public class TanluManager implements IMogoMarkerClickListener, initListener(); } + + public void searchRoadCondition(String intentStr, String data, String city, String keywords) { + Disposable disposable = Single.create((SingleOnSubscribe) emitter -> { + Logger.d(TAG, "searchRoadCondition---> intentStr: " + intentStr + " data: " + data + " " + + "city: " + city + " keywords: " + keywords); + Intent intent = new Intent(intentStr); + intent.putExtra("data", data); + intent.putExtra("city", city); + intent.putExtra("keywords", keywords); + Thread.sleep(3000); + emitter.onSuccess(intent); + }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(intent -> { + Logger.d(TAG, "searchRoadCondition---go real share"); + realShare(intentStr, intent); + }); + } + + + public void shareSuccess(String poiType, MogoLatLng location) { + MarkerInfo markerInfo = new MarkerInfo(poiType, "", location.lon, location.lat, true, "1"); + EventBus.getDefault().post(markerInfo); + } + + /** * 构造经纬度列表 * diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/ServiceApisManager.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/ServiceApisManager.kt index 74c0ab300d..1ebbeeea93 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/ServiceApisManager.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/ServiceApisManager.kt @@ -1,6 +1,7 @@ package com.mogo.module.share.manager import android.content.Context +import android.util.Log import com.alibaba.android.arouter.launcher.ARouter import com.mogo.service.IMogoServiceApis import com.mogo.service.MogoServicePaths @@ -12,6 +13,7 @@ object ServiceApisManager { lateinit var serviceApis: IMogoServiceApis fun init(context: Context) { + Log.d("liyz", "ServiceApisManager --- init ") serviceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context) as IMogoServiceApis } } \ No newline at end of file diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/UploadHelper.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/UploadHelper.kt index a4b734bd8b..f76986a2d7 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/UploadHelper.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/manager/UploadHelper.kt @@ -6,6 +6,7 @@ import com.mogo.commons.voice.AIAssist import com.mogo.map.MogoLatLng import com.mogo.module.common.entity.MarkerPoiTypeEnum import com.mogo.module.share.R +import com.mogo.module.share.TanluManager import com.mogo.module.share.constant.ShareConstants.* import com.mogo.service.share.TanluUploadParams import com.mogo.utils.NetworkUtils @@ -46,12 +47,13 @@ object UploadHelper { // 有网就正常上报 ServiceApisManager.serviceApis.statusManagerApi.setUploadingStatus("CARD_TYPE_ROAD_CONDITION", true) // 上报即成功 - ServiceApisManager.serviceApis.tanluUiApi.shareSuccess(type.eventType, type.location) + Log.d("liyz", "upload --- init------2---- ") + TanluManager.getInstance(context).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) + TanluManager.getInstance(context).uploadRoadCondition(type) //语音播报 showVoiceTip(context, type.eventType) diff --git a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java index 8ef4b677ed..74ed7bc9e3 100644 --- a/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java +++ b/modules/mogo-module-tanlu/src/main/java/com/mogo/module/tanlu/fragment/TanluCardViewProvider.java @@ -43,25 +43,25 @@ public class TanluCardViewProvider implements IMogoTanluUiProvider { @Override public void searchRoadCondition(String intentStr, String data, String city, String keywords) { -// Disposable disposable = Single.create((SingleOnSubscribe) emitter -> { -// Logger.d(TAG, "searchRoadCondition---> intentStr: " + intentStr + " data: " + data + " " + -// "city: " + city + " keywords: " + keywords); -// Intent intent = new Intent(intentStr); -// intent.putExtra("data", data); -// intent.putExtra("city", city); -// intent.putExtra("keywords", keywords); -// Thread.sleep(3000); -// emitter.onSuccess(intent); -// }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(intent -> { -// Logger.d(TAG, "searchRoadCondition---go real share"); -// tanluListWindow.realShare(intentStr, intent); -// }); + Disposable disposable = Single.create((SingleOnSubscribe) emitter -> { + Logger.d(TAG, "searchRoadCondition---> intentStr: " + intentStr + " data: " + data + " " + + "city: " + city + " keywords: " + keywords); + Intent intent = new Intent(intentStr); + intent.putExtra("data", data); + intent.putExtra("city", city); + intent.putExtra("keywords", keywords); + Thread.sleep(3000); + emitter.onSuccess(intent); + }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(intent -> { + Logger.d(TAG, "searchRoadCondition---go real share"); + tanluListWindow.realShare(intentStr, intent); + }); } @Override public void shareSuccess(String poiType, MogoLatLng location) { -// MarkerInfo markerInfo = new MarkerInfo(poiType, "", location.lon, location.lat, true, "1"); -// EventBus.getDefault().post(markerInfo); + MarkerInfo markerInfo = new MarkerInfo(poiType, "", location.lon, location.lat, true, "1"); + EventBus.getDefault().post(markerInfo); }