@@ -1,108 +0,0 @@
package com.mogo.eagle.core.data.config ;
import android.content.Context ;
import android.util.ArrayMap ;
import com.elegant.network.utils.GsonUtil ;
import com.mogo.eagle.core.data.R ;
import com.mogo.eagle.core.data.enums.EventTypeEnumNew ;
import com.mogo.eagle.core.data.map.PoiWrapper ;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger ;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr ;
import java.util.List ;
import java.util.Map ;
/**
* 云端配置poi数据管理公共类
*
* @author tongchenfei
*/
public class CloudPoiManager {
private static final String TAG = " CloudPoiManager " ;
private final Map < String , PoiWrapper > poiWrapper = new ArrayMap < > ( ) ;
private static CloudPoiManager instance = null ;
public static CloudPoiManager getInstance ( ) {
if ( instance = = null ) {
synchronized ( CloudPoiManager . class ) {
if ( instance = = null ) {
instance = new CloudPoiManager ( ) ;
}
}
}
return instance ;
}
public void generateDefault ( ) {
if ( poiWrapper . isEmpty ( ) ) {
poiWrapper . put ( EventTypeEnumNew . TRAFFIC_CHECK . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . TRAFFIC_CHECK . getPoiType ( ) ,
R . drawable . module_common_icon_map_marker_road_check2 , R . drawable . module_common_icon_map_marker_road_check2_white , " 交通检查 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . ROAD_CLOSED . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . ROAD_CLOSED . getPoiType ( ) ,
R . drawable . module_common_icon_map_marker_road_block_off2 , R . drawable . module_common_icon_map_marker_road_block_off2_white , " 封路 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . FOURS_ROAD_WORK . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . FOURS_ROAD_WORK . getPoiType ( ) ,
R . drawable . module_common_icon_map_marker_road_work2 , R . drawable . module_common_icon_map_marker_road_work2_white , " 施工 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . TYPE_SOCKET_ROAD_SHIGONG . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . TYPE_SOCKET_ROAD_SHIGONG . getPoiType ( ) ,
R . drawable . module_common_icon_map_marker_road_work2 , R . drawable . module_common_icon_map_marker_road_work2_white , " 施工 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . FOURS_BLOCK_UP . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . FOURS_BLOCK_UP . getPoiType ( ) ,
R . drawable . module_common_icon_map_marker_road_block_up2 , R . drawable . module_common_icon_map_marker_road_block_up2_white , " 拥堵 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . FOURS_PONDING . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . FOURS_PONDING . getPoiType ( ) ,
R . drawable . module_common_icon_map_marker_pondingl2 , R . drawable . module_common_icon_map_marker_pondingl2_white , " 积水 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . FOURS_ICE . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . FOURS_ICE . getPoiType ( ) ,
R . drawable . module_common_ic_rc_freeze2 , R . drawable . module_common_ic_rc_freeze2_white , " 结冰 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . FOURS_ACCIDENT . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . FOURS_ACCIDENT . getPoiType ( ) ,
R . drawable . module_common_ic_rc_accident3 , R . drawable . module_common_ic_rc_accident3_white , " 事故 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . FOURS_ACCIDENT_01 . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . FOURS_ACCIDENT_01 . getPoiType ( ) ,
R . drawable . module_common_ic_rc_accident3 , R . drawable . module_common_ic_rc_accident3_white , " 重大事故 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . FOURS_ACCIDENT_02 . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . FOURS_ACCIDENT_02 . getPoiType ( ) ,
R . drawable . module_common_ic_rc_accident3 , R . drawable . module_common_ic_rc_accident3_white , " 特大事故 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . FOURS_ACCIDENT_03 . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . FOURS_ACCIDENT_03 . getPoiType ( ) ,
R . drawable . module_common_ic_rc_accident3 , R . drawable . module_common_ic_rc_accident3_white , " 较大事故 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . FOURS_ACCIDENT_04 . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . FOURS_ACCIDENT_04 . getPoiType ( ) ,
R . drawable . module_common_ic_rc_accident3 , R . drawable . module_common_ic_rc_accident3_white , " 一般事故 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . FOURS_ACCIDENT_05 . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . FOURS_ACCIDENT_05 . getPoiType ( ) ,
R . drawable . module_common_ic_rc_accident3 , R . drawable . module_common_ic_rc_accident3_white , " 轻微事故 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . FOURS_LIVING . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . FOURS_LIVING . getPoiType ( ) ,
R . drawable . module_common_icon_map_marker_living , R . drawable . module_common_icon_map_marker_living_white , " 实时路况 " ) ) ;
poiWrapper . put ( EventTypeEnumNew . ILLEGAL_PARK_LIVING . getPoiType ( ) , new PoiWrapper ( EventTypeEnumNew . ILLEGAL_PARK_LIVING . getPoiType ( ) ,
R . drawable . module_common_ic_rc_illegal_park , R . drawable . module_common_ic_rc_illegal_park_white , " 违章停车 " ) ) ;
// 分享里用到的故障求助
poiWrapper . put ( " 9999 " , new PoiWrapper ( " 9999 " ,
R . drawable . module_common_icon_seek_help , R . drawable . module_common_icon_seek_help , " 故障求助 " ) ) ;
}
}
public void updateFromConfig ( Context context ) {
generateDefault ( ) ;
// 从sp中获取config属性, 将服务端配置内容合并到本地
String config = SharedPrefsMgr . getInstance ( context ) . getString ( " SHARE_BUTTON_CONFIG " , " " ) ;
if ( ! config . isEmpty ( ) ) {
List < PoiWrapper > configWrappers = GsonUtil . arrayFromJson ( config , PoiWrapper . class ) ;
CallerLogger . INSTANCE . d ( TAG , " config: " + configWrappers ) ;
if ( configWrappers ! = null ) {
for ( PoiWrapper wrapper : configWrappers ) {
wrapper . setIconInfoRes ( R . drawable . module_common_icon_map_marker_road_block_up2_white ) ;
wrapper . setIconRes ( R . drawable . module_common_icon_map_marker_road_block_up2 ) ;
if ( poiWrapper . containsKey ( wrapper . getPoiType ( ) ) ) {
PoiWrapper defWrapper = poiWrapper . get ( wrapper . getPoiType ( ) ) ;
if ( defWrapper ! = null ) {
wrapper . setIconRes ( defWrapper . getIconRes ( ) ) ;
wrapper . setIconInfoRes ( defWrapper . getIconInfoRes ( ) ) ;
}
}
CallerLogger . INSTANCE . d ( TAG , " put=== " + wrapper ) ;
poiWrapper . put ( wrapper . getPoiType ( ) , wrapper ) ;
}
} else {
CallerLogger . INSTANCE . e ( TAG , " 解析configWrapper异常: " + config ) ;
}
}
}
public PoiWrapper getWrapperByPoiType ( String poiType ) {
return poiWrapper . get ( poiType ) ;
}
}