Merge branch 'feature/v1.0.0' of gitlab.zhidaoauto.com:ecos/yycp-service/Launcher into feature/v1.0.0
This commit is contained in:
@@ -10,7 +10,6 @@ import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.launcher.news.FreshNewsConstants;
|
||||
import com.mogo.module.adcard.AdCardConstants;
|
||||
import com.mogo.module.back.BackToMainHomeManager;
|
||||
import com.mogo.module.carchatting.card.CallChatConstant;
|
||||
import com.mogo.module.common.MogoModule;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
|
||||
@@ -298,6 +298,7 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
return mMarker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoMarkerOptions getMogoMarkerOptions() {
|
||||
return mMogoMarkerOptions;
|
||||
}
|
||||
|
||||
@@ -222,4 +222,11 @@ public interface IMogoMarker {
|
||||
* @param position window 的位置。
|
||||
*/
|
||||
void setPositionByPixels( Point position );
|
||||
|
||||
/**
|
||||
* Marker 配置
|
||||
* @return
|
||||
*/
|
||||
MogoMarkerOptions getMogoMarkerOptions();
|
||||
|
||||
}
|
||||
|
||||
@@ -14,64 +14,77 @@ public class MarkerUserInfo implements Serializable {
|
||||
private String userName;//用户昵称
|
||||
private String userHead;//用户头像
|
||||
private String gender;//gender": "男|女|无(也可以0|1|2根据实际库存返回即可)
|
||||
private int age;// 年龄段,可以为空,与车聊聊一致
|
||||
private Integer age;// 年龄段,可以为空,与车聊聊一致
|
||||
|
||||
public void setAge(int age) {
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public int getAgeNumber() {
|
||||
return age;
|
||||
if (age != null) {
|
||||
return age;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public String getAge() {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int year = cal.get(Calendar.YEAR);
|
||||
try {
|
||||
if (getAgeNumber() >= 0) {
|
||||
|
||||
//2020-30=1990
|
||||
double ageDiffer = year - age;
|
||||
String ageStr = "" + ageDiffer;
|
||||
char[] ageChars = ageStr.toCharArray();
|
||||
Calendar cal = Calendar.getInstance();
|
||||
int year = cal.get(Calendar.YEAR);
|
||||
|
||||
//1990
|
||||
char ageChar = ageChars[2];
|
||||
//2020-30=1990
|
||||
double ageDiffer = year - getAgeNumber();
|
||||
String ageStr = "" + ageDiffer;
|
||||
char[] ageChars = ageStr.toCharArray();
|
||||
|
||||
String ageString = "未设置";
|
||||
//1990
|
||||
char ageChar = ageChars[2];
|
||||
|
||||
switch (ageChar) {
|
||||
case '0':
|
||||
ageString = "00后";
|
||||
break;
|
||||
case '1':
|
||||
ageString = "10后";
|
||||
break;
|
||||
case '2':
|
||||
ageString = "20后";
|
||||
break;
|
||||
case '3':
|
||||
ageString = "30后";
|
||||
break;
|
||||
case '4':
|
||||
ageString = "40后";
|
||||
break;
|
||||
case '5':
|
||||
ageString = "50后";
|
||||
break;
|
||||
case '6':
|
||||
ageString = "60后";
|
||||
break;
|
||||
case '7':
|
||||
ageString = "70后";
|
||||
break;
|
||||
case '8':
|
||||
ageString = "80后";
|
||||
break;
|
||||
case '9':
|
||||
ageString = "90后";
|
||||
break;
|
||||
String ageString = "未设置";
|
||||
|
||||
switch (ageChar) {
|
||||
case '0':
|
||||
ageString = "00后";
|
||||
break;
|
||||
case '1':
|
||||
ageString = "10后";
|
||||
break;
|
||||
case '2':
|
||||
ageString = "20后";
|
||||
break;
|
||||
case '3':
|
||||
ageString = "30后";
|
||||
break;
|
||||
case '4':
|
||||
ageString = "40后";
|
||||
break;
|
||||
case '5':
|
||||
ageString = "50后";
|
||||
break;
|
||||
case '6':
|
||||
ageString = "60后";
|
||||
break;
|
||||
case '7':
|
||||
ageString = "70后";
|
||||
break;
|
||||
case '8':
|
||||
ageString = "80后";
|
||||
break;
|
||||
case '9':
|
||||
ageString = "90后";
|
||||
break;
|
||||
}
|
||||
|
||||
return ageString;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
|
||||
return ageString;
|
||||
}
|
||||
|
||||
public int getGenderValue() {
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.map.location.IMogoLocationClient
|
||||
import com.mogo.map.marker.IMogoMarkerManager
|
||||
import com.mogo.map.navi.IMogoNavi
|
||||
import com.mogo.map.search.geo.IMogoGeoSearch
|
||||
@@ -59,6 +60,10 @@ object SearchServiceHolder{
|
||||
return mapService.getNavi(context)
|
||||
}
|
||||
|
||||
fun getLocationClient(): IMogoLocationClient {
|
||||
return mapService.getLocationClient(context)
|
||||
}
|
||||
|
||||
fun getMapUIController(): IMogoMapUIController {
|
||||
return mapService.mapUIController
|
||||
}
|
||||
|
||||
@@ -64,7 +64,6 @@ public class CategoryPresenter extends Presenter<CategoryView> {
|
||||
public void startSearchLocalPoiByInput(String keyword) {
|
||||
MogoPoiSearchQuery mogoInputtipsQuery = new MogoPoiSearchQuery(keyword, keyword);
|
||||
mogoInputtipsQuery.setPageSize(10);
|
||||
mogoInputtipsQuery.getCity();
|
||||
mogoInputtipsQuery.setLocation(
|
||||
SearchServiceHolder.INSTANCE.getMapUIController().getWindowCenterLocation());
|
||||
IMogoPoiSearch inputtipsSearch =
|
||||
|
||||
@@ -83,7 +83,7 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
SearchServiceHolder.INSTANCE.getMarkerManger().removeMarkers();
|
||||
SearchServiceHolder.INSTANCE.getMapUIController().showMyLocation( false );
|
||||
SearchServiceHolder.INSTANCE.getMapUIController().showMyLocation(false);
|
||||
moveMapToCenter();
|
||||
}
|
||||
|
||||
@@ -116,10 +116,12 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi
|
||||
|
||||
mHistoryAdapter.setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
SearchServiceHolder.INSTANCE.getAnalyticsManager().track("Navigation_History_destination", new HashMap<String,Object>());
|
||||
SearchServiceHolder.INSTANCE.getAnalyticsManager()
|
||||
.track("Navigation_History_destination", new HashMap<String, Object>());
|
||||
SearchPoi item = (SearchPoi) v.getTag(R.id.tag_item);
|
||||
MogoTip mogoTip = EntityConvertUtils.poi2MogoTip(item);
|
||||
SearchServiceHolder.INSTANCE.push(ChoosePathFragment.Companion.newInstance(mogoTip.getPoint()),
|
||||
SearchServiceHolder.INSTANCE.push(
|
||||
ChoosePathFragment.Companion.newInstance(mogoTip.getPoint()),
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT);
|
||||
}
|
||||
});
|
||||
@@ -128,9 +130,15 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi
|
||||
@Override public void onClick(View v) {
|
||||
MogoTip tag = (MogoTip) v.getTag(R.id.tag_position);
|
||||
SearchPoi searchPoi = EntityConvertUtils.tipToPoi(tag);
|
||||
mSearchPresenter.insert(searchPoi);
|
||||
SearchServiceHolder.INSTANCE.push(ChoosePathFragment.Companion.newInstance(tag.getPoint()),
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT);
|
||||
if (tag.getPoint() == null) {
|
||||
push(CategorySearchFragment.Companion.newInstance(tag.getName()),
|
||||
MogoModulePaths.PATH_FRAGMENT_SEARCH_CATEGORY);
|
||||
} else {
|
||||
mSearchPresenter.insert(searchPoi);
|
||||
SearchServiceHolder.INSTANCE.push(
|
||||
ChoosePathFragment.Companion.newInstance(tag.getPoint()),
|
||||
MogoModulePaths.PATH_FRAGMENT_CHOOSE_PAHT);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -142,7 +150,8 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi
|
||||
|
||||
findViewById(R.id.tv_navi_setting).setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
SearchServiceHolder.INSTANCE.getAnalyticsManager().track("Navigation_button_setting", new HashMap<String,Object>());
|
||||
SearchServiceHolder.INSTANCE.getAnalyticsManager()
|
||||
.track("Navigation_button_setting", new HashMap<String, Object>());
|
||||
|
||||
push(new NaviSettingFragment(), MogoModulePaths.PATH_FRAGMENT_SETTING);
|
||||
}
|
||||
@@ -168,7 +177,8 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi
|
||||
|
||||
findViewById(R.id.tv_navi_search).setOnClickListener(new View.OnClickListener() {
|
||||
@Override public void onClick(View v) {
|
||||
SearchServiceHolder.INSTANCE.getAnalyticsManager().track("Navigation_button_search", new HashMap<String,Object>());
|
||||
SearchServiceHolder.INSTANCE.getAnalyticsManager()
|
||||
.track("Navigation_button_search", new HashMap<String, Object>());
|
||||
|
||||
mSearchPresenter.startSearchPoiByInput(mSearchBox.getText().toString());
|
||||
}
|
||||
@@ -404,7 +414,7 @@ public class SearchFragment extends BaseSearchFragment implements SearchView, Vi
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
SearchServiceHolder.INSTANCE.getMapUIController().showMyLocation( true );
|
||||
SearchServiceHolder.INSTANCE.getMapUIController().showMyLocation(true);
|
||||
moveMapToRight();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.search.geo.MogoPoiItem;
|
||||
import com.mogo.map.search.inputtips.IMogoInputtipsListener;
|
||||
import com.mogo.map.search.inputtips.IMogoInputtipsSearch;
|
||||
@@ -100,6 +101,11 @@ public class SearchPresenter extends Presenter< SearchView >
|
||||
public void startSearchPoiByInput( String keyword ) {
|
||||
MogoInputtipsQuery mogoInputtipsQuery = new MogoInputtipsQuery();
|
||||
mogoInputtipsQuery.setKeyword(keyword);
|
||||
|
||||
MogoLocation lastKnowLocation =
|
||||
SearchServiceHolder.INSTANCE.getLocationClient().getLastKnowLocation();
|
||||
mogoInputtipsQuery.setCity(lastKnowLocation.getCityName());
|
||||
mogoInputtipsQuery.setCityLimit(true);
|
||||
IMogoInputtipsSearch inputtipsSearch =
|
||||
mMapService.getInputtipsSearch(getContext(), mogoInputtipsQuery);
|
||||
|
||||
|
||||
@@ -1,49 +1,22 @@
|
||||
package com.mogo.module.service;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.module.common.entity.MarkerCarChat;
|
||||
import com.mogo.module.common.entity.MarkerCardResult;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.MarkerNoveltyInfo;
|
||||
import com.mogo.module.common.entity.MarkerOnlineCar;
|
||||
import com.mogo.module.common.entity.MarkerPoiTypeEnum;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.common.entity.MarkerShareMusic;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.service.marker.MapMarkerAdapter;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.analytics.IMogoAnalytics;
|
||||
import com.mogo.service.cardmanager.IMogoCardChangedListener;
|
||||
import com.mogo.service.cardmanager.IMogoCardManager;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.connection.IMogoSocketManager;
|
||||
import com.mogo.service.imageloader.IMogoImageloader;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
@@ -55,7 +28,6 @@ import java.util.Map;
|
||||
public class MarkerServiceHandler {
|
||||
private static final String TAG = "MarkerServiceHandler";
|
||||
|
||||
private static MoGoMarkerClickListener mogoMarkerClickListener;
|
||||
|
||||
private static IMogoMapService mMapService;
|
||||
private static IMogoMarkerManager mMarkerManager;
|
||||
@@ -70,17 +42,13 @@ public class MarkerServiceHandler {
|
||||
private static IMogoCardManager mMogoCardManager;
|
||||
private static IMogoAnalytics mMogoAnalytics;
|
||||
|
||||
private static Context mContext;
|
||||
private static MapMarkerManager mMapMarkerManager;
|
||||
|
||||
// 第一次请求到地图的Marker数据
|
||||
private static boolean isFirstMarker = true;
|
||||
|
||||
public static void init(final Context context) {
|
||||
mContext = context;
|
||||
mMapService = (IMogoMapService) ARouter.getInstance().build(MogoServicePaths.PATH_SERVICES_MAP).navigation(context);
|
||||
mImageloader = (IMogoImageloader) ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_IMAGE_LOADER).navigation(context);
|
||||
mMogoStatusManager = (IMogoStatusManager) ARouter.getInstance().build(MogoServicePaths.PATH_STATUS_MANAGER).navigation(context);
|
||||
mMogoStatusManager = (IMogoStatusManager) ARouter.getInstance().build(MogoServicePaths.PATH_STATUS_MANAGER).navigation(context);
|
||||
mMogoSocketManager = (IMogoSocketManager) ARouter.getInstance().build(MogoServicePaths.PATH_SOCKET_MANAGER).navigation();
|
||||
mMogoCardManager = (IMogoCardManager) ARouter.getInstance().build(MogoServicePaths.PATH_CARD_MANAGER).navigation();
|
||||
mMogoAnalytics = (IMogoAnalytics) ARouter.getInstance().build(MogoServicePaths.PATH_UTILS_ANALYTICS).navigation();
|
||||
@@ -89,40 +57,9 @@ public class MarkerServiceHandler {
|
||||
mNavi = mMapService.getNavi(context);
|
||||
mMapUIController = mMapService.getMapUIController();
|
||||
mLocationClient = mMapService.getLocationClient(context);
|
||||
mogoMarkerClickListener = new MoGoMarkerClickListener();
|
||||
|
||||
// 长连接
|
||||
mMogoSocketManager.registerOnMessageListener(401001, new IMogoOnMessageListener<MarkerResponse>() {
|
||||
|
||||
@Override
|
||||
public Class<MarkerResponse> target() {
|
||||
return MarkerResponse.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(final MarkerResponse response) {
|
||||
Logger.e(TAG, "======MarkerResponse:" + response);
|
||||
if (!getMogoStatusManager().isSearchUIShow() && !getMogoStatusManager().isV2XShow()) {
|
||||
isFirstMarker = true;
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
drawMapMarker(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getMogoCardManager().registerCardChangedListener("LAUNCHER_MARKER_MODULE", new IMogoCardChangedListener() {
|
||||
|
||||
@Override
|
||||
public void onSwitched(int position, String moduleName) {
|
||||
Logger.e(TAG, "======moduleName:" + moduleName);
|
||||
highlightedMarker(moduleName);
|
||||
}
|
||||
});
|
||||
mMapMarkerManager = MapMarkerManager.getInstance(context);
|
||||
mMapMarkerManager.init(context);
|
||||
}
|
||||
|
||||
public static IMogoMapService getMapService() {
|
||||
@@ -161,356 +98,44 @@ public class MarkerServiceHandler {
|
||||
return mMogoAnalytics;
|
||||
}
|
||||
|
||||
private static IMogoMarker lastMarker;
|
||||
|
||||
/**
|
||||
* 地图上的Marker点击回调
|
||||
*/
|
||||
static class MoGoMarkerClickListener implements IMogoMarkerClickListener {
|
||||
|
||||
@Override
|
||||
public boolean onMarkerClicked(IMogoMarker marker) {
|
||||
Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker:" + marker);
|
||||
try {
|
||||
if (lastMarker != null) {
|
||||
// 判断点击的是否是同一个
|
||||
if (marker.equals(lastMarker)) {
|
||||
Logger.w(TAG, "onMarkerClicked 与上一次点击的Marker一样,不做处理:" + marker);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 将上次选中 Marker 设置为未选中状态
|
||||
MarkerShowEntity lastMarkerShowEntity = (MarkerShowEntity) lastMarker.getObject();
|
||||
|
||||
Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker lastMarkerShowEntity:" + lastMarkerShowEntity);
|
||||
|
||||
lastMarkerShowEntity.setChecked(false);
|
||||
lastMarkerShowEntity.setHighlighted(false);
|
||||
|
||||
drawMapMarker(lastMarkerShowEntity);
|
||||
|
||||
lastMarker.remove();
|
||||
}
|
||||
|
||||
// 将当前的Marker设置为选中
|
||||
MarkerShowEntity markerShowEntity = (MarkerShowEntity) marker.getObject();
|
||||
Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker markerShowEntity:" + markerShowEntity);
|
||||
|
||||
markerShowEntity.setChecked(true);
|
||||
markerShowEntity.setHighlighted(true);
|
||||
|
||||
lastMarker = drawMapMarker(markerShowEntity);
|
||||
if (lastMarker != null) {
|
||||
lastMarker.setAlpha(1f);
|
||||
}
|
||||
|
||||
marker.remove();
|
||||
|
||||
final Map<String, Object> properties = new HashMap<>();
|
||||
switch (lastMarker.getOwner()) {
|
||||
case ServiceConst.CARD_TYPE_CARS_CHATTING:
|
||||
properties.put("type", 3);
|
||||
break;
|
||||
case ServiceConst.CARD_TYPE_USER_DATA:
|
||||
properties.put("type", 5);
|
||||
break;
|
||||
case ServiceConst.CARD_TYPE_ROAD_CONDITION:
|
||||
properties.put("type", 2);
|
||||
break;
|
||||
case ServiceConst.CARD_TYPE_NOVELTY:
|
||||
MarkerShowEntity showEntity = (MarkerShowEntity) lastMarker.getObject();
|
||||
Object bindObj = showEntity.getBindObj();
|
||||
if (bindObj instanceof MarkerNoveltyInfo) {
|
||||
switch (((MarkerNoveltyInfo) bindObj).getPoiType()) {
|
||||
case MarkerPoiTypeEnum.GAS_STATION:
|
||||
properties.put("type", 4);
|
||||
break;
|
||||
case MarkerPoiTypeEnum.TRAFFIC_CHECK:
|
||||
properties.put("type", 8);
|
||||
break;
|
||||
case MarkerPoiTypeEnum.ROAD_CLOSED:
|
||||
properties.put("type", 7);
|
||||
break;
|
||||
case MarkerPoiTypeEnum.SHOP_DISCOUNT:
|
||||
properties.put("type", 9);
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_SHOP:
|
||||
properties.put("type", 10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ServiceConst.CARD_TYPE_SHARE_MUSIC:
|
||||
properties.put("type", 6);
|
||||
break;
|
||||
}
|
||||
|
||||
getMogoAnalytics().track("Launcher_Icon_Click", properties);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static IMogoLocationClient getMogoLocationClient() {
|
||||
return mLocationClient;
|
||||
}
|
||||
|
||||
// 对指定类型高亮处理
|
||||
public static void highlightedMarker(String typeTag) {
|
||||
try {
|
||||
Map<String, List<IMogoMarker>> allMarker = getMarkerManager().getAllMarkers();
|
||||
for (Map.Entry<String, List<IMogoMarker>> entry : allMarker.entrySet()) {
|
||||
String keyStr = entry.getKey();
|
||||
List<IMogoMarker> markerList = entry.getValue();
|
||||
public static MapMarkerManager getMapMarkerManager() {
|
||||
return mMapMarkerManager;
|
||||
}
|
||||
|
||||
if (keyStr.equals(typeTag)) {
|
||||
for (IMogoMarker marker : markerList) {
|
||||
marker.setAlpha(1f);
|
||||
}
|
||||
} else {
|
||||
for (IMogoMarker marker : markerList) {
|
||||
marker.setAlpha(0.7f);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//TODO -------------以下方法是临时过度使用的,后面统一使用,getMapMarkerManager进行调用
|
||||
|
||||
/**
|
||||
* 绘制Marker
|
||||
* 建议使用
|
||||
* @see MapMarkerManager#drawMapMarker(MarkerResponse)
|
||||
*/
|
||||
@Deprecated
|
||||
public static void drawMapMarker(MarkerResponse response) {
|
||||
getMapMarkerManager().drawMapMarker(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制Marker
|
||||
* 建议使用
|
||||
* @see MapMarkerManager#drawMapMarker(MarkerShowEntity)
|
||||
*/
|
||||
public static void drawMapMarker(MarkerResponse response) {
|
||||
lastMarker = null;
|
||||
|
||||
JSONArray array = new JSONArray();
|
||||
|
||||
// 解析不同的Marker类型,然后对应的进行绘制
|
||||
if (response != null && response.getResult() != null) {
|
||||
|
||||
MarkerCardResult markerCardResult = response.getResult();
|
||||
|
||||
// 语音触发的在线车辆搜索,采用增量的形式绘制
|
||||
if (markerCardResult.getDataType() != null &&
|
||||
markerCardResult.getDataType().size() == 1 &&
|
||||
markerCardResult.getDataType().contains(ServiceConst.CARD_TYPE_USER_DATA)) {
|
||||
getMarkerManager().removeMarkers(ServiceConst.CARD_TYPE_USER_DATA);
|
||||
getMogoCardManager().switch2(ServiceConst.CARD_TYPE_USER_DATA);
|
||||
isFirstMarker = true;
|
||||
} else {
|
||||
// 清空所有地图上绘制的Marker
|
||||
getMarkerManager().removeMarkers();
|
||||
}
|
||||
|
||||
List<MarkerCarChat> carChatList = markerCardResult.getCarChat();
|
||||
List<MarkerOnlineCar> onlineCarList = markerCardResult.getOnlineCar();
|
||||
List<MarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
|
||||
List<MarkerShareMusic> shareMusicList = markerCardResult.getShareMusic();
|
||||
List<MarkerNoveltyInfo> noveltyInfoList = markerCardResult.getNoveltyInfo();
|
||||
|
||||
if (carChatList != null) {
|
||||
for (MarkerCarChat markerCarChat : carChatList) {
|
||||
MarkerLocation markerLocation = markerCarChat.getLocation();
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj(markerCarChat);
|
||||
markerShowEntity.setMarkerLocation(markerLocation);
|
||||
markerShowEntity.setMarkerType(markerCarChat.getType());
|
||||
markerShowEntity.setTextContent(markerCarChat.getUserInfo().getUserName());
|
||||
markerShowEntity.setIconUrl(markerCarChat.getUserInfo().getUserHead());
|
||||
|
||||
drawMapMarker(markerShowEntity);
|
||||
}
|
||||
}
|
||||
|
||||
if (onlineCarList != null) {
|
||||
IMogoMarker nearlyMogoMarker = null;
|
||||
double nearlyDistance = Double.MAX_VALUE;
|
||||
for (MarkerOnlineCar markerOnlineCar : onlineCarList) {
|
||||
MarkerLocation markerLocation = markerOnlineCar.getLocation();
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj(markerOnlineCar);
|
||||
markerShowEntity.setMarkerLocation(markerLocation);
|
||||
markerShowEntity.setMarkerType(markerOnlineCar.getType());
|
||||
markerShowEntity.setTextContent(markerOnlineCar.getUserInfo().getUserName());
|
||||
markerShowEntity.setIconUrl(markerOnlineCar.getUserInfo().getUserHead());
|
||||
|
||||
IMogoMarker iMogoMarker = drawMapMarker(markerShowEntity);
|
||||
// 计算在线车辆距离当前车辆的距离,每次都与最后一次距离最近的进行比较,保留距离最近的车辆,进行卡片展示
|
||||
try {
|
||||
double calculateDistance = Utils.calculateLineDistance(
|
||||
new MogoLatLng(markerLocation.getLat(), markerLocation.getLat()),
|
||||
new MogoLatLng(mLocationClient.getLastKnowLocation().getLatitude(), mLocationClient.getLastKnowLocation().getLongitude())
|
||||
);
|
||||
|
||||
// 进行比较,保留最近的一个数据
|
||||
if (calculateDistance < nearlyDistance) {
|
||||
nearlyMogoMarker = iMogoMarker;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
fillNumberTrackEventBody(array, 3, onlineCarList.size());
|
||||
|
||||
try {
|
||||
// 在ACC on 之后第一次获取到了在线车辆数据,选中最近的一个Marker
|
||||
if (isFirstMarker) {
|
||||
if (nearlyMogoMarker != null) {
|
||||
// getMogoCardManager().switch2(ServiceConst.CARD_TYPE_USER_DATA);
|
||||
// MarkerShowEntity markerShowEntity = (MarkerShowEntity) nearlyMogoMarker.getObject();
|
||||
// MarkerOnlineCar markerOnlineCar = (MarkerOnlineCar) markerShowEntity.getBindObj();
|
||||
// onLineCarCardViewProvider.updateView(markerOnlineCar);
|
||||
MogoMarkersHandler.getInstance().onMarkerClicked(nearlyMogoMarker);
|
||||
isFirstMarker = false;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (exploreWayList != null) {
|
||||
for (MarkerExploreWay markerExploreWay : exploreWayList) {
|
||||
if (!markerExploreWay.getCanLive()) {
|
||||
MarkerLocation markerLocation = markerExploreWay.getLocation();
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj(markerExploreWay);
|
||||
markerShowEntity.setMarkerLocation(markerLocation);
|
||||
markerShowEntity.setMarkerType(markerExploreWay.getType());
|
||||
markerShowEntity.setTextContent(markerExploreWay.getAddr());
|
||||
|
||||
drawMapMarker(markerShowEntity);
|
||||
}
|
||||
}
|
||||
fillNumberTrackEventBody(array, 1, exploreWayList.size());
|
||||
}
|
||||
|
||||
if (shareMusicList != null) {
|
||||
for (MarkerShareMusic markerShareMusic : shareMusicList) {
|
||||
MarkerLocation markerLocation = markerShareMusic.getLocation();
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj(markerShareMusic);
|
||||
markerShowEntity.setMarkerLocation(markerLocation);
|
||||
markerShowEntity.setMarkerType(markerShareMusic.getType());
|
||||
markerShowEntity.setTextContent(markerShareMusic.getMediaName());
|
||||
markerShowEntity.setIconUrl(markerShareMusic.getMediaImg());
|
||||
|
||||
drawMapMarker(markerShowEntity);
|
||||
}
|
||||
fillNumberTrackEventBody(array, 4, shareMusicList.size());
|
||||
}
|
||||
|
||||
if (noveltyInfoList != null) {
|
||||
int num_gas_station = 0;
|
||||
int num_traffic_check = 0;
|
||||
int num_road_closed = 0;
|
||||
int num_shop_discount = 0;
|
||||
int num_fours_shop = 0;
|
||||
|
||||
for (MarkerNoveltyInfo noveltyInfo : noveltyInfoList) {
|
||||
MarkerLocation markerLocation = noveltyInfo.getLocation();
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj(noveltyInfo);
|
||||
markerShowEntity.setMarkerLocation(markerLocation);
|
||||
markerShowEntity.setMarkerType(noveltyInfo.getType());
|
||||
markerShowEntity.setTextContent(noveltyInfo.getLocation().getAddress());
|
||||
|
||||
drawMapMarker(markerShowEntity);
|
||||
|
||||
switch (noveltyInfo.getPoiType()) {
|
||||
case MarkerPoiTypeEnum.GAS_STATION:
|
||||
num_gas_station++;
|
||||
break;
|
||||
case MarkerPoiTypeEnum.TRAFFIC_CHECK:
|
||||
num_traffic_check++;
|
||||
break;
|
||||
case MarkerPoiTypeEnum.ROAD_CLOSED:
|
||||
num_road_closed++;
|
||||
break;
|
||||
case MarkerPoiTypeEnum.SHOP_DISCOUNT:
|
||||
num_shop_discount++;
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_SHOP:
|
||||
num_fours_shop++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fillNumberTrackEventBody(array, 2, num_gas_station);
|
||||
fillNumberTrackEventBody(array, 6, num_road_closed);
|
||||
fillNumberTrackEventBody(array, 5, num_traffic_check);
|
||||
fillNumberTrackEventBody(array, 7, num_shop_discount);
|
||||
fillNumberTrackEventBody(array, 8, num_fours_shop);
|
||||
}
|
||||
analyticData(array);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void fillNumberTrackEventBody(JSONArray arr, int type, int size) {
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put("type", type);
|
||||
object.put("num", size);
|
||||
if (arr != null) {
|
||||
arr.put(object);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@Deprecated
|
||||
public static void drawMapMarker(MarkerShowEntity markerShowEntity) {
|
||||
getMapMarkerManager().drawMapMarker(markerShowEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计地图内数据获取
|
||||
*
|
||||
* @param array 埋点数据
|
||||
* 对指定类型高亮处理
|
||||
* 建议使用
|
||||
* @see MapMarkerManager#highlightedMarker(String)
|
||||
*/
|
||||
private static void analyticData(JSONArray array) {
|
||||
try {
|
||||
if (array == null || array.length() == 0) {
|
||||
return;
|
||||
}
|
||||
final Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("data", array.toString());
|
||||
getMogoAnalytics().track("Launcher_Data_Get", properties);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@Deprecated
|
||||
public static void highlightedMarker(String typeTag) {
|
||||
getMapMarkerManager().highlightedMarker(typeTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制Marker,这里绘制的会使用markerShowEntities队列进行维护
|
||||
*/
|
||||
public static IMogoMarker drawMapMarker(MarkerShowEntity markerShowEntity) {
|
||||
// Logger.i(TAG, "绘制Marker====drawMapMarker:" + markerShowEntity);
|
||||
try {
|
||||
if (markerShowEntity.getMarkerLocation() != null) {
|
||||
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner(markerShowEntity.getMarkerType())
|
||||
.alpha(0.7f)
|
||||
.object(markerShowEntity)
|
||||
.latitude(markerShowEntity.getMarkerLocation().getLat())
|
||||
.longitude(markerShowEntity.getMarkerLocation().getLon());
|
||||
View markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
|
||||
options.icon(markerView);
|
||||
|
||||
IMogoMarker marker = getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
|
||||
marker.setOnMarkerClickListener(mogoMarkerClickListener);
|
||||
return marker;
|
||||
} else {
|
||||
Logger.e(TAG, "Location 必须进行初始化!!!!!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,488 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
import com.mogo.module.common.entity.MarkerCarChat;
|
||||
import com.mogo.module.common.entity.MarkerCardResult;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.MarkerNoveltyInfo;
|
||||
import com.mogo.module.common.entity.MarkerOnlineCar;
|
||||
import com.mogo.module.common.entity.MarkerPoiTypeEnum;
|
||||
import com.mogo.module.common.entity.MarkerResponse;
|
||||
import com.mogo.module.common.entity.MarkerShareMusic;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.Utils;
|
||||
import com.mogo.service.cardmanager.IMogoCardChangedListener;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-02-1010:44
|
||||
* desc : 大而全的Marker管理
|
||||
* version: 1.0
|
||||
*/
|
||||
public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessageListener<MarkerResponse> {
|
||||
private static final String TAG = "MarkerManager";
|
||||
// 第一次请求到地图的Marker数据
|
||||
private boolean isFirstMarker = true;
|
||||
private Context mContext;
|
||||
private static IMogoMarker lastMarker;
|
||||
private static MapMarkerManager mMarkerManager;
|
||||
|
||||
private MapMarkerManager() {
|
||||
}
|
||||
|
||||
public static synchronized MapMarkerManager getInstance(Context context) {
|
||||
synchronized (MapMarkerManager.class) {
|
||||
if (mMarkerManager == null) {
|
||||
mMarkerManager = new MapMarkerManager();
|
||||
}
|
||||
}
|
||||
return mMarkerManager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化大而全的 Marker 管理
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public void init(Context context) {
|
||||
mContext = context;
|
||||
// 长连接
|
||||
MarkerServiceHandler
|
||||
.getMogoSocketManager()
|
||||
.registerOnMessageListener(401001, this);
|
||||
|
||||
MarkerServiceHandler.getMogoCardManager().registerCardChangedListener("LAUNCHER_MARKER_MODULE", new IMogoCardChangedListener() {
|
||||
|
||||
@Override
|
||||
public void onSwitched(int position, String moduleName) {
|
||||
Logger.e(TAG, "======moduleName:" + moduleName);
|
||||
highlightedMarker(moduleName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 地图上的Marker点击回调
|
||||
*/
|
||||
@Override
|
||||
public boolean onMarkerClicked(IMogoMarker marker) {
|
||||
Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker:" + marker);
|
||||
try {
|
||||
if (lastMarker != null) {
|
||||
// 判断点击的是否是同一个
|
||||
if (marker.equals(lastMarker)) {
|
||||
Logger.w(TAG, "onMarkerClicked 与上一次点击的Marker一样,不做处理:" + marker);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 将上次选中 Marker 设置为未选中状态
|
||||
MarkerShowEntity lastMarkerShowEntity = (MarkerShowEntity) lastMarker.getObject();
|
||||
|
||||
Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker lastMarkerShowEntity:" + lastMarkerShowEntity);
|
||||
|
||||
lastMarkerShowEntity.setChecked(false);
|
||||
lastMarkerShowEntity.setHighlighted(false);
|
||||
|
||||
drawMapMarker(lastMarkerShowEntity);
|
||||
|
||||
lastMarker.remove();
|
||||
}
|
||||
|
||||
// 将当前的Marker设置为选中
|
||||
MarkerShowEntity markerShowEntity = (MarkerShowEntity) marker.getObject();
|
||||
Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker markerShowEntity:" + markerShowEntity);
|
||||
|
||||
markerShowEntity.setChecked(true);
|
||||
markerShowEntity.setHighlighted(true);
|
||||
|
||||
lastMarker = drawMapMarker(markerShowEntity);
|
||||
if (lastMarker != null) {
|
||||
lastMarker.setAlpha(1f);
|
||||
}
|
||||
|
||||
marker.remove();
|
||||
|
||||
final Map<String, Object> properties = new HashMap<>();
|
||||
switch (lastMarker.getOwner()) {
|
||||
case ServiceConst.CARD_TYPE_CARS_CHATTING:
|
||||
properties.put("type", 3);
|
||||
break;
|
||||
case ServiceConst.CARD_TYPE_USER_DATA:
|
||||
properties.put("type", 5);
|
||||
break;
|
||||
case ServiceConst.CARD_TYPE_ROAD_CONDITION:
|
||||
properties.put("type", 2);
|
||||
break;
|
||||
case ServiceConst.CARD_TYPE_NOVELTY:
|
||||
MarkerShowEntity showEntity = (MarkerShowEntity) lastMarker.getObject();
|
||||
Object bindObj = showEntity.getBindObj();
|
||||
if (bindObj instanceof MarkerNoveltyInfo) {
|
||||
switch (((MarkerNoveltyInfo) bindObj).getPoiType()) {
|
||||
case MarkerPoiTypeEnum.GAS_STATION:
|
||||
properties.put("type", 4);
|
||||
break;
|
||||
case MarkerPoiTypeEnum.TRAFFIC_CHECK:
|
||||
properties.put("type", 8);
|
||||
break;
|
||||
case MarkerPoiTypeEnum.ROAD_CLOSED:
|
||||
properties.put("type", 7);
|
||||
break;
|
||||
case MarkerPoiTypeEnum.SHOP_DISCOUNT:
|
||||
properties.put("type", 9);
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_SHOP:
|
||||
properties.put("type", 10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ServiceConst.CARD_TYPE_SHARE_MUSIC:
|
||||
properties.put("type", 6);
|
||||
break;
|
||||
}
|
||||
|
||||
MarkerServiceHandler.getMogoAnalytics().track("Launcher_Icon_Click", properties);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 对指定类型高亮处理
|
||||
public static void highlightedMarker(String typeTag) {
|
||||
try {
|
||||
Map<String, List<IMogoMarker>> allMarker = MarkerServiceHandler.getMarkerManager().getAllMarkers();
|
||||
for (Map.Entry<String, List<IMogoMarker>> entry : allMarker.entrySet()) {
|
||||
String keyStr = entry.getKey();
|
||||
List<IMogoMarker> markerList = entry.getValue();
|
||||
|
||||
if (keyStr.equals(typeTag)) {
|
||||
for (IMogoMarker marker : markerList) {
|
||||
marker.setAlpha(1f);
|
||||
}
|
||||
} else {
|
||||
for (IMogoMarker marker : markerList) {
|
||||
marker.setAlpha(0.7f);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭 Marker 详情
|
||||
*
|
||||
* @param marker 要关闭的Marker
|
||||
*/
|
||||
public void closeMarkerSelect(IMogoMarker marker) {
|
||||
// 将上次选中 Marker 设置为未选中状态
|
||||
if (marker != null) {
|
||||
Logger.i(TAG, "closeMarkerSelect 将出Marker详情关闭:" + marker);
|
||||
|
||||
// 将上次选中 Marker 设置为未选中状态
|
||||
MarkerShowEntity lastMarkerShowEntity = (MarkerShowEntity) marker.getObject();
|
||||
lastMarkerShowEntity.setChecked(false);
|
||||
lastMarkerShowEntity.setHighlighted(false);
|
||||
|
||||
drawMapMarker(lastMarkerShowEntity);
|
||||
marker.remove();
|
||||
|
||||
lastMarker = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制Marker
|
||||
*/
|
||||
public void drawMapMarker(MarkerResponse response) {
|
||||
lastMarker = null;
|
||||
|
||||
JSONArray array = new JSONArray();
|
||||
|
||||
// 解析不同的Marker类型,然后对应的进行绘制
|
||||
if (response != null && response.getResult() != null) {
|
||||
|
||||
MarkerCardResult markerCardResult = response.getResult();
|
||||
|
||||
// 语音触发的在线车辆搜索,采用增量的形式绘制
|
||||
if (markerCardResult.getDataType() != null &&
|
||||
markerCardResult.getDataType().size() == 1 &&
|
||||
markerCardResult.getDataType().contains(ServiceConst.CARD_TYPE_USER_DATA)) {
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers(ServiceConst.CARD_TYPE_USER_DATA);
|
||||
MarkerServiceHandler.getMogoCardManager().switch2(ServiceConst.CARD_TYPE_USER_DATA);
|
||||
isFirstMarker = true;
|
||||
} else {
|
||||
// 清空所有地图上绘制的Marker
|
||||
MarkerServiceHandler.getMarkerManager().removeMarkers();
|
||||
}
|
||||
|
||||
List<MarkerCarChat> carChatList = markerCardResult.getCarChat();
|
||||
List<MarkerOnlineCar> onlineCarList = markerCardResult.getOnlineCar();
|
||||
List<MarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
|
||||
List<MarkerShareMusic> shareMusicList = markerCardResult.getShareMusic();
|
||||
List<MarkerNoveltyInfo> noveltyInfoList = markerCardResult.getNoveltyInfo();
|
||||
|
||||
if (carChatList != null) {
|
||||
for (MarkerCarChat markerCarChat : carChatList) {
|
||||
MarkerLocation markerLocation = markerCarChat.getLocation();
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj(markerCarChat);
|
||||
markerShowEntity.setMarkerLocation(markerLocation);
|
||||
markerShowEntity.setMarkerType(markerCarChat.getType());
|
||||
markerShowEntity.setTextContent(markerCarChat.getUserInfo().getUserName());
|
||||
markerShowEntity.setIconUrl(markerCarChat.getUserInfo().getUserHead());
|
||||
|
||||
drawMapMarker(markerShowEntity);
|
||||
}
|
||||
}
|
||||
|
||||
if (onlineCarList != null) {
|
||||
IMogoMarker nearlyMogoMarker = null;
|
||||
double nearlyDistance = Double.MAX_VALUE;
|
||||
for (MarkerOnlineCar markerOnlineCar : onlineCarList) {
|
||||
MarkerLocation markerLocation = markerOnlineCar.getLocation();
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj(markerOnlineCar);
|
||||
markerShowEntity.setMarkerLocation(markerLocation);
|
||||
markerShowEntity.setMarkerType(markerOnlineCar.getType());
|
||||
markerShowEntity.setTextContent(markerOnlineCar.getUserInfo().getUserName());
|
||||
markerShowEntity.setIconUrl(markerOnlineCar.getUserInfo().getUserHead());
|
||||
|
||||
IMogoMarker iMogoMarker = drawMapMarker(markerShowEntity);
|
||||
// 计算在线车辆距离当前车辆的距离,每次都与最后一次距离最近的进行比较,保留距离最近的车辆,进行卡片展示
|
||||
try {
|
||||
double calculateDistance = Utils.calculateLineDistance(
|
||||
new MogoLatLng(markerLocation.getLat(), markerLocation.getLat()),
|
||||
new MogoLatLng(
|
||||
MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation().getLatitude(),
|
||||
MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation().getLongitude()
|
||||
)
|
||||
);
|
||||
|
||||
// 进行比较,保留最近的一个数据
|
||||
if (calculateDistance < nearlyDistance) {
|
||||
nearlyMogoMarker = iMogoMarker;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
fillNumberTrackEventBody(array, 3, onlineCarList.size());
|
||||
|
||||
try {
|
||||
// 在ACC on 之后第一次获取到了在线车辆数据,选中最近的一个Marker
|
||||
if (isFirstMarker) {
|
||||
if (nearlyMogoMarker != null) {
|
||||
// getMogoCardManager().switch2(ServiceConst.CARD_TYPE_USER_DATA);
|
||||
// MarkerShowEntity markerShowEntity = (MarkerShowEntity) nearlyMogoMarker.getObject();
|
||||
// MarkerOnlineCar markerOnlineCar = (MarkerOnlineCar) markerShowEntity.getBindObj();
|
||||
// onLineCarCardViewProvider.updateView(markerOnlineCar);
|
||||
MogoMarkersHandler.getInstance().onMarkerClicked(nearlyMogoMarker);
|
||||
isFirstMarker = false;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (exploreWayList != null) {
|
||||
for (MarkerExploreWay markerExploreWay : exploreWayList) {
|
||||
if (!markerExploreWay.getCanLive()) {
|
||||
MarkerLocation markerLocation = markerExploreWay.getLocation();
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj(markerExploreWay);
|
||||
markerShowEntity.setMarkerLocation(markerLocation);
|
||||
markerShowEntity.setMarkerType(markerExploreWay.getType());
|
||||
markerShowEntity.setTextContent(markerExploreWay.getAddr());
|
||||
|
||||
drawMapMarker(markerShowEntity);
|
||||
}
|
||||
}
|
||||
fillNumberTrackEventBody(array, 1, exploreWayList.size());
|
||||
}
|
||||
|
||||
if (shareMusicList != null) {
|
||||
for (MarkerShareMusic markerShareMusic : shareMusicList) {
|
||||
MarkerLocation markerLocation = markerShareMusic.getLocation();
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj(markerShareMusic);
|
||||
markerShowEntity.setMarkerLocation(markerLocation);
|
||||
markerShowEntity.setMarkerType(markerShareMusic.getType());
|
||||
markerShowEntity.setTextContent(markerShareMusic.getMediaName());
|
||||
markerShowEntity.setIconUrl(markerShareMusic.getMediaImg());
|
||||
|
||||
drawMapMarker(markerShowEntity);
|
||||
}
|
||||
fillNumberTrackEventBody(array, 4, shareMusicList.size());
|
||||
}
|
||||
|
||||
if (noveltyInfoList != null) {
|
||||
int num_gas_station = 0;
|
||||
int num_traffic_check = 0;
|
||||
int num_road_closed = 0;
|
||||
int num_shop_discount = 0;
|
||||
int num_fours_shop = 0;
|
||||
|
||||
for (MarkerNoveltyInfo noveltyInfo : noveltyInfoList) {
|
||||
MarkerLocation markerLocation = noveltyInfo.getLocation();
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj(noveltyInfo);
|
||||
markerShowEntity.setMarkerLocation(markerLocation);
|
||||
markerShowEntity.setMarkerType(noveltyInfo.getType());
|
||||
markerShowEntity.setTextContent(noveltyInfo.getLocation().getAddress());
|
||||
|
||||
drawMapMarker(markerShowEntity);
|
||||
|
||||
switch (noveltyInfo.getPoiType()) {
|
||||
case MarkerPoiTypeEnum.GAS_STATION:
|
||||
num_gas_station++;
|
||||
break;
|
||||
case MarkerPoiTypeEnum.TRAFFIC_CHECK:
|
||||
num_traffic_check++;
|
||||
break;
|
||||
case MarkerPoiTypeEnum.ROAD_CLOSED:
|
||||
num_road_closed++;
|
||||
break;
|
||||
case MarkerPoiTypeEnum.SHOP_DISCOUNT:
|
||||
num_shop_discount++;
|
||||
break;
|
||||
case MarkerPoiTypeEnum.FOURS_SHOP:
|
||||
num_fours_shop++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fillNumberTrackEventBody(array, 2, num_gas_station);
|
||||
fillNumberTrackEventBody(array, 6, num_road_closed);
|
||||
fillNumberTrackEventBody(array, 5, num_traffic_check);
|
||||
fillNumberTrackEventBody(array, 7, num_shop_discount);
|
||||
fillNumberTrackEventBody(array, 8, num_fours_shop);
|
||||
}
|
||||
analyticData(array);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 统计埋点
|
||||
*/
|
||||
private static void fillNumberTrackEventBody(JSONArray arr, int type, int size) {
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
object.put("type", type);
|
||||
object.put("num", size);
|
||||
if (arr != null) {
|
||||
arr.put(object);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计地图内数据获取
|
||||
*
|
||||
* @param array 埋点数据
|
||||
*/
|
||||
private static void analyticData(JSONArray array) {
|
||||
try {
|
||||
if (array == null || array.length() == 0) {
|
||||
return;
|
||||
}
|
||||
final Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("data", array.toString());
|
||||
MarkerServiceHandler.getMogoAnalytics().track("Launcher_Data_Get", properties);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制Marker,这里绘制的会使用markerShowEntities队列进行维护
|
||||
*
|
||||
* @param markerShowEntity marker 绘制数据实体
|
||||
* @return 绘制的Marker
|
||||
*/
|
||||
public IMogoMarker drawMapMarker(MarkerShowEntity markerShowEntity) {
|
||||
//Logger.i(TAG, "绘制Marker====drawMapMarker:" + markerShowEntity);
|
||||
try {
|
||||
if (markerShowEntity.getMarkerLocation() != null) {
|
||||
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner(markerShowEntity.getMarkerType())
|
||||
.alpha(0.7f)
|
||||
.object(markerShowEntity)
|
||||
.latitude(markerShowEntity.getMarkerLocation().getLat())
|
||||
.longitude(markerShowEntity.getMarkerLocation().getLon());
|
||||
View markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
|
||||
options.icon(markerView);
|
||||
|
||||
IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
|
||||
marker.setOnMarkerClickListener(this);
|
||||
return marker;
|
||||
} else {
|
||||
Logger.e(TAG, "Location 必须进行初始化!!!!!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<MarkerResponse> target() {
|
||||
return MarkerResponse.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(final MarkerResponse response) {
|
||||
Logger.e(TAG, "MarkerResponse======" + response);
|
||||
if (!MarkerServiceHandler.getMogoStatusManager().isSearchUIShow() &&
|
||||
!MarkerServiceHandler.getMogoStatusManager().isV2XShow()) {
|
||||
isFirstMarker = true;
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
drawMapMarker(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@
|
||||
android:layout_width="@dimen/dp_34"
|
||||
android:layout_height="@dimen/dp_64"
|
||||
android:src="@drawable/icon_map_marker_car_gray"
|
||||
android:translationY="-10dp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/ivBg"
|
||||
app:layout_constraintStart_toStartOf="@+id/ivBg"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ivBg" />
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
android:layout_width="@dimen/dp_34"
|
||||
android:layout_height="@dimen/dp_64"
|
||||
android:src="@drawable/icon_map_marker_car_gray"
|
||||
android:translationY="-10dp"
|
||||
app:layout_constraintEnd_toEndOf="@+id/ivReverseTriangle"
|
||||
app:layout_constraintStart_toStartOf="@+id/ivReverseTriangle"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ivReverseTriangle" />
|
||||
|
||||
@@ -134,7 +134,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
|
||||
//声音控制文字
|
||||
private String voiceGetInfoMationTts;
|
||||
private String[] searchingVoiceStrings;
|
||||
// private String[] searchingVoiceStrings;
|
||||
private String[] searchfaileVoiceStrings;
|
||||
|
||||
//media
|
||||
@@ -291,6 +291,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
poiSearch.searchPOIAsyn();
|
||||
}
|
||||
} else {
|
||||
Logger.e(TAG, "onGeocodeSearched -----geocodeResult == null");
|
||||
speakFailVoice(searchfaileVoiceStrings[2]);
|
||||
}
|
||||
}
|
||||
@@ -472,6 +473,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
public void onCmdSelected(String cmd) {
|
||||
Log.d(TAG, "mogoVoiceListener cmd = " + cmd);
|
||||
if (cmd.equals(TanluConstants.PLAY_VIDEO)) { //播放路况 --ok
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice(getString(R.string.tanlu_prepare_play), null);
|
||||
gsyVideoOptionBuilder.setUrl(mVideoUrl).setCacheWithPlay(false).setPlayTag(TAG)
|
||||
.build(simpleCoverVideoPlayer);
|
||||
simpleCoverVideoPlayer.getStartButton().performClick();
|
||||
@@ -995,6 +997,18 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
return;
|
||||
}
|
||||
|
||||
if (markerExploreWayList != null && markerExploreWayList.size() > 0) {
|
||||
markerExploreWayList.clear(); //刷新之前先删除之前的,然后再添加成请求的
|
||||
currentPosition = 0;
|
||||
}
|
||||
|
||||
//转换数据结构
|
||||
convertData(informationList);
|
||||
//切换到探路卡片
|
||||
if (!isCurrentPage) {
|
||||
iMogoCardManager.switch2(TanluConstants.MODEL_NAME);
|
||||
}
|
||||
|
||||
//清除探路之前的数据
|
||||
mMarkerManager.removeMarkers(TanluConstants.MODEL_NAME);
|
||||
|
||||
@@ -1023,6 +1037,9 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
}
|
||||
Logger.d(TAG, "getNavigationData optionList.size() = " + optionList.size());
|
||||
mMarkerManager.addMarkers(TanluConstants.MODEL_NAME, optionList, true);
|
||||
|
||||
//直接使用当前数据list,作为切换的数据源,切换左侧列表到最新的数据
|
||||
handleMarkerExploreWay(markerExploreWayList.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1263,27 +1280,30 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
|
||||
private void speakSuccessVoice(List<Information> informations, String
|
||||
trafficStatus) {
|
||||
Log.d(TAG, "informations.size() = " + informations.size());
|
||||
switch (informations.size()) {
|
||||
case 0:
|
||||
Logger.d(TAG, "speakSuccessVoice ----> " + random.nextInt(3));
|
||||
Logger.d(TAG, "speakSuccessVoice --0----> " + random.nextInt(3));
|
||||
speakFailVoice(searchfaileVoiceStrings[random.nextInt(3)]);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
Logger.d(TAG, "speakSuccessVoice ---1---> ");
|
||||
trackVoiceSearch(1);
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice((
|
||||
String.format(voiceGetInfoMationTts, "1") + trafficStatus), null);
|
||||
|
||||
case 2:
|
||||
trackVoiceSearch(1);
|
||||
Logger.d(TAG, "speakSuccessVoice ---2---> ");
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice((
|
||||
String.format(
|
||||
voiceGetInfoMationTts,
|
||||
"2"
|
||||
) + trafficStatus), null);
|
||||
|
||||
|
||||
case 3:
|
||||
Logger.d(TAG, "speakSuccessVoice ---3---> ");
|
||||
trackVoiceSearch(1);
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice((
|
||||
String.format(
|
||||
@@ -1292,6 +1312,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
) + trafficStatus), null);
|
||||
|
||||
default:
|
||||
Logger.d(TAG, "speakSuccessVoice ---default-> ");
|
||||
trackVoiceSearch(1);
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice((
|
||||
String.format(
|
||||
@@ -1304,8 +1325,8 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
private void initStrings() {
|
||||
voiceGetInfoMationTts =
|
||||
getContext().getResources().getString(R.string.voice_get_informations_tts);
|
||||
searchingVoiceStrings =
|
||||
getContext().getResources().getStringArray(R.array.searching_voice_string_array);
|
||||
// searchingVoiceStrings =
|
||||
// getContext().getResources().getStringArray(R.array.searching_voice_string_array);
|
||||
searchfaileVoiceStrings =
|
||||
getContext().getResources().getStringArray(R.array.search_fail_voice_array);
|
||||
}
|
||||
@@ -1315,7 +1336,7 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
}
|
||||
|
||||
private void speakSearchingVoice() {
|
||||
AIAssist.getInstance(getContext()).speakTTSVoice(searchingVoiceStrings[random.nextInt(3)], null);
|
||||
// AIAssist.getInstance(getContext()).speakTTSVoice(searchingVoiceStrings[random.nextInt(3)], null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
<string name="tanlu_next">下一条</string>
|
||||
<string name="tanlu_share_success">分享成功</string>
|
||||
<string name="tanlu_share_failed">分享失败</string>
|
||||
<string name="tanlu_prepare_play">将为您播放</string>
|
||||
|
||||
|
||||
<array name="searching_voice_string_array">
|
||||
<item >正在为您搜索路况</item>
|
||||
|
||||
Reference in New Issue
Block a user