Merge remote-tracking branch 'origin/dev_merge_shunyi_vr_map' into dev_merge_shunyi_vr_map

This commit is contained in:
wangcongtao
2020-12-18 18:34:19 +08:00
17 changed files with 266 additions and 110 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -676,6 +676,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
TopViewNoLinkageAnimHelper.getInstance().clear();
NoMapTopViewShaderHelper.getInstance().release();
EntranceViewHolder.getInstance().release();
mCameraLiveNoticeHelper.release();
}
@Override

View File

@@ -91,7 +91,6 @@ public class CameraLiveGSYVideoView extends LiveRoundLayout implements IMogoSkin
});
}
/**
* 开始直播
*
@@ -113,7 +112,7 @@ public class CameraLiveGSYVideoView extends LiveRoundLayout implements IMogoSkin
private void playLiveVideo(String liveUrl) {
try {
if (mLivePlayer != null) {
mLivePlayer.startPlay(liveUrl, TXLivePlayer.PLAY_TYPE_LIVE_FLV);
mLivePlayer.startPlay(liveUrl, TXLivePlayer.PLAY_TYPE_LIVE_RTMP);
mLivePlayer.setPlayListener(new ITXLivePlayListener() {
@Override
public void onPlayEvent(int event, Bundle bundle) {
@@ -129,16 +128,9 @@ public class CameraLiveGSYVideoView extends LiveRoundLayout implements IMogoSkin
mLoading.setVisibility(GONE);
mClLoadError.setVisibility(GONE);
} else if (event < 0) {
// AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("直播获取失败,可以对我说重试", null);
stopLive(mLiveUrl);
mLoading.setVisibility(GONE);
mClLoadError.setVisibility(VISIBLE);
// // 注册语音交互
// V2XVoiceManager.INSTANCE
// .registerWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_CAR_LIVE,
// v2XVoiceCallbackRefreshListener)
// .registerUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_LIVE_UN_WAKEUP,
// v2XVoiceCallbackRefreshListener);
}
}
@@ -164,21 +156,6 @@ public class CameraLiveGSYVideoView extends LiveRoundLayout implements IMogoSkin
// true 代表清除最后一帧画面
mLivePlayer.stopPlay(true);
mTxcVideoView.onDestroy();
// 停止推流
// V2XServiceManager
// .getV2XRefreshModel()
// .livePush(new V2XRefreshCallback<V2XLivePushVoRes>() {
// @Override
// public void onSuccess(V2XLivePushVoRes result) {
// Logger.d(TAG, "播放器:" + result);
// }
//
// @Override
// public void onFail(String msg) {
// Logger.e(TAG, "播放器:" + msg);
// }
// }, carLiveInfo.getVideoSn(), 1);
} catch (Exception e) {
e.printStackTrace();
}
@@ -196,10 +173,6 @@ public class CameraLiveGSYVideoView extends LiveRoundLayout implements IMogoSkin
protected void onDetachedFromWindow() {
stopLive(mLiveUrl);
mLoading.setVisibility(VISIBLE);
// 反注册语音交互
// V2XVoiceManager.INSTANCE
// .unRegisterWakeCmd(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_CAR_LIVE)
// .unRegisterUnWakeVoice(V2XVoiceConstants.COMMAND_ZHIDAO_V2X_REFRESH_LIVE_UN_WAKEUP);
super.onDetachedFromWindow();
}

View File

@@ -22,6 +22,8 @@ import com.mogo.module.extensions.live.ExtensionServiceManager;
import com.mogo.module.extensions.live.PushDataType;
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
import com.mogo.service.connection.WebSocketMsgType;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
@@ -34,17 +36,15 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
private Context mContext;
private static IMogoMarker mMogoMarker;
private CloudRoadData mCloudRoadData;
private boolean isFirst;
private boolean isVrMode;
public void init(Context context) {
Logger.d(TAG, "init ======= ");
mContext = context;
}
public void enterVrMode() {
Logger.d(TAG, "enterVrMode===");
MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(mContext).registerOnWebSocketMessageListener(this);
ExtensionServiceManager
.getMogoRegisterCenter().registerMogoMarkerClickListener(PushDataType.TYPE_PUSH_CAMERA_DATA, new IMogoMarkerClickListener() {
@Override
@@ -59,39 +59,32 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
return false;
}
});
}
// if (!isFirst) {
// isFirst = true;
// UiThreadHandler.postDelayed(() -> {
// mCloudRoadData = new CloudRoadData();
//// mCloudRoadData.setRtmpUrl("rtmp://58.200.131.2:1935/livetv/hunantv");
// mCloudRoadData.setRtmpUrl("http://video.zhidaozhixing.com/live/rec_12_22.flv");
//
// mCloudRoadData.setLat(39.969089);
// mCloudRoadData.setLon(116.418009);
//
//// CameraLiveManager.getInstance().init(mCloudRoadData);
// addCameraMarker(mCloudRoadData);
// }, 2_000);
// }
public void release() {
MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(mContext).unregisterOnWebSocketMessageListener(this);
}
public void enterVrMode() {
Logger.d(TAG, "enterVrMode===");
isVrMode = true;
}
public void exitVrMode() {
Logger.d(TAG, "退出vr模式===");
// removeCameraMarker();
// isFirst = false;
MogoApisHandler.getInstance().getApis().getWebSocketManagerApi(mContext).unregisterOnWebSocketMessageListener(this);
isVrMode = false;
}
/**
* PushRoadConditionDrawer
* vr模式
*
* @param roadData
*/
private void addCameraMarker(CloudRoadData roadData) {
Logger.d(TAG, "addCameraMarker --lat = " + roadData.getLat() + "--lon =" + roadData.getLon());
private void addVrCameraMarker(CloudRoadData roadData) {
Logger.d(TAG, "addVrCameraMarker --lat = " + roadData.getLat() + "--lon =" + roadData.getLon());
removeCameraMarker();
MogoMarkerOptions options = new MogoMarkerOptions()
.object(roadData)
.latitude(roadData.getLat())
@@ -109,6 +102,29 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
}
}
/**
* 普通模式
*
* @param roadData
*/
private void addNormalCameraMarker(CloudRoadData roadData) {
Logger.d(TAG, "addNormalCameraMarker --lat = " + roadData.getLat() + " --lon =" + roadData.getLon());
removeCameraMarker();
MogoMarkerOptions options = new MogoMarkerOptions()
.object(roadData)
.latitude(roadData.getLat())
.longitude(roadData.getLon());
options.anchor(0.5f, 0.5f);
Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.module_camera_normal_traffic, null);
options.icon(bitmap);
mMogoMarker = ExtensionServiceManager.getMapService().getMarkerManager(mContext)
.addMarker(PushDataType.TYPE_PUSH_CAMERA_DATA, options);
if (mMogoMarker != null) {
mMogoMarker.setInfoWindowAdapter(new CameraWindow3DAdapter(AbsMogoApplication.getApp(), mMogoMarker.getMogoMarkerOptions()));
}
}
private void removeCameraMarker() {
if (mMogoMarker != null) {
mMogoMarker.remove();
@@ -125,37 +141,55 @@ public class CameraLiveNoticeHelper implements IMogoOnWebSocketMessageListener<M
return MogoSnapshotSetData.class;
}
private double mCurrentlat;
private double mCurrentlon;
private volatile boolean isLoadVr;
private volatile boolean isLoadNormal;
private String mCurretnUuid;
/**
* @param obj
*/
@Override
public void onMsgReceived(MogoSnapshotSetData obj) {
// Logger.d(TAG, "onMsgReceived cameralive : " + obj);
if (obj != null) { //如果多个点,如何处理,点击的时候
Logger.d(TAG, "onMsgReceived cameralive : " + obj);
if (obj != null) {
mCloudRoadData = obj.getCamera();
if (mCloudRoadData != null) {
Log.d(TAG, "onMsgReceived getRtmpUrl = " + mCloudRoadData.getRtmpUrl());
Log.d(TAG, "mCurrentlat = " + mCurrentlat + "--mCurrentlon = " + mCurrentlon + "---mCloudRoadData.getLat() = " + mCloudRoadData.getLat() + "--mCloudRoadData.getLon() = " + mCloudRoadData.getLon());
if (mCurrentlat == mCloudRoadData.getLat() && mCurrentlon == mCloudRoadData.getLon()) {
//TODO
Log.e(TAG, "onMsgReceived getRtmpUrl = " + mCloudRoadData.getRtmpUrl() + "--- isVrMode = " + isVrMode + ">>>>mCurretnUuid = " + mCurretnUuid + ">>>mCloudRoadData.getUuid() = " + mCloudRoadData.getUuid());
if (mCurretnUuid != null && mCurretnUuid.equals(mCloudRoadData.getUuid())) {
Log.d(TAG, "isLoadVr = " + isLoadVr + "....isLoadNormal = " + isLoadNormal);
if (isVrMode) {
if (!isLoadVr) {
addVrCameraMarker(mCloudRoadData);
isLoadVr = true;
isLoadNormal = false;
}
} else {
if (!isLoadNormal) {
addNormalCameraMarker(mCloudRoadData);
isLoadNormal = true;
isLoadVr = false;
}
}
} else {
removeCameraMarker();
addCameraMarker(mCloudRoadData);
mCurrentlat = mCloudRoadData.getLat();
mCurrentlon = mCloudRoadData.getLon();
if (isVrMode) {
addVrCameraMarker(mCloudRoadData);
} else {
addNormalCameraMarker(mCloudRoadData);
}
mCurretnUuid = mCloudRoadData.getUuid();
}
} else {
//删除marker
Logger.e(TAG, "onMsgReceived mCloudRoadData == null ");
UiThreadHandler.postDelayed(() -> {
removeCameraMarker();
}, 1_000);
removeCameraMarker();
// Log.e(TAG, "onMsgReceived mCloudRoadData == null ");
// UiThreadHandler.postDelayed(() -> {
//
// }, 1_000);
}
} else {
Log.e(TAG, "onMsgReceived obj == null ");
Logger.e(TAG, "onMsgReceived obj == null ");
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -40,6 +40,7 @@ dependencies {
implementation rootProject.ext.dependencies.arouter
implementation rootProject.ext.dependencies.amapnavi3dmap
implementation rootProject.ext.dependencies.amaplocation
annotationProcessor rootProject.ext.dependencies.aroutercompiler
if (Boolean.valueOf(RELEASE)) {

View File

@@ -6,6 +6,6 @@
<service
android:name=".SmallMapService"
android:exported="false"
/>
android:process=":smallMap"/>
</application>
</manifest>

View File

@@ -1,13 +1,17 @@
package com.mogo.module.small.map;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdate;
import com.amap.api.maps.CameraUpdateFactory;
@@ -15,13 +19,17 @@ import com.amap.api.maps.TextureMapView;
import com.amap.api.maps.UiSettings;
import com.amap.api.maps.model.BitmapDescriptor;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.CameraPosition;
import com.amap.api.maps.model.CustomMapStyleOptions;
import com.amap.api.maps.model.MyLocationStyle;
import com.amap.api.navi.AMapNaviView;
import com.amap.api.navi.AMapNaviViewOptions;
import com.mogo.module.common.view.RoundLayout;
import com.mogo.module.small.map.animation.DirectionRotateAnimation;
import com.mogo.module.small.map.utils.MapAssetStyleUtils;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
/**
* 小地图的方向View
@@ -32,11 +40,13 @@ import java.net.URL;
public class SmallMapDirectionView extends RoundLayout {
private ImageView mIvMapBorder;
private TextureMapView mTextureMapView;
private AMapNaviView mAMapNaviView;
private AMap mAMap;
private UiSettings mUiSettings;
private CameraUpdate mCameraUpdate;
private MyLocationStyle myLocationStyle;
private AMapLocationClient mLocationClient;
private AMapLocationClientOption mLocationClientOption;
private DirectionRotateAnimation mRotateAnimation;
private int lastAngle = 0;
@@ -59,42 +69,127 @@ public class SmallMapDirectionView extends RoundLayout {
LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this);
mIvMapBorder = findViewById(R.id.ivMapBorder);
mTextureMapView = findViewById(R.id.textureMapView);
mAMapNaviView = findViewById(R.id.aMapNaviView);
mAMapNaviView.onCreate(null);
// 车头朝上
mAMapNaviView.setNaviMode(AMapNaviView.CAR_UP_MODE);
mAMap = mAMapNaviView.getMap();
mTextureMapView.onCreate(null);
mAMap = mTextureMapView.getMap();
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);//夜景地图aMap是地图控制器对象
URL small_map_style = getClass().getResource("/assets/small_map_style.data");
URL small_map_style_extra = getClass().getResource("/assets/small_map_style_extra.data");
mAMap.setCustomMapStyle(new CustomMapStyleOptions()
.setEnable(true)
.setStyleDataPath(small_map_style.getPath())
.setStyleExtraPath(small_map_style_extra.getPath())
);
myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);//连续定位、且将视角移动到地图中心点定位点依照设备方向旋转并且会跟随设备移动。1秒1次定位如果不设置myLocationType默认也会执行此种模式。
myLocationStyle.interval(2000); //设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。
BitmapDescriptor location = BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo);
myLocationStyle.myLocationIcon(location);
mAMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style
mAMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点false表示隐藏定位蓝点并不进行定位默认是false
// 导航地图
AMapNaviViewOptions options = mAMapNaviView.getViewOptions();
//设置导航界面UI是否显示
if (options != null) {
// 设置是否开启自动黑夜模式切换默认为false不自动切换
options.setAutoNaviViewNightMode(false);
// 设置6秒后是否自动锁车
options.setAutoLockCar(true);
// 设置路线上的摄像头气泡是否显示
options.setCameraBubbleShow(false);
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
// 设置自车的图片对象
options.setCarBitmap(BitmapFactory.decodeResource(getContext().getResources(),
R.drawable.module_small_map_view_my_location_logo));
// 设置罗盘位图对象
options.setFourCornersBitmap(BitmapFactory.decodeResource(getContext().getResources(),
R.drawable.icon_module_small_map_four_corners));
// 设置指南针图标否在导航界面显示默认显示。true显示false隐藏
options.setCompassEnabled(false);
// 黑夜模式
options.setNaviNight(true);
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
options.setTrafficBarEnabled(false);
// 设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
options.setTrafficLayerEnabled(false);
// 设置导航界面是否显示路线全览按钮。
options.setRouteListButtonShow(false);
// 设置屏幕是否常亮,默认开启
options.setScreenAlwaysBright(false);
// 设置交通播报是否打开(只适用于驾车导航,需要联网)。
options.setTrafficInfoUpdateEnabled(false);
// 设置摄像头播报是否打开(只适用于驾车导航)。
options.setCameraInfoUpdateEnabled(false);
// 设置菜单按钮是否在导航界面显示。
options.setSettingMenuEnabled(false);
// 设置是否绘制显示交通路况的线路(彩虹线),拥堵-红色,畅通-绿色,缓慢-黄色,未知-蓝色。默认不绘制彩虹线。
options.setTrafficLine(false);
// 设置是否绘制牵引线(当前位置到目的地的指引线)。默认不绘制牵引线。
options.setLeaderLineEnabled(-1);
// 设置导航界面UI是否显示。
options.setLayoutVisible(false);
// 设置是否自动画路
options.setAutoDrawRoute(false);
// 设置是否显示路口放大图(实景图)
options.setRealCrossDisplayShow(false);
// 设置是否显示路口放大图(路口模型图)
options.setModeCrossDisplayShow(false);
// 设置是否显示道路信息view
options.setLaneInfoShow(false);
// 设置是否自动改变缩放等级
options.setAutoChangeZoom(false);
// 设置是否自动全览模式,即在算路成功后自动进入全览模式
options.setAutoDisplayOverview(false);
// 设置路线转向箭头隐藏和显示
options.setNaviArrowVisible(false);
// 通过路线是否自动置灰,仅支持驾车导航
options.setAfterRouteAutoGray(false);
//options.setZoom(((int) 9));
//options.setPointToCenter(0.7D, 0.5D);
// 2D模式
options.setTilt(0);
mAMapNaviView.setViewOptions(options);
}
// 设置电子眼所在路线的可见性
mAMapNaviView.setRouteOverlayVisible(false);
// 设置是否隐藏AMapNaviView上的CarOverlay包括自车、罗盘
mAMapNaviView.setCarOverlayVisible(true);
mAMapNaviView.setViewOptions(options);
//设置希望展示的地图缩放级别
mCameraUpdate = CameraUpdateFactory.zoomTo(12);
mAMap.moveCamera(mCameraUpdate);
// 设置当前位置的样式
// myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类
// myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);//连续定位、且将视角移动到地图中心点定位点依照设备方向旋转并且会跟随设备移动。1秒1次定位如果不设置myLocationType默认也会执行此种模式。
// myLocationStyle.interval(1000); //设置连续定位模式下的定位间隔,只在连续定位模式下生效,单次定位模式下不会生效。单位为毫秒。
// BitmapDescriptor location = BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo);
// myLocationStyle.myLocationIcon(location);
// mAMap.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style
// mAMap.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点false表示隐藏定位蓝点并不进行定位默认是false。
mAMap.setOnCameraChangeListener(new AMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition) {
if (cameraPosition != null) {
//Log.w("onCameraChange", "cameraPosition=" + cameraPosition.bearing);
changeAngle((int) cameraPosition.bearing);
}
}
@Override
public void onCameraChangeFinish(CameraPosition cameraPosition) {
}
});
// 关闭地图文字标注
mAMap.showMapText(false);
// 设置地图的样式
mUiSettings = mAMap.getUiSettings();
mUiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮
// mUiSettings.setZoomGesturesEnabled(false);// 缩放手势
// mUiSettings.setScrollGesturesEnabled(false);// 滑动手势
// mUiSettings.setRotateGesturesEnabled(false);// 旋转手势
// mUiSettings.setTiltGesturesEnabled(false);// 倾斜手势
mUiSettings.setAllGesturesEnabled(false);// 所有手势
mUiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
mUiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions();
customMapStyleOptions.setStyleData(MapAssetStyleUtils.getAssetsStyle(context));
customMapStyleOptions.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(context));
customMapStyleOptions.setEnable(true);
mAMap.setCustomMapStyle(customMapStyleOptions);
}
@@ -104,9 +199,10 @@ public class SmallMapDirectionView extends RoundLayout {
* @param angle 角度 0 - 359度旋转,相对于自身中心位置
*/
public void changeAngle(int angle) {
int tempAngle = angle;
if (angle <= 180) {
tempAngle = angle;
int tempAngle = 360 - angle;
if (tempAngle <= 180) {
tempAngle = tempAngle;
} else {
tempAngle = -(360 - tempAngle);
}

View File

@@ -88,15 +88,6 @@ public class SmallMapService extends Service {
mSmallMapDirectionView = mWindowManagerView.findViewById(R.id.smallMapDirectionView);
mSmallMapDirectionView.postDelayed(new Runnable() {
@Override
public void run() {
Random random = new Random();
mSmallMapDirectionView.changeAngle(random.nextInt(360));
}
}, 1000);
}

View File

@@ -0,0 +1,60 @@
package com.mogo.module.small.map.utils;
import android.content.Context;
import java.io.IOException;
import java.io.InputStream;
/**
* @author donghongyu
* @date 12/18/20 5:37 PM
*/
public class MapAssetStyleUtils {
public static byte[] getAssetsStyle(Context context) {
byte[] buffer1 = null;
InputStream is1 = null;
try {
is1 = context.getResources().getAssets().open("small_map_style.data");
int lenght1 = is1.available();
buffer1 = new byte[lenght1];
is1.read(buffer1);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (is1 != null) {
is1.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return buffer1;
}
public static byte[] getAssetsExtraStyle(Context context) {
byte[] buffer1 = null;
InputStream is1 = null;
try {
is1 = context.getResources().getAssets().open("small_map_style_extra.data");
int lenght1 = is1.available();
buffer1 = new byte[lenght1];
is1.read(buffer1);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (is1 != null) {
is1.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return buffer1;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

View File

@@ -19,8 +19,8 @@
android:layout_centerInParent="true"
app:roundLayoutRadius="360dp">
<com.amap.api.maps.TextureMapView
android:id="@+id/textureMapView"
<com.amap.api.navi.AMapNaviView
android:id="@+id/aMapNaviView"
android:layout_width="@dimen/module_small_map_view_width"
android:layout_height="@dimen/module_small_map_view_width" />