Merge branch 'feature/v1.0.0' into feature/v1.0.0-anim

This commit is contained in:
unknown
2020-02-24 11:45:21 +08:00
13 changed files with 367 additions and 296 deletions

View File

@@ -136,6 +136,7 @@ public class EntranceFragment extends MvpFragment< EntranceView, EntrancePresent
if ( location != null ) {
mMogoStatusManager.setUserInteractionStatus( TAG, true, false );
mMApUIController.changeZoom( 16.0f );
mMogoStatusManager.setUserInteractionStatus( TAG, true, false );
mMApUIController.recoverLockMode();
// mMApUIController.moveToCenter( new MogoLatLng( location.getLatitude(), location.getLongitude() ) );
}

View File

@@ -595,10 +595,6 @@ public class MogoModulesManager implements MogoModulesHandler,
}
}
}
if ( iterator.hasNext() ) {
iterator.next().accOn();
}
}
@Override

View File

@@ -56,7 +56,7 @@ public class MarkerServiceHandler {
mMarkerManager = mMapService.getMarkerManager(context);
mNavi = mMapService.getNavi(context);
mMapUIController = mMapService.getMapUIController();
mLocationClient = mMapService.getLocationClient(context);
mLocationClient = mMapService.getSingletonLocationClient(context);
mMapMarkerManager = MapMarkerManager.getInstance(context);
mMapMarkerManager.init(context);

View File

@@ -193,12 +193,14 @@ public class MogoServiceProvider implements IMogoModuleProvider,
@Override
public void onSuccess() {
mLoopRequest = false;
Logger.d( TAG, "request Success." );
invokeAutoRefreshStrategy();
}
@Override
public void onFail() {
if ( mLoopRequest ) {
Logger.d( TAG, "onFail and loop" );
mHandler.sendEmptyMessageDelayed( ServiceConst.MSG_LOOP_REQUEST, ServiceConst.LOOP_INTERVAL );
} else {
invokeAutoRefreshStrategy();
@@ -427,7 +429,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
@Override
public void onMapChanged( MogoLatLng latLng, float zoom, float tilt, float bearing ) {
Logger.d(TAG, "onMapChanged==latLng:" + latLng+" mStatusManager.isUserInteracted()==="+mStatusManager.isUserInteracted());
if ( mIsCameraInited ) {
mLastZoomLevel = zoom;
mLastCustomRefreshCenterLocation = latLng;
@@ -444,6 +446,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
if ( mStatusManager.isUserInteracted() ) {
mLastCustomRefreshCenterLocation = latLng;
mLastZoomLevel = zoom;
refreshCameraPosition();
return;
}
@@ -487,6 +490,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
if ( factor == 0.0f ) {
return false;
}
Logger.d( TAG, "invokeRefreshWhenTranslationByUsermLastCustomRefreshCenterLocation = %s, latLng = %s", mLastCustomRefreshCenterLocation, latLng );
float distance = Utils.calculateLineDistance( latLng, mLastCustomRefreshCenterLocation );
return distance > factor;
} catch ( Exception e ) {
@@ -500,6 +504,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
if ( location == null ) {
return;
}
// 自动刷新触发
final MogoLatLng point = new MogoLatLng( location.getLatitude(), location.getLongitude() );
if ( mLastAutoRefreshLocation == null ) {
@@ -580,7 +585,7 @@ public class MogoServiceProvider implements IMogoModuleProvider,
try {
if ( isTrue ) {
// V2X_UI时不在自动刷新打点策略
// stopAutoRefreshStrategy();
stopAutoRefreshStrategy();
// 清除所有的打点信息记录
MarkerServiceHandler.getMapMarkerManager().alreadySmallMarker.clear();
} else {

View File

@@ -1,25 +1,21 @@
package com.mogo.module.service.marker;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.BounceInterpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.TextView;
import com.amap.api.maps.model.animation.Animation;
import com.amap.api.maps.model.animation.ScaleAnimation;
import com.mogo.map.MogoLatLng;
import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
import com.mogo.map.location.MogoLocation;
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;
@@ -33,6 +29,7 @@ import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.service.ServiceConst;
import com.mogo.module.service.Utils;
import com.mogo.module.service.datamanager.MogoDataHandler;
import com.mogo.module.service.utils.ViewUtils;
import com.mogo.service.cardmanager.IMogoCardChangedListener;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.utils.logger.Logger;
@@ -56,8 +53,7 @@ import java.util.Map;
public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessageListener<MarkerResponse> {
private static final String TAG = "MapMarkerManager";
// 第一次请求到地图的Marker数据
private boolean isFirstMarker = true;
private boolean isOnLineCard = false;
private boolean isFirstMarker = false;
private static Context mContext;
private static IMogoMarker lastMarker;
private static MapMarkerManager mMarkerManager;
@@ -99,17 +95,15 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
public void onSwitched(int position, String moduleName) {
Logger.e(TAG, "======moduleName" + moduleName);
highlightedMarker(moduleName, false);
if (moduleName.equals(ServiceConst.CARD_TYPE_USER_DATA)) {
isOnLineCard = true;
} else {
isOnLineCard = false;
}
mLastHighLightModule = moduleName;
}
});
}
// ACC ON 的时候重置为true
public void setFirstMarker(boolean firstMarker) {
isFirstMarker = firstMarker;
}
/**
* 地图上的Marker点击回调
@@ -119,7 +113,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker" + marker);
try {
// 移动地图到指定位置
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus(ServiceConst.TYPE, true, true);
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus(ServiceConst.TYPE, true, false);
MarkerServiceHandler.getMapUIController().moveToCenter(marker.getPosition());
if (lastMarker != null) {
@@ -129,26 +123,11 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
return false;
}
// 将上次选中 Marker 设置为未选中状态
MarkerShowEntity lastMarkerShowEntity = (MarkerShowEntity) lastMarker.getObject();
Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker lastMarkerShowEntity" + lastMarkerShowEntity);
if (lastMarkerShowEntity != null) {
lastMarkerShowEntity.setChecked(false);
lastMarkerShowEntity.setHighlighted(false);
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, lastMarkerShowEntity, lastMarker.getMogoMarkerOptions());
lastMarker.setIcon(fromView(markerView.getView()));
}
closeMarker(lastMarker);
}
// 将当前的Marker设置为选中
MarkerShowEntity markerShowEntity = (MarkerShowEntity) marker.getObject();
Logger.i(TAG, "onMarkerClicked 点击了大而全中的Marker markerShowEntity" + markerShowEntity);
if (markerShowEntity != null) {
markerShowEntity.setChecked(true);
markerShowEntity.setHighlighted(true);
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, marker.getMogoMarkerOptions());
marker.setIcon(fromView(markerView.getView()));
}
openMarker(marker);
lastMarker = marker;
// 数据统计代码
@@ -200,31 +179,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
}
private Bitmap fromView(View view) {
view.setDrawingCacheEnabled(true);
processChildView(view);
view.destroyDrawingCache();
view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
Bitmap bitmap = null;
return (bitmap = view.getDrawingCache()) != null ? bitmap.copy(Bitmap.Config.ARGB_8888, false) : null;
}
private void processChildView(View view) {
if (!(view instanceof ViewGroup)) {
if (view instanceof TextView) {
((TextView) view).setHorizontallyScrolling(false);
}
} else {
for (int var1 = 0; var1 < ((ViewGroup) view).getChildCount(); ++var1) {
processChildView(((ViewGroup) view).getChildAt(var1));
}
}
}
// 对指定类型高亮处理
public synchronized static void highlightedMarker(final String typeTag) {
highlightedMarker(typeTag, false);
@@ -334,22 +288,38 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
// 将上次选中 Marker 设置为未选中状态
if (marker != null) {
Logger.i(TAG, "closeMarkerSelect 将出Marker详情关闭" + marker);
// 将上次选中 Marker 设置为未选中状态
MarkerShowEntity lastMarkerShowEntity = (MarkerShowEntity) marker.getObject();
lastMarkerShowEntity.setChecked(false);
lastMarkerShowEntity.setHighlighted(false);
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, lastMarkerShowEntity, marker.getMogoMarkerOptions());
marker.setIcon(fromView(markerView.getView()));
closeMarker(marker);
lastMarker = null;
}
}
/**
* 绘制Marker
*/
// 展开气泡
private void openMarker(IMogoMarker mogoMarker) {
if (mogoMarker != null) {
Object object = mogoMarker.getObject();
if (object != null) {
MarkerShowEntity markerShowEntity = (MarkerShowEntity) object;
markerShowEntity.setChecked(true);
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions());
mogoMarker.setIcon(ViewUtils.fromView(markerView.getView()));
}
}
}
// 折叠气泡
private void closeMarker(IMogoMarker mogoMarker) {
if (mogoMarker != null) {
Object object = mogoMarker.getObject();
if (object != null) {
MarkerShowEntity markerShowEntity = (MarkerShowEntity) object;
markerShowEntity.setChecked(false);
IMarkerView markerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions());
mogoMarker.setIcon(ViewUtils.fromView(markerView.getView()));
}
}
}
// 绘制Marker
public synchronized void drawMapMarker(MarkerResponse response) {
lastMarker = null;
@@ -369,25 +339,16 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
isFirstMarker = true;
} else {
// 清空所有地图上绘制的Marker
if (!MarkerServiceHandler.getMogoStatusManager().isV2XShow()) {
MarkerServiceHandler.getMarkerManager().removeMarkers();
}
MarkerServiceHandler.getMarkerManager().removeMarkers();
}
List<MarkerCarChat> carChatList = markerCardResult.getCarChat();
List<MarkerOnlineCar> onlineCarList = markerCardResult.getOnlineCar();
List<MarkerExploreWay> exploreWayList = null;
List<MarkerShareMusic> shareMusicList = null;
List<MarkerNoveltyInfo> noveltyInfoList = null;
List<MarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
List<MarkerShareMusic> shareMusicList = markerCardResult.getShareMusic();
List<MarkerNoveltyInfo> noveltyInfoList = markerCardResult.getNoveltyInfo();
// V2X 场景下只保留在线车辆数据
if (!MarkerServiceHandler.getMogoStatusManager().isV2XShow()) {
exploreWayList = markerCardResult.getExploreWay();
shareMusicList = markerCardResult.getShareMusic();
noveltyInfoList = markerCardResult.getNoveltyInfo();
}
if (onlineCarList != null) {
double nearlyDistance = Double.MAX_VALUE;
double nearlyDistance = Float.MAX_VALUE;
for (MarkerOnlineCar markerOnlineCar : onlineCarList) {
MarkerLocation markerLocation = markerOnlineCar.getLocation();
@@ -401,16 +362,25 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
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()
)
// 当前车辆的位置
MogoLocation currentLocation = MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation();
// 计算车辆距离指定气泡的距离
float calculateDistance = Utils.calculateLineDistance(
new MogoLatLng(markerLocation.getLat(), markerLocation.getLon()),
new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude())
);
// Logger.d("点之间距离",
// "当前车辆经纬度:" +
// "\n\tlatitude=" + currentLocation.getLatitude() +
// "\n\tlongitude=" + currentLocation.getLongitude() +
// "\n气泡经纬度" + markerLocation +
// "\n相距" + calculateDistance + "米");
// 进行比较,保留最近的一个数据
if (calculateDistance < nearlyDistance) {
nearlyDistance = calculateDistance;
nearlyMogoMarker = iMogoMarker;
}
@@ -418,6 +388,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
e.printStackTrace();
}
}
Logger.d("点之间距离", "距离当前车辆位置最近的距离为:" + nearlyDistance);
fillNumberTrackEventBody(array, 3, onlineCarList.size());
}
@@ -505,9 +476,8 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag
highlightedMarker(mLastHighLightModule, true);
try {
Thread.sleep(500);
// 在ACC on 之后第一次获取到了在线车辆数据选中最近的一个Marker
if (isFirstMarker && isOnLineCard) {
if (isFirstMarker) {
if (nearlyMogoMarker != null) {
Logger.w(TAG, "ACC ON,或者语音搜索触发默认选中最近的在线车辆nearlyMogoMarker" + nearlyMogoMarker);
onMarkerClicked(nearlyMogoMarker);

View File

@@ -77,6 +77,14 @@ public class RefreshModel {
}
}
@Override
public void onError( Throwable e ) {
super.onError( e );
if (callback != null) {
callback.onFail();
}
}
@Override
public void onError(String message, int code) {
super.onError(message, code);

View File

@@ -0,0 +1,37 @@
package com.mogo.module.service.utils;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020-02-2123:51
* desc :
* version: 1.0
*/
public class ViewUtils {
public static Bitmap fromView(View view) {
view.setDrawingCacheEnabled(true);
processChildView(view);
view.destroyDrawingCache();
view.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
Bitmap bitmap = null;
return (bitmap = view.getDrawingCache()) != null ? bitmap.copy(Bitmap.Config.ARGB_8888, false) : null;
}
public static void processChildView(View view) {
if (!(view instanceof ViewGroup)) {
if (view instanceof TextView) {
((TextView) view).setHorizontallyScrolling(false);
}
} else {
for (int var1 = 0; var1 < ((ViewGroup) view).getChildCount(); ++var1) {
processChildView(((ViewGroup) view).getChildAt(var1));
}
}
}
}

View File

@@ -616,6 +616,7 @@ import static com.mogo.module.tanlu.video.VideoInitKt.initVideo;
private void moveToMarcker(double lat, double lon) {
MogoLatLng latLng = new MogoLatLng(lat, lon);
mMogoStatusManager.setUserInteractionStatus( TAG, true, false );
mMApUIController.moveToCenter(latLng);
}
@@ -1303,6 +1304,7 @@ import static com.mogo.module.tanlu.video.VideoInitKt.initVideo;
optionList.add(options);
}
Logger.d(TAG, "getVoiceControlRoadData optionList.size() = " + optionList.size());
mMogoStatusManager.setUserInteractionStatus(TanluConstants.MODEL_NAME, true, false);
mMarkerManager.addMarkers(TanluConstants.MODEL_NAME, optionList, true);
//直接使用当前数据list作为切换的数据源切换左侧列表到最新的数据