还原了多进程小地图方案,原因是LayoutInflater.from(this).cloneInContext(this)没有起到作用
This commit is contained in:
@@ -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() ) {
|
||||
|
||||
@@ -83,7 +83,7 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
@Override
|
||||
protected void beforeSetContentView( Bundle savedInstanceState ) {
|
||||
init();
|
||||
//installSkinManager( savedInstanceState );
|
||||
installSkinManager( savedInstanceState );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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>
|
||||
@@ -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");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user