[Feat]全览模式展示新基建图标
This commit is contained in:
@@ -221,6 +221,7 @@ ext {
|
||||
view_model_scope : "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0",
|
||||
live_data_scope : "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0",
|
||||
life_cycle_java8 : "androidx.lifecycle:lifecycle-common-java8:2.2.0",
|
||||
lifecycle_extension : "androidx.lifecycle:lifecycle-extensions:2.2.0",
|
||||
|
||||
|
||||
//========================== Unit Test ======================
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.mogo.eagle.core.function.api.chat.biz.ChatConsts;
|
||||
import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager;
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager;
|
||||
import com.mogo.eagle.core.function.notice.PushUIConstants;
|
||||
import com.mogo.eagle.core.function.overview.OverviewDb;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppLaunchTimeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
@@ -48,6 +49,7 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
}
|
||||
start = System.currentTimeMillis();
|
||||
connectAmiIp();
|
||||
initOverviewDb();
|
||||
// Crash 日志收集
|
||||
initCrashConfig();
|
||||
initLogConfig();
|
||||
@@ -95,6 +97,10 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
CallerDevaToolsManager.INSTANCE.init(this);
|
||||
}
|
||||
|
||||
private void initOverviewDb() {
|
||||
OverviewDb.Companion.getDb(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接ami
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,11 @@ android {
|
||||
arg("AROUTER_MODULE_NAME", project.getName())
|
||||
}
|
||||
}
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@@ -37,7 +41,6 @@ android {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -56,6 +59,12 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.amapnavi3dmap
|
||||
implementation rootProject.ext.dependencies.amaplocation
|
||||
|
||||
implementation rootProject.ext.dependencies.androidxroomruntime
|
||||
kapt rootProject.ext.dependencies.androidxroomcompiler
|
||||
implementation rootProject.ext.dependencies.androidxroomktx
|
||||
implementation rootProject.ext.dependencies.view_model_scope
|
||||
implementation rootProject.ext.dependencies.lifecycle_extension
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
|
||||
Binary file not shown.
@@ -3,6 +3,7 @@ package com.mogo.eagle.core.function.map;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_MAP;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -11,14 +12,23 @@ import androidx.annotation.Nullable;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.TextureMapView;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.eagle.core.data.constants.MoGoFragmentPaths;
|
||||
import com.mogo.eagle.core.data.map.CenterLine;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener;
|
||||
import com.mogo.eagle.core.function.api.map.hd.IMoGoMapFragmentProvider;
|
||||
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerHDMapManager;
|
||||
import com.mogo.eagle.core.function.call.monitor.CallerMonitorManager;
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager;
|
||||
import com.mogo.eagle.core.function.overview.Infrastructure;
|
||||
import com.mogo.eagle.core.function.overview.ViewModelExtKt;
|
||||
import com.mogo.eagle.core.function.overview.vm.OverViewModel;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoUiSettings;
|
||||
@@ -27,6 +37,15 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi;
|
||||
import com.zhidaoauto.map.sdk.open.business.PointCloudHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import ch.hsr.geohash.GeoHash;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @since 2021-11-09
|
||||
@@ -36,7 +55,8 @@ import com.zhidaoauto.map.sdk.open.business.PointCloudHelper;
|
||||
*/
|
||||
@Route(path = MoGoFragmentPaths.PATH_FRAGMENT_MAP)
|
||||
public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
implements MapView, IMoGoMapFragmentProvider, IMoGoSkinModeChangeListener {
|
||||
implements MapView, IMoGoMapFragmentProvider, IMoGoSkinModeChangeListener
|
||||
, IMoGoAutopilotPlanningListener {
|
||||
|
||||
private static final String TAG = "MapFragment";
|
||||
|
||||
@@ -44,6 +64,11 @@ public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
private IMogoMap mMogoMap;
|
||||
private TextureMapView mNaviMapView;
|
||||
private AMap mAMap;
|
||||
// 每个GeoHash网格对应的新基建Bean
|
||||
private Map<String, ArrayList<Infrastructure>> infMap = new HashMap();
|
||||
// 全局路径规划中的GeoHash网格
|
||||
private Map<String, ArrayList<Infrastructure>> pathMap = new HashMap();
|
||||
private Map<LatLng, Infrastructure> posInfMap = new HashMap();
|
||||
|
||||
private final boolean mIsControllerByOthersStatus = false;
|
||||
|
||||
@@ -90,6 +115,7 @@ public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
mAMap = mNaviMapView.getMap();
|
||||
// 添加换肤监听
|
||||
CallerSkinModeListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -102,6 +128,7 @@ public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
initMapView();
|
||||
queryInfStructure();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,6 +211,34 @@ public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
MapPointCloudSubscriber.Companion.getInstance();
|
||||
}
|
||||
|
||||
private boolean isFirst = true;
|
||||
|
||||
private void queryInfStructure() {
|
||||
OverViewModel viewModel = ViewModelExtKt.obtainViewModel(this, OverViewModel.class);
|
||||
// viewModel.getInfStructures().observe(this.getViewLifecycleOwner(), infrastructures -> {
|
||||
// if (isFirst) {
|
||||
// for (Infrastructure entity : infrastructures) {
|
||||
// Double lat = Double.parseDouble(entity.getLat());
|
||||
// Double lon = Double.parseDouble(entity.getLon());
|
||||
// if (lat < 0 || lat > 90 || lon < 0 || lon > 180) {
|
||||
// continue;
|
||||
// }
|
||||
// String geoHash = GeoHash.withCharacterPrecision(lat, lon, 7).toBase32();
|
||||
// viewModel.updateGeoHash(entity.getId(), geoHash);
|
||||
// }
|
||||
// isFirst = false;
|
||||
// }
|
||||
// });
|
||||
|
||||
viewModel.getInfStructuresMap().observe(this.getViewLifecycleOwner(), map -> {
|
||||
if (!infMap.isEmpty()) {
|
||||
infMap.clear();
|
||||
}
|
||||
infMap.putAll(map);
|
||||
});
|
||||
viewModel.fetchInfStructures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapUIController getUIController() {
|
||||
return mMogoMap.getUIController();
|
||||
@@ -192,6 +247,7 @@ public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
CallerSkinModeListenerManager.INSTANCE.removeListener(TAG);
|
||||
CallerAutopilotPlanningListenerManager.INSTANCE.removeListener(TAG);
|
||||
if (mMogoMapView != null) {
|
||||
mMogoMapView.onDestroy();
|
||||
mMogoMapView = null;
|
||||
@@ -302,6 +358,67 @@ public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
PointCloudHelper.INSTANCE.setIsDrawPointCloud(isDrawPointCloud);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotTrajectory(@NonNull List<MessagePad.TrajectoryPoint> trajectoryInfos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotRotting(MessagePad.GlobalPathResp globalPathResp) {
|
||||
if (globalPathResp != null) {
|
||||
if (!pathMap.isEmpty()) {
|
||||
pathMap.clear();
|
||||
}
|
||||
String geoHash;
|
||||
ArrayList<Infrastructure> infList;
|
||||
for (MessagePad.Location location : globalPathResp.getWayPointsList()) {
|
||||
geoHash = GeoHash.withCharacterPrecision(location.getLatitude(), location.getLongitude(), 7).toBase32();
|
||||
// 网格内的轨迹点只取一次
|
||||
if (!pathMap.containsKey(geoHash)) {
|
||||
// 从缓存的新基建数据中去取对应geoHash的新基建数据集合
|
||||
infList = infMap.get(geoHash);
|
||||
if (infList != null) {
|
||||
pathMap.put(geoHash, infList);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 绘制新基建数据
|
||||
if (!posInfMap.isEmpty()) {
|
||||
posInfMap.clear();
|
||||
}
|
||||
ArrayList<MarkerOptions> markerOptionsList = new ArrayList();
|
||||
for (ArrayList<Infrastructure> structureList : pathMap.values()) {
|
||||
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.icon_shexiangtou_nor)
|
||||
));
|
||||
posInfMap.put(latLng, structure);
|
||||
markerOptionsList.add(markerOption);
|
||||
}
|
||||
}
|
||||
mAMap.addMarkers(markerOptionsList, false);
|
||||
mAMap.setOnMarkerClickListener(marker -> {
|
||||
Infrastructure infrastructure = posInfMap.get(marker.getPosition());
|
||||
// 如果是摄像头
|
||||
if (0 == infrastructure.getCategory() && infrastructure.getIp() != null) {
|
||||
CallerMonitorManager.INSTANCE.openCameraStream(infrastructure.getIp(),
|
||||
flvUrl -> {
|
||||
|
||||
return null;
|
||||
}, throwable -> {
|
||||
|
||||
return null;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地图是否是Debug模式
|
||||
* @param debugMode 是否开启Debug模式
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import java.util.*
|
||||
|
||||
@Entity(tableName = "t_device")
|
||||
data class Infrastructure(
|
||||
@PrimaryKey
|
||||
@ColumnInfo(name = "id")
|
||||
var id: Int,
|
||||
|
||||
@ColumnInfo(name = "category")
|
||||
var category: Int,
|
||||
|
||||
@ColumnInfo(name = "ip")
|
||||
var ip: String?,
|
||||
|
||||
@ColumnInfo(name = "lon")
|
||||
var lon: String?,
|
||||
|
||||
@ColumnInfo(name = "lat")
|
||||
var lat: String?,
|
||||
|
||||
@ColumnInfo(name = "heading")
|
||||
var heading: Int,
|
||||
|
||||
@ColumnInfo(name = "geohash")
|
||||
var geoHash: String?
|
||||
)
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
|
||||
class OverViewManager private constructor() {
|
||||
|
||||
private object Holder {
|
||||
val INSTANCE = OverViewManager()
|
||||
}
|
||||
|
||||
companion object {
|
||||
val instance by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
Holder.INSTANCE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
|
||||
@Dao
|
||||
interface OverviewDao {
|
||||
// 0表示摄像头,8表示红绿灯
|
||||
@Query("SELECT * FROM t_device WHERE category = :category")
|
||||
suspend fun listInfStructures(category: Int): List<Infrastructure>
|
||||
|
||||
@Query("SELECT * FROM t_device")
|
||||
suspend fun listAllInfStructures(): List<Infrastructure>
|
||||
|
||||
@Query("UPDATE t_device SET geohash = :geoHash WHERE id = :id")
|
||||
suspend fun updateGeoHash(id: Int, geoHash: String)
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
|
||||
@Database(entities = [Infrastructure::class], version = 1, exportSchema = false)
|
||||
abstract class OverviewDb: RoomDatabase() {
|
||||
abstract fun overviewDao(): OverviewDao
|
||||
|
||||
companion object {
|
||||
private const val DB_PATH = "database/t_device.db"
|
||||
private const val INTERNAL_DB_NAME = "t_device.db"
|
||||
|
||||
private var db: OverviewDb? = null
|
||||
|
||||
fun getDb(context: Context): OverviewDb {
|
||||
if (db == null) {
|
||||
db = Room.databaseBuilder(context.applicationContext, OverviewDb::class.java, INTERNAL_DB_NAME)
|
||||
.createFromAsset(DB_PATH)
|
||||
.fallbackToDestructiveMigration()
|
||||
.build()
|
||||
}
|
||||
return db!!
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
|
||||
fun <T : ViewModel> AppCompatActivity.obtainViewModel(viewModelClass: Class<T>) =
|
||||
ViewModelProviders.of(this, ViewModelFactory.getInstance(application)).get(viewModelClass)
|
||||
|
||||
fun <T : ViewModel> Fragment.obtainViewModel(viewModelClass: Class<T>) =
|
||||
ViewModelProviders.of(this, ViewModelFactory.getInstance(AbsMogoApplication.getApp())).get(viewModelClass)
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Application
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.mogo.eagle.core.function.overview.vm.OverViewModel
|
||||
|
||||
class ViewModelFactory private constructor(
|
||||
private val overviewDao: OverviewDao
|
||||
) : ViewModelProvider.NewInstanceFactory() {
|
||||
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>) =
|
||||
with(modelClass) {
|
||||
when {
|
||||
isAssignableFrom(OverViewModel::class.java) ->
|
||||
OverViewModel(overviewDao)
|
||||
else ->
|
||||
throw IllegalArgumentException("Unknown ViewModel class: ${modelClass.name}")
|
||||
}
|
||||
} as T
|
||||
|
||||
companion object {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Volatile private var INSTANCE: ViewModelFactory? = null
|
||||
|
||||
fun getInstance(application: Application) =
|
||||
INSTANCE ?: synchronized(ViewModelFactory::class.java) {
|
||||
INSTANCE ?: ViewModelFactory(
|
||||
OverviewDb.getDb(application).overviewDao())
|
||||
.also { INSTANCE = it }
|
||||
}
|
||||
|
||||
@VisibleForTesting fun destroyInstance() {
|
||||
INSTANCE = null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.mogo.eagle.core.function.overview.vm
|
||||
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.*
|
||||
import com.mogo.eagle.core.function.overview.Infrastructure
|
||||
import com.mogo.eagle.core.function.overview.OverviewDao
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.lang.Exception
|
||||
|
||||
class OverViewModel(
|
||||
private val overviewDao: OverviewDao
|
||||
) : ViewModel() {
|
||||
private val _infStructures = MutableLiveData<List<Infrastructure>>()
|
||||
val infStructures
|
||||
get() = _infStructures
|
||||
|
||||
private val _infStructuresMap = _infStructures
|
||||
.switchMap { infStructures ->
|
||||
liveData {
|
||||
val map = HashMap<String, ArrayList<Infrastructure>>()
|
||||
infStructures.forEach {
|
||||
val geoHash = it.geoHash
|
||||
if (geoHash == null) {
|
||||
return@forEach
|
||||
} else {
|
||||
if (!map.containsKey(geoHash)) {
|
||||
val list = ArrayList<Infrastructure>()
|
||||
list.add(it)
|
||||
map[geoHash] = list
|
||||
} else {
|
||||
map[geoHash]?.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
emit(map)
|
||||
}
|
||||
}
|
||||
val infStructuresMap
|
||||
get() = _infStructuresMap
|
||||
|
||||
fun fetchInfStructures() {
|
||||
viewModelScope.launch {
|
||||
val data = try {
|
||||
// 只查找摄像头
|
||||
overviewDao.listInfStructures(0)
|
||||
// overviewDao.listAllInfStructures()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
Log.e("cff", "${e.cause}${e.message}")
|
||||
null
|
||||
}
|
||||
data?.let {
|
||||
_infStructures.value = it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun updateGeoHash(id: Int, geoHash: String) {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
overviewDao.updateGeoHash(id, geoHash)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
Log.e("cff", "${e.cause}${e.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
@@ -32,6 +32,7 @@ class CronTaskManager(private var context: Context?) {
|
||||
|
||||
// 开启路侧摄像头推流
|
||||
private var streamDisposable: Disposable? = null
|
||||
private var streamDisposable2: Disposable? = null
|
||||
private var cameraList: List<CameraEntity>? = null
|
||||
private var carCameraList: List<CameraEntity>? = null
|
||||
|
||||
@@ -209,6 +210,36 @@ class CronTaskManager(private var context: Context?) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 供全览模式摄像头业务使用
|
||||
*/
|
||||
fun reqOpenCameraStream(cameraIp: String, success: (String) -> Unit, error: (Throwable) -> Unit) {
|
||||
streamDisposable2?.let {
|
||||
if (!it.isDisposed) it.dispose()
|
||||
}
|
||||
streamDisposable2 = MoGoRetrofitFactory.getInstance(HostConst.CITY_HOST)
|
||||
.create(CameraListServices::class.java)
|
||||
.reqOpenCameraStream(cameraIp)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
CallerLogger.d("$M_MONITOR$TAG", "reqOpenCameraStream返回结果为:$it")
|
||||
val flvString = it.flvUrl
|
||||
if (!flvString.isNullOrEmpty()) {
|
||||
success(flvString)
|
||||
} else {
|
||||
error(Throwable("flvUrl为空"))
|
||||
}
|
||||
}, {
|
||||
CallerLogger.e(
|
||||
"$M_MONITOR$TAG",
|
||||
"reqOpenCameraStream&message is:${it.message}, cause is:${it.cause}"
|
||||
)
|
||||
error(it)
|
||||
it.printStackTrace()
|
||||
})
|
||||
}
|
||||
|
||||
fun startCronTask() {
|
||||
cronHandler.sendEmptyMessageDelayed(CRON_TASK_TYPE, 0)
|
||||
}
|
||||
@@ -231,6 +262,9 @@ class CronTaskManager(private var context: Context?) {
|
||||
streamDisposable?.let {
|
||||
if (!it.isDisposed) it.dispose()
|
||||
}
|
||||
streamDisposable2?.let {
|
||||
if (!it.isDisposed) it.dispose()
|
||||
}
|
||||
cronHandler.removeMessages(CRON_TASK_TYPE)
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.mogo.eagle.core.function.monitoring;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.camera.CameraEntity;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.eagle.core.function.api.monitoring.IMoGoMonitoringProvider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/10/29 11:09 上午
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_AI_MONITORING)
|
||||
public class MoGoMonitoringProvider implements IMoGoMonitoringProvider {
|
||||
|
||||
public String TAG = "MoGoMonitoringProvider";
|
||||
private CronTaskManager mCronTaskManager;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getFunctionName() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
mCronTaskManager = new CronTaskManager(context);
|
||||
mCronTaskManager.startCronTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CameraEntity> getCameraList() {
|
||||
return mCronTaskManager.getCameraList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openCameraStream(String cameraIp) {
|
||||
// 现在不用华哥接口,改用卫明的打开视频推流接口
|
||||
// mCronTaskManager.requestOpenCamera(cameraIp);
|
||||
mCronTaskManager.reqOpenCameraStream(cameraIp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeCameraStream() {
|
||||
mCronTaskManager.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
mCronTaskManager.onDestroy();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.mogo.eagle.core.function.monitoring
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.function.api.monitoring.IMoGoMonitoringProvider
|
||||
import com.mogo.eagle.core.data.camera.CameraEntity
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/10/29 11:09 上午
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_AI_MONITORING)
|
||||
class MoGoMonitoringProvider : IMoGoMonitoringProvider {
|
||||
override var functionName = "MoGoMonitoringProvider"
|
||||
private var mCronTaskManager: CronTaskManager? = null
|
||||
override fun init(context: Context) {
|
||||
mCronTaskManager = CronTaskManager(context)
|
||||
mCronTaskManager!!.startCronTask()
|
||||
}
|
||||
|
||||
override val cameraList: List<CameraEntity>
|
||||
get() = mCronTaskManager!!.getCameraList()
|
||||
|
||||
override fun openCameraStream(cameraIp: String) {
|
||||
// 现在不用华哥接口,改用卫明的打开视频推流接口
|
||||
// mCronTaskManager.requestOpenCamera(cameraIp);
|
||||
mCronTaskManager!!.reqOpenCameraStream(cameraIp)
|
||||
}
|
||||
|
||||
override fun openCameraStream(cameraIp: String, success: (String) -> Unit, error: (Throwable) -> Unit) {
|
||||
mCronTaskManager!!.reqOpenCameraStream(cameraIp, success, error)
|
||||
}
|
||||
|
||||
override fun disposeCameraStream() {
|
||||
mCronTaskManager!!.clear()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
mCronTaskManager!!.onDestroy()
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.mogo.eagle.core.function.api.monitoring;
|
||||
|
||||
import com.mogo.eagle.core.data.camera.CameraEntity;
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/10/29 10:35 上午
|
||||
* 超视距功能,路测摄像头,前车摄像头监控
|
||||
*/
|
||||
public interface IMoGoMonitoringProvider extends IMoGoFunctionServerProvider {
|
||||
List<CameraEntity> getCameraList();
|
||||
|
||||
void openCameraStream(String cameraIp);
|
||||
|
||||
/**
|
||||
* 防止回调摄像头列表View的相关调用
|
||||
*/
|
||||
void disposeCameraStream();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.mogo.eagle.core.function.api.monitoring
|
||||
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider
|
||||
import com.mogo.eagle.core.data.camera.CameraEntity
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/10/29 10:35 上午
|
||||
* 超视距功能,路测摄像头,前车摄像头监控
|
||||
*/
|
||||
interface IMoGoMonitoringProvider : IMoGoFunctionServerProvider {
|
||||
val cameraList: List<CameraEntity>?
|
||||
fun openCameraStream(cameraIp: String)
|
||||
fun openCameraStream(cameraIp: String, success: (String) -> Unit, error: (Throwable) -> Unit)
|
||||
/**
|
||||
* 防止回调摄像头列表View的相关调用
|
||||
*/
|
||||
fun disposeCameraStream()
|
||||
}
|
||||
@@ -19,6 +19,10 @@ object CallerMonitorManager {
|
||||
providerApi.openCameraStream(cameraIp)
|
||||
}
|
||||
|
||||
fun openCameraStream(cameraIp: String, success: (String) -> Unit, error: (Throwable) -> Unit) {
|
||||
providerApi.openCameraStream(cameraIp, success, error)
|
||||
}
|
||||
|
||||
fun disposeCameraStream() {
|
||||
providerApi.disposeCameraStream()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user