diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/RoundLayout.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/RoundLayout.java
new file mode 100644
index 0000000000..23418c8b9e
--- /dev/null
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/view/RoundLayout.java
@@ -0,0 +1,90 @@
+package com.mogo.module.common.view;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Path;
+import android.graphics.RectF;
+import android.util.AttributeSet;
+import android.widget.RelativeLayout;
+
+import com.mogo.module.common.R;
+import com.mogo.skin.support.IMogoSkinCompatSupportable;
+import com.mogo.skin.support.helper.MogoSkinCompatBackgroundHelperDelegate;
+
+/**
+ * author : donghongyu
+ * e-mail : 1358506549@qq.com
+ * date : 2020/3/25 11:39 AM
+ * desc :
+ * version: 1.0
+ */
+public class RoundLayout extends RelativeLayout implements IMogoSkinCompatSupportable {
+ private float roundLayoutRadius = 14f;
+ private Path roundPath;
+ private RectF rectF;
+ private MogoSkinCompatBackgroundHelperDelegate mBackgroundTintHelper;
+
+ public RoundLayout(Context context) {
+ this(context, null);
+ }
+
+ public RoundLayout(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public RoundLayout(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+
+ TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RoundLayout);
+ roundLayoutRadius = typedArray.getDimensionPixelSize(R.styleable.RoundLayout_roundLayoutRadius, (int) roundLayoutRadius);
+ typedArray.recycle();
+
+ init();
+
+ mBackgroundTintHelper = new MogoSkinCompatBackgroundHelperDelegate(this);
+ mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
+ }
+
+
+ private void init() {
+ setWillNotDraw(false);//如果你继承的是ViewGroup,注意此行,否则draw方法是不会回调的;
+ roundPath = new Path();
+ rectF = new RectF();
+ }
+
+ private void setRoundPath() {
+ //添加一个圆角矩形到path中, 如果要实现任意形状的View, 只需要手动添加path就行
+ roundPath.addRoundRect(rectF, roundLayoutRadius, roundLayoutRadius, Path.Direction.CW);
+ }
+
+
+ public void setRoundLayoutRadius(float roundLayoutRadius) {
+ this.roundLayoutRadius = roundLayoutRadius;
+ setRoundPath();
+ postInvalidate();
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ super.onLayout(changed, l, t, r, b);
+ rectF.set(0f, 0f, getMeasuredWidth(), getMeasuredHeight());
+ setRoundPath();
+ }
+
+ @Override
+ public void draw(Canvas canvas) {
+ if (roundLayoutRadius > 0f) {
+ canvas.clipPath(roundPath);
+ }
+ super.draw(canvas);
+ }
+
+ @Override
+ public void applySkin() {
+ if (mBackgroundTintHelper != null) {
+ mBackgroundTintHelper.applySkin();
+ }
+ }
+}
+
diff --git a/modules/mogo-module-common/src/main/res/values/styles.xml b/modules/mogo-module-common/src/main/res/values/styles.xml
index aab6f7f597..c694e342bb 100644
--- a/modules/mogo-module-common/src/main/res/values/styles.xml
+++ b/modules/mogo-module-common/src/main/res/values/styles.xml
@@ -27,4 +27,8 @@
- @drawable/module_commons_heart_ratingbar_drawable
+
+
+
+
\ No newline at end of file
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
index 6739bb7c85..e4a4336d9c 100644
--- 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
@@ -4,7 +4,10 @@ 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;
@@ -19,16 +22,22 @@ import com.mogo.utils.logger.Logger;
public class SmallMapService extends Service {
private static final String TAG = "MachineVisionMapService";
private IBinder mBinder;
+
private WindowManagerView mWindowManagerView;
private SmallMapView mMapView;
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ Logger.d(TAG, "onCreate");
+ addMachineVisionMapView();
+ }
@Nullable
@Override
public IBinder onBind(Intent intent) {
- mBinder = new SmallMapServiceBinder();
- addMachineVisionMapView();
Logger.d(TAG, "onBind");
+ mBinder = new SmallMapServiceBinder();
return mBinder;
}
@@ -41,17 +50,39 @@ public class SmallMapService extends Service {
@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();
+ }
}
private void addMachineVisionMapView() {
+ Logger.d(TAG, "addMachineVisionMapView");
+ mWindowManagerView = new WindowManagerView.Builder(getApplicationContext())
+ .contentView(R.layout.module_small_map_view)
+ .size(
+ WindowManager.LayoutParams.WRAP_CONTENT,
+ WindowManager.LayoutParams.WRAP_CONTENT
+ )
+ .position(
+ getResources().getDimensionPixelOffset( R.dimen.module_mvision_view_x ),
+ getResources().getDimensionPixelOffset( R.dimen.module_mvision_view_y )
+ )
+ .gravity(Gravity.TOP | Gravity.LEFT)
+ .showInWindowManager();
+ mWindowManagerView.show();
+
}
@@ -61,19 +92,38 @@ public class SmallMapService extends Service {
*/
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/SmallMapView.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapView.java
index b9b74f4ac5..62e75cdc07 100644
--- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapView.java
+++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapView.java
@@ -2,18 +2,19 @@ package com.mogo.module.small.map;
import android.content.Context;
import android.util.AttributeSet;
-import android.util.Log;
import androidx.annotation.Nullable;
import com.mogo.map.MogoBaseMapView;
+import com.mogo.utils.logger.Logger;
/**
* @author donghongyu
* @date 12/10/20 1:35 PM
*/
public class SmallMapView extends MogoBaseMapView {
- private final String TAG = "SmallMapView";
+
+ private static final String TAG = "SmallMapView";
public SmallMapView(Context context) {
this(context, null);
@@ -28,7 +29,7 @@ public class SmallMapView extends MogoBaseMapView {
}
@Override
- protected void addMapView( Context context ) {
-
+ protected void addMapView(Context context) {
+ Logger.d(TAG, "addMapView");
}
-}
+}
\ No newline at end of file
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 d6ee7e537b..3bbdee2b65 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,6 +1,7 @@
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.View;
@@ -9,6 +10,7 @@ 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.service.module.ModuleType;
/**
@@ -19,6 +21,8 @@ import com.mogo.service.module.ModuleType;
public class SmallVisionProvider implements IMogoSmallMapProvider {
private final String TAG = "SmallVisionProvider";
+ private Intent mSmallMapServiceIntent;
+
@Override
public Fragment createFragment(Context context, Bundle data) {
return null;
@@ -43,12 +47,15 @@ public class SmallVisionProvider implements IMogoSmallMapProvider {
@Override
public void init(Context context) {
Log.d(TAG, "小地图模块初始化……");
-
+ mSmallMapServiceIntent = new Intent(context, SmallMapService.class);
+ context.startService(mSmallMapServiceIntent);
}
@Override
public void onDestroy() {
Log.d(TAG, "小地图模块销毁……");
-
+ if (mSmallMapServiceIntent != null) {
+ AbsMogoApplication.getApp().stopService(mSmallMapServiceIntent);
+ }
}
}
diff --git a/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_border.png b/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_border.png
new file mode 100644
index 0000000000..cc2c540c8b
Binary files /dev/null and b/modules/mogo-module-smp/src/main/res/drawable-xhdpi/module_small_map_view_border.png differ
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
new file mode 100644
index 0000000000..a787adfc60
--- /dev/null
+++ b/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml
new file mode 100644
index 0000000000..9910274622
--- /dev/null
+++ b/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml
@@ -0,0 +1,12 @@
+
+
+ 400px
+ 400px
+ 1490px
+ 650px
+
+ 0px
+ 0px
+ 1920px
+ 1080px
+
\ No newline at end of file