diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java index b414122da7..907e3007d1 100644 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java @@ -10,10 +10,6 @@ import android.widget.ImageView; import android.widget.TextView; import com.alibaba.android.arouter.launcher.ARouter; -import com.elegant.analytics.Analytics; -import com.elegant.analytics.AnalyticsConfig; -import com.elegant.analytics.IAnalyticsParamsProvider; -import com.elegant.analytics.UploadMode; import com.mogo.commons.analytics.AnalyticsUtils; import com.mogo.commons.debug.DebugConfig; import com.mogo.commons.device.Devices; @@ -28,10 +24,8 @@ import com.mogo.utils.ThreadPoolService; import com.mogo.utils.TipDrawable; import com.mogo.utils.TipToast; import com.mogo.utils.network.NetConfig; -import com.mogo.utils.storage.SharedPrefsMgr; import java.security.SecureRandom; -import java.util.Map; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; @@ -48,6 +42,13 @@ public abstract class AbsMogoApplication extends Application { private static final String TAG = "AbsMogoApplication"; + // 没有换肤功能的LayoutInflater + private static LayoutInflater mLayoutInflaterNoSkin; + + public static LayoutInflater getLayoutInflaterNoSkin() { + return mLayoutInflaterNoSkin; + } + private static Application sApp; public static Application getApp() { @@ -57,6 +58,8 @@ public abstract class AbsMogoApplication extends Application { @Override public void onCreate() { super.onCreate(); + // 在设置皮肤布局填充器之前进行克隆一个出来 + mLayoutInflaterNoSkin = LayoutInflater.from(this).cloneInContext(this); sApp = this; initARouter(); if ( shouldInit() ) { diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java index e23dc28f2f..4a439ba53d 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java @@ -83,7 +83,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme @Override protected void beforeSetContentView( Bundle savedInstanceState ) { init(); - installSkinManager( savedInstanceState ); + //installSkinManager( savedInstanceState ); } /** diff --git a/modules/mogo-module-smp/src/main/AndroidManifest.xml b/modules/mogo-module-smp/src/main/AndroidManifest.xml index 32b078729c..32b3a76248 100644 --- a/modules/mogo-module-smp/src/main/AndroidManifest.xml +++ b/modules/mogo-module-smp/src/main/AndroidManifest.xml @@ -1,11 +1,4 @@ - - - - \ No newline at end of file diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java index 9e131500ea..dec53d8d38 100644 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java +++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java @@ -4,9 +4,9 @@ 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 android.widget.RelativeLayout; import androidx.annotation.Nullable; @@ -17,7 +17,7 @@ import com.amap.api.maps.UiSettings; import com.amap.api.maps.model.CameraPosition; import com.amap.api.navi.AMapNaviView; import com.amap.api.navi.AMapNaviViewOptions; -import com.mogo.module.common.view.RoundLayout; +import com.mogo.commons.AbsMogoApplication; import com.mogo.module.small.map.animation.DirectionRotateAnimation; import com.mogo.utils.FileUtils; @@ -30,11 +30,11 @@ import java.io.IOException; * @author donghongyu * @date 12/14/20 4:40 PM */ -public class SmallMapDirectionView extends RoundLayout { +public class SmallMapDirectionView extends RelativeLayout { + private String styleFilePath = "/mnt/sdcard/amap/small_map_style.data"; private ImageView mIvMapBorder; private AMapNaviView mAMapNaviView; - private DirectionRotateAnimation mRotateAnimation; private int lastAngle = 0; @@ -48,15 +48,17 @@ public class SmallMapDirectionView extends RoundLayout { public SmallMapDirectionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - initView(context); + try { + initView(context); + } catch (Exception e) { + e.printStackTrace(); + } } private void initView(Context context) { - String styleFilePath = "/mnt/sdcard/amap/small_map_style.data"; - mRotateAnimation = new DirectionRotateAnimation(context, null); - LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this); + AbsMogoApplication.getLayoutInflaterNoSkin().inflate(R.layout.module_small_map_view, this); mIvMapBorder = findViewById(R.id.ivMapBorder); mAMapNaviView = findViewById(R.id.aMapNaviView); mAMapNaviView.onCreate(null); diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java deleted file mode 100644 index 4a8a3c0fbe..0000000000 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapService.java +++ /dev/null @@ -1,131 +0,0 @@ -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"); - mWindowManagerView = new WindowManagerView.Builder(getApplicationContext()) - .contentView(R.layout.module_small_map_direction_view) - .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(); - mSmallMapDirectionView = mWindowManagerView.findViewById(R.id.smallMapDirectionView); - } - - - /** - * 小地图与大地图之间进程通讯 - */ - 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"); - - } - - - } -} diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapViewHandler.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapViewHandler.java deleted file mode 100644 index 93e841b09a..0000000000 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapViewHandler.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.mogo.module.small.map; - -/** - * @author donghongyu - * @date 12/10/20 1:35 PM - */ -public class SmallMapViewHandler { -} diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallVisionProvider.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallVisionProvider.java index c2e5ad3f48..c6b1a34797 100644 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallVisionProvider.java +++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallVisionProvider.java @@ -1,22 +1,24 @@ 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 @@ -26,9 +28,11 @@ import com.mogo.service.statusmanager.StatusDescriptor; 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; @@ -76,22 +80,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, "小地图模块触发展示……"); - if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { - mSmallMapServiceIntent = new Intent(mContext, SmallMapService.class); - mContext.startService(mSmallMapServiceIntent); - } + addSmallMapView(); } @Override public void hidePanel() { Log.d(TAG, "小地图模块触发隐藏……"); - if (mSmallMapServiceIntent != null) { - AbsMogoApplication.getApp().stopService(mSmallMapServiceIntent); + if (mWindowManagerView != null && mWindowManagerView.isShowing()) { + mWindowManagerView.dismiss(); } } @@ -119,4 +123,33 @@ 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(); + } + } diff --git a/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml b/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml index d86de24931..dd0630dcfc 100644 --- a/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml +++ b/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml @@ -1,8 +1,10 @@ - @@ -33,4 +35,4 @@ android:layout_centerInParent="true" android:src="@drawable/module_small_map_view_border" /> - \ No newline at end of file + \ No newline at end of file diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/alarm/V2XAlarmServer.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/alarm/V2XAlarmServer.java index c85a80e593..ef7ce042d4 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/alarm/V2XAlarmServer.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/alarm/V2XAlarmServer.java @@ -2,7 +2,6 @@ package com.mogo.module.v2x.alarm; import android.text.TextUtils; -import com.mogo.commons.debug.DebugConfig; import com.mogo.map.MogoLatLng; import com.mogo.map.location.MogoLocation; import com.mogo.map.search.geo.IMogoGeoSearchListener; @@ -253,6 +252,10 @@ public class V2XAlarmServer { //Logger.i(MODULE_NAME, "根据经纬度查询结果为:" + regeocodeResult.getRegeocodeAddress().getFormatAddress()); String keyword = "停车场"; boolean isHighWay = false; + if (regeocodeResult == null || regeocodeResult.getRegeocodeAddress() == null || + regeocodeResult.getRegeocodeAddress().getFormatAddress() == null) { + return; + } // 如果当前位置是高速则推荐服务区 if (regeocodeResult.getRegeocodeAddress().getFormatAddress().contains("高速")) { keyword = "停车场|服务区";