完成小地图的容器绘制,地图还无法添加上去
This commit is contained in:
@@ -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");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user