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

This commit is contained in:
tongchenfei
2020-12-24 20:31:09 +08:00
7 changed files with 185 additions and 68 deletions

View File

@@ -3,6 +3,7 @@ package com.mogo.commons;
import android.app.Application;
import android.content.Context;
import android.text.TextUtils;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -59,7 +60,7 @@ public abstract class AbsMogoApplication extends Application {
public void onCreate() {
super.onCreate();
// 在设置皮肤布局填充器之前进行克隆一个出来
mLayoutInflaterNoSkin = LayoutInflater.from(this).cloneInContext(this);
mLayoutInflaterNoSkin = LayoutInflater.from(new ContextThemeWrapper(this, R.style.Theme_AppCompat)).cloneInContext(new ContextThemeWrapper(this, R.style.Theme_AppCompat));
sApp = this;
initARouter();
if ( shouldInit() ) {

View File

@@ -83,7 +83,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
@Override
protected void beforeSetContentView( Bundle savedInstanceState ) {
init();
//installSkinManager( savedInstanceState );
installSkinManager( savedInstanceState );
}
/**

View File

@@ -1,4 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.module.small.map">
<application>
<service
android:name=".SmallMapService"
android:exported="false"
android:process=":smallMap"/>
</application>
</manifest>

View File

@@ -0,0 +1,134 @@
package com.mogo.module.small.map;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.view.Gravity;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mogo.module.common.entity.MogoSnapshotSetData;
import com.mogo.module.common.machinevision.IMachineVisionInterface;
import com.mogo.module.common.wm.WindowManagerView;
import com.mogo.utils.logger.Logger;
/**
* @author donghongyu
* @date 12/10/20 1:35 PM
*/
public class SmallMapService extends Service {
private static final String TAG = "MachineVisionMapService";
private IBinder mBinder;
private WindowManagerView mWindowManagerView;
private SmallMapDirectionView mSmallMapDirectionView;
@Override
public void onCreate() {
super.onCreate();
Logger.d(TAG, "onCreate");
addSmallMapView();
}
@Nullable
@Override
public IBinder onBind(Intent intent) {
Logger.d(TAG, "onBind");
mBinder = new SmallMapServiceBinder();
return mBinder;
}
@Override
public void onRebind(Intent intent) {
super.onRebind(intent);
addSmallMapView();
Logger.d(TAG, "onRebind");
}
@Override
public boolean onUnbind(Intent intent) {
Logger.d(TAG, "onUnbind");
if (mWindowManagerView != null && mWindowManagerView.isShowing()) {
mWindowManagerView.dismiss();
}
mWindowManagerView = null;
return true;
}
@Override
public void onDestroy() {
super.onDestroy();
Logger.d(TAG, "onDestroy");
if (mWindowManagerView != null) {
mWindowManagerView.dismiss();
}
}
/**
* 添加小地图View
*/
private void addSmallMapView() {
Logger.d(TAG, "addSmallMapView");
// 初始化小地图控件
mSmallMapDirectionView = new SmallMapDirectionView(getApplicationContext());
mWindowManagerView = new WindowManagerView.Builder(getApplicationContext())
.contentView(mSmallMapDirectionView)
.size(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT
)
.position(
getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_x),
getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_y)
)
.gravity(Gravity.TOP | Gravity.LEFT)
.showInWindowManager();
mWindowManagerView.show();
}
/**
* 小地图与大地图之间进程通讯
*/
public class SmallMapServiceBinder extends IMachineVisionInterface.Stub {
@Override
public void linkToDeath(@NonNull DeathRecipient recipient, int flags) {
super.linkToDeath(recipient, flags);
Logger.d(TAG, "linkToDeath");
}
@Override
public boolean unlinkToDeath(@NonNull DeathRecipient recipient, int flags) {
Logger.d(TAG, "unlinkToDeath");
return super.unlinkToDeath(recipient, flags);
}
@Override
public void postData(MogoSnapshotSetData data) throws RemoteException {
Logger.d(TAG, "postData");
}
@Override
public void hideViewIfExist() throws RemoteException {
Logger.d(TAG, "hideViewIfExist");
}
@Override
public void showViewIfExist() throws RemoteException {
Logger.d(TAG, "showViewIfExist");
}
}
}

View File

@@ -1,24 +1,22 @@
package com.mogo.module.small.map;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.wm.WindowManagerView;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.map.IMogoSmallMapProvider;
import com.mogo.service.module.ModuleType;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.logger.Logger;
/**
* @author donghongyu
@@ -28,11 +26,9 @@ import com.mogo.utils.logger.Logger;
public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusChangedListener {
private final String TAG = "SmallVisionProvider";
private Intent mSmallMapServiceIntent;
private Context mContext;
private WindowManagerView mWindowManagerView;
private SmallMapDirectionView mSmallMapDirectionView;
@Override
public Fragment createFragment(Context context, Bundle data) {
return null;
@@ -80,22 +76,22 @@ public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusCh
public void onDestroy() {
Log.d(TAG, "小地图模块销毁……");
hidePanel();
// 释放组件内存
mSmallMapDirectionView = null;
mWindowManagerView = null;
}
@Override
public void showPanel() {
Log.d(TAG, "小地图模块触发展示……");
addSmallMapView();
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
mSmallMapServiceIntent = new Intent(mContext, SmallMapService.class);
mContext.startService(mSmallMapServiceIntent);
}
}
@Override
public void hidePanel() {
Log.d(TAG, "小地图模块触发隐藏……");
if (mWindowManagerView != null && mWindowManagerView.isShowing()) {
mWindowManagerView.dismiss();
if (mSmallMapServiceIntent != null) {
AbsMogoApplication.getApp().stopService(mSmallMapServiceIntent);
}
}
@@ -126,33 +122,4 @@ public class SmallVisionProvider implements IMogoSmallMapProvider, IMogoStatusCh
}
}
}
/**
* 添加小地图View
*/
private void addSmallMapView() {
Logger.d(TAG, "addSmallMapView");
// 初始化小地图控件
if (mSmallMapDirectionView == null) {
mSmallMapDirectionView = new SmallMapDirectionView(mContext);
}
if (mWindowManagerView == null) {
mWindowManagerView = new WindowManagerView.Builder(mContext)
.contentView(mSmallMapDirectionView)
.size(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT
)
.position(
mContext.getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_x),
mContext.getResources().getDimensionPixelOffset(R.dimen.module_small_map_view_y)
)
.gravity(Gravity.TOP | Gravity.LEFT)
.showInWindowManager();
}
mWindowManagerView.show();
}
}

View File

@@ -111,19 +111,19 @@ public class V2XAlarmServer {
}
// 进行提醒
if (!isAlreadyAlert) {
Logger.w(MODULE_NAME, "V2X预警--车辆与事件信息:" +
"\n事件详情ID" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
"\n事件详情" + GsonUtil.jsonFromObject(v2XRoadEventEntity.getNoveltyInfo()) +
"\n距离" + v2XRoadEventEntity.getDistance() + "" +
"\n是否已经提醒" + isAlreadyAlert +
"\n当前车辆-经度:" + currentLocation.getLongitude() +
"\n当前车辆-经度:" + currentLocation.getLatitude() +
"\n当前车辆-角度:" + currentLocation.getBearing() +
"\n道路事件-经度:" + eventLocation.getLon() +
"\n道路事件-经度:" + eventLocation.getLat() +
"\n道路事件-角度:" + eventLocation.getAngle() +
"\n夹角角度" + eventAngle + ""
);
// Logger.w(MODULE_NAME, "V2X预警--车辆与事件信息:" +
// "\n事件详情ID" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
// "\n事件详情" + GsonUtil.jsonFromObject(v2XRoadEventEntity.getNoveltyInfo()) +
// "\n距离" + v2XRoadEventEntity.getDistance() + "米" +
// "\n是否已经提醒" + isAlreadyAlert +
// "\n当前车辆-经度:" + currentLocation.getLongitude() +
// "\n当前车辆-经度:" + currentLocation.getLatitude() +
// "\n当前车辆-角度:" + currentLocation.getBearing() +
// "\n道路事件-经度:" + eventLocation.getLon() +
// "\n道路事件-经度:" + eventLocation.getLat() +
// "\n道路事件-角度:" + eventLocation.getAngle() +
// "\n夹角角度" + eventAngle + " 度"
// );
mAlertRoadEventList.put(v2XRoadEventEntity, TimeUtils.getNowString());
return v2XRoadEventEntity;
}
@@ -141,13 +141,13 @@ public class V2XAlarmServer {
// );
}
} else {
Logger.w(MODULE_NAME,
"V2X预警--车头方向与事件方向角度不一致:" +
"\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
"\n车头方向 " + carBearing +
"\n事件方向" + eventBearing +
"\n角度差值" + diffAngle
);
// Logger.w(MODULE_NAME,
// "V2X预警--车头方向与事件方向角度不一致:" +
// "\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
// "\n车头方向 " + carBearing +
// "\n事件方向" + eventBearing +
// "\n角度差值" + diffAngle
// );
}
} else {
// Logger.w(MODULE_NAME, "V2X预警--车辆距离事件距离大于500米了" +
@@ -156,10 +156,10 @@ public class V2XAlarmServer {
// );
}
} else {
Logger.e(MODULE_NAME,
"V2X预警--道路事件没有角度信息" +
"\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
);
// Logger.e(MODULE_NAME,
// "V2X预警--道路事件没有角度信息" +
// "\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId()
// );
}
}
}

View File

@@ -80,6 +80,14 @@ public class RoundLayout extends RelativeLayout implements IMogoSkinCompatSuppor
super.draw(canvas);
}
@Override
public void setBackgroundResource(int resId) {
super.setBackgroundResource(resId);
if (mBackgroundTintHelper != null) {
mBackgroundTintHelper.onSetBackgroundResource(resId);
}
}
@Override
public void applySkin() {
if (mBackgroundTintHelper != null) {