diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt index 228463e426..d2f79b5837 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt @@ -164,10 +164,10 @@ import java.util.* } } - /*ivCameraIcon?.setOnLongClickListener { - activity?.let { it1 -> CarcorderPreviewView.show(it1) } + ivCameraIcon?.setOnLongClickListener { + showSmallFragment() true - }*/ + } ivToolsIcon?.setOnClickListener { if (toolsViewFloat == null) { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/camera/RoadVideoDialog.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/camera/RoadVideoDialog.kt index fc8c71d8a7..1a5a426d86 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/camera/RoadVideoDialog.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/camera/RoadVideoDialog.kt @@ -40,10 +40,13 @@ class RoadVideoDialog(context: Context) : BaseFloatDialog(context), LifecycleObs init { setContentView(R.layout.road_video_dialog) + roadVideoPB.indeterminateDrawable.colorFilter = PorterDuffColorFilter( + ContextCompat.getColor(context, R.color.notice_blue), + PorterDuff.Mode.MULTIPLY + ) setCanceledOnTouchOutside(true) roadVideoClose.setOnClickListener { - stopLive() dismiss() } @@ -52,12 +55,14 @@ class RoadVideoDialog(context: Context) : BaseFloatDialog(context), LifecycleObs fun show(url: String, isFlvUrl: Boolean) { show() + roadVideoPB.visibility = View.VISIBLE if (!isFlvUrl) { // 打开指定ip的摄像头直播流 CallerMonitorManager.openCameraStream(url, { flvUrl -> gsyVideoPlay(flvUrl) }) { ToastUtils.showShort(it.message) + dismiss() } } else { gsyVideoPlay(url) @@ -93,10 +98,6 @@ class RoadVideoDialog(context: Context) : BaseFloatDialog(context), LifecycleObs } } }) - roadVideoPB.indeterminateDrawable.colorFilter = PorterDuffColorFilter( - ContextCompat.getColor(context, R.color.notice_blue), - PorterDuff.Mode.MULTIPLY - ) } private fun gsyVideoPlay(flvUrl: String) { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/stagetwo/APMStartup.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/stagetwo/APMStartup.java deleted file mode 100644 index 0a90bd5125..0000000000 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/stagetwo/APMStartup.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.mogo.eagle.core.function.main.stagetwo; - -import android.content.Context; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import com.alibaba.android.arouter.launcher.ARouter; -import com.mogo.test.crashreport.CrashReportConstants; -import com.mogo.test.crashreport.upgrade.UpgradeReportConstants; -import com.rousetime.android_startup.AndroidStartup; - -public class APMStartup extends AndroidStartup { - @Nullable - @Override - public Boolean create(@NonNull Context context) { - // bugly - ARouter.getInstance().build(UpgradeReportConstants.PATH).navigation(); - // apm - ARouter.getInstance().build(CrashReportConstants.PATH).navigation(); - return true; - } - - @Override - public boolean callCreateOnMainThread() { - return true; - } - - @Override - public boolean waitOnMainThread() { - return false; - } -} diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/road_video_bg.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/road_video_bg.png new file mode 100644 index 0000000000..99bfcefc6f Binary files /dev/null and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xxhdpi/road_video_bg.png differ diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/road_video_dialog.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/road_video_dialog.xml index 937c3505fe..f421903ffc 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/road_video_dialog.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/road_video_dialog.xml @@ -7,6 +7,7 @@ android:minWidth="1736px" android:minHeight="974px" app:roundLayoutRadius="30px" + android:background="@drawable/road_video_bg" tools:ignore="MissingDefaultResource"> { - mAMapNaviView.displayOverview(); + CallerHmiManager.INSTANCE.hideSmallFragment(); +// mAMapNaviView.displayOverview(); }); // 注册定位监听 CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this); @@ -738,14 +738,38 @@ public class AMapCustomView } ArrayList markerOptionsList = new ArrayList(); for (ArrayList structureList : pathMap.values()) { + int firstQuadrantCt = 0, secondQuadrantCt = 0, thirdQuadrantCt = 0, forthQuadrantCt = 0; + // 每个GeoHash内根据坐标系象限分散开摄像头icon显示 for (Infrastructure structure : structureList) { MarkerOptions markerOption = new MarkerOptions(); LatLng latLng = new LatLng(Double.valueOf(structure.getLat()), Double.valueOf(structure.getLon())); markerOption.position(latLng); - markerOption.icon(BitmapDescriptorFactory.fromBitmap( - BitmapFactory.decodeResource(getResources(), R.drawable.video_nor) - )); + if (structure.getHeading() >= 0 && structure.getHeading() <= 90) { + markerOption.anchor(0.5f * firstQuadrantCt, 0.5f + 0.5f * firstQuadrantCt); + markerOption.icon(BitmapDescriptorFactory.fromBitmap( + BitmapFactory.decodeResource(getResources(),R.drawable.video_icon_right) + )); + firstQuadrantCt++; + } else if (structure.getHeading() >= 90 && structure.getHeading() <= 180) { + markerOption.anchor(0.5f * secondQuadrantCt, 0.5f * secondQuadrantCt); + markerOption.icon(BitmapDescriptorFactory.fromBitmap( + BitmapFactory.decodeResource(getResources(),R.drawable.video_icon_right) + )); + secondQuadrantCt++; + } else if (structure.getHeading() >= 180 && structure.getHeading() <= 270) { + markerOption.anchor(0.5f + 0.5f * thirdQuadrantCt, 0.5f * thirdQuadrantCt); + markerOption.icon(BitmapDescriptorFactory.fromBitmap( + BitmapFactory.decodeResource(getResources(),R.drawable.video_icon_left) + )); + thirdQuadrantCt++; + } else { + markerOption.anchor(0.75f + 0.25f * forthQuadrantCt, 0.75f + 0.25f * forthQuadrantCt); + markerOption.icon(BitmapDescriptorFactory.fromBitmap( + BitmapFactory.decodeResource(getResources(),R.drawable.video_icon_left) + )); + forthQuadrantCt++; + } posInfMap.put(latLng, structure); markerOptionsList.add(markerOption); } diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/video_nor.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/video_icon_left.png similarity index 100% rename from core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/video_nor.png rename to core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/video_icon_left.png diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/video_icon_right.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/video_icon_right.png new file mode 100644 index 0000000000..b395889f64 Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi-2560x1440/video_icon_right.png differ diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/video_nor.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/video_icon_left.png similarity index 100% rename from core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/video_nor.png rename to core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/video_icon_left.png diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/video_icon_right.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/video_icon_right.png new file mode 100644 index 0000000000..b395889f64 Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/video_icon_right.png differ diff --git a/core/function-impl/mogo-core-function-monitoring/src/main/java/com/mogo/eagle/core/function/monitoring/CronTaskManager.kt b/core/function-impl/mogo-core-function-monitoring/src/main/java/com/mogo/eagle/core/function/monitoring/CronTaskManager.kt index 2a1fcf754b..a250a266c1 100644 --- a/core/function-impl/mogo-core-function-monitoring/src/main/java/com/mogo/eagle/core/function/monitoring/CronTaskManager.kt +++ b/core/function-impl/mogo-core-function-monitoring/src/main/java/com/mogo/eagle/core/function/monitoring/CronTaskManager.kt @@ -13,6 +13,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MONITOR import com.mogo.map.MogoLocationClient import com.mogo.module.common.constants.HostConst +import io.reactivex.Observable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable import io.reactivex.schedulers.Schedulers @@ -219,16 +220,28 @@ class CronTaskManager(private var context: Context?) { } streamDisposable2 = MoGoRetrofitFactory.getInstance(HostConst.CITY_HOST) .create(CameraListServices::class.java) - .reqOpenCameraStream(cameraIp) + .reqOpenCameraStreamWithRetry(cameraIp) + .flatMap { + if (it.code != 200 && it.code != 0) { + Observable.error(Throwable(it.msg)) + } else { + Observable.just(it) + } + } .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) + .retryWhen(RetryWithDelay()) .subscribe({ CallerLogger.d("$M_MONITOR$TAG", "reqOpenCameraStream返回结果为:$it") - val flvString = it.flvUrl - if (!flvString.isNullOrEmpty()) { - success(flvString) + if (it.code == 200 || it.code == 0) { + val flvString = it.flvUrl + if (!flvString.isNullOrEmpty()) { + success(flvString) + } else { + error(Throwable("flvUrl为空")) + } } else { - error(Throwable("flvUrl为空")) + error(Throwable(it.msg)) } }, { CallerLogger.e( diff --git a/core/function-impl/mogo-core-function-monitoring/src/main/java/com/mogo/eagle/core/function/monitoring/RetryWithDelay.java b/core/function-impl/mogo-core-function-monitoring/src/main/java/com/mogo/eagle/core/function/monitoring/RetryWithDelay.java new file mode 100644 index 0000000000..1819095745 --- /dev/null +++ b/core/function-impl/mogo-core-function-monitoring/src/main/java/com/mogo/eagle/core/function/monitoring/RetryWithDelay.java @@ -0,0 +1,25 @@ +package com.mogo.eagle.core.function.monitoring; + +import java.util.concurrent.TimeUnit; + +import io.reactivex.Observable; +import io.reactivex.ObservableSource; +import io.reactivex.functions.Function; + +public class RetryWithDelay implements Function, Observable> { + + private final int maxRetries = 3; + private final int retryDelayMillis = 5000; + // 计数器 + private int retryCount = 0; + + @Override + public Observable apply(Observable observable) throws Exception { + return observable.flatMap((Function>) throwable -> { + if (++retryCount <= maxRetries) { + return Observable.timer(retryDelayMillis, TimeUnit.MILLISECONDS); + } + return Observable.error(throwable); + }); + } +} diff --git a/core/function-impl/mogo-core-function-monitoring/src/main/java/com/mogo/eagle/core/function/monitoring/net/CameraListServices.kt b/core/function-impl/mogo-core-function-monitoring/src/main/java/com/mogo/eagle/core/function/monitoring/net/CameraListServices.kt index bfd67c564d..cba6c1a43a 100644 --- a/core/function-impl/mogo-core-function-monitoring/src/main/java/com/mogo/eagle/core/function/monitoring/net/CameraListServices.kt +++ b/core/function-impl/mogo-core-function-monitoring/src/main/java/com/mogo/eagle/core/function/monitoring/net/CameraListServices.kt @@ -1,6 +1,7 @@ package com.mogo.eagle.core.function.monitoring.net import com.mogo.eagle.core.data.camera.* +import io.reactivex.Observable import io.reactivex.Single import retrofit2.http.* @@ -22,4 +23,7 @@ interface CameraListServices { @Query("lon") lon: Double, @Query("lat") lat: Double, @Query("radiusMeter") radiusMeter: Int ): Single + + @GET("/camera-stream/stream/camera/openStream") + fun reqOpenCameraStreamWithRetry(@Query("ip") cameraIp: String): Observable } \ No newline at end of file