绘制每秒一次的车辆
This commit is contained in:
@@ -6,6 +6,8 @@ import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -13,6 +15,7 @@ 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.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public
|
||||
@@ -29,6 +32,7 @@ class MachineVisionMapService extends Service {
|
||||
private IBinder mBinder;
|
||||
|
||||
private WindowManagerView mMachineVisionMapViewManager;
|
||||
private View mRootView;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -80,14 +84,38 @@ class MachineVisionMapService extends Service {
|
||||
public boolean unlinkToDeath( @NonNull DeathRecipient recipient, int flags ) {
|
||||
return super.unlinkToDeath( recipient, flags );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideViewIfExist() throws RemoteException {
|
||||
if ( mRootView != null ) {
|
||||
Logger.d( TAG, "hideViewIfExist" );
|
||||
UiThreadHandler.post( () -> {
|
||||
if ( mRootView != null ) {
|
||||
mRootView.setVisibility( View.GONE );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showViewIfExist() throws RemoteException {
|
||||
if ( mRootView != null ) {
|
||||
Logger.d( TAG, "showViewIfExist" );
|
||||
UiThreadHandler.post( () -> {
|
||||
if ( mRootView != null ) {
|
||||
mRootView.setVisibility( View.VISIBLE );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addMachineVisionMapView() {
|
||||
mMachineVisionMapViewManager = new WindowManagerView.Builder( getApplicationContext() )
|
||||
.contentView( R.layout.module_mvision_layout_view )
|
||||
.size(
|
||||
getResources().getDimensionPixelOffset( R.dimen.module_mvision_view_width ),
|
||||
getResources().getDimensionPixelOffset( R.dimen.module_mvision_view_height )
|
||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||
WindowManager.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
.position(
|
||||
getResources().getDimensionPixelOffset( R.dimen.module_mvision_view_x ),
|
||||
@@ -95,7 +123,7 @@ class MachineVisionMapService extends Service {
|
||||
)
|
||||
.gravity( Gravity.TOP | Gravity.LEFT )
|
||||
.showInWindowManager();
|
||||
|
||||
mRootView = mMachineVisionMapViewManager.findViewById( R.id.module_mvision_map_root );
|
||||
MachineVisionMapViewHandler.getInstance().setMachineVisionMapView( mMachineVisionMapViewManager.findViewById( R.id.module_mvision_map_view ) );
|
||||
mMachineVisionMapViewManager.show();
|
||||
}
|
||||
@@ -103,8 +131,10 @@ class MachineVisionMapService extends Service {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
MachineVisionMapViewHandler.getInstance().release();
|
||||
if ( mMachineVisionMapViewManager != null ) {
|
||||
mMachineVisionMapViewManager.dismiss();
|
||||
mRootView = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.widget.FrameLayout;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.map.IMogoMapView;
|
||||
import com.mogo.map.MogoBaseMapView;
|
||||
import com.mogo.map.impl.custom.CustomMapView;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -20,7 +21,7 @@ public
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class MachineVisionMapView extends FrameLayout {
|
||||
class MachineVisionMapView extends MogoBaseMapView {
|
||||
|
||||
private static final String TAG = "MachineVisionMapView";
|
||||
|
||||
@@ -34,10 +35,10 @@ class MachineVisionMapView extends FrameLayout {
|
||||
|
||||
public MachineVisionMapView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
addMapView();
|
||||
}
|
||||
|
||||
private void addMapView() {
|
||||
@Override
|
||||
protected void addDleMaps() {
|
||||
IMogoMapView machineMapView = new CustomMapView().create( getContext() );
|
||||
if ( machineMapView != null ) {
|
||||
final View mapView = machineMapView.getMapView();
|
||||
@@ -49,5 +50,24 @@ class MachineVisionMapView extends FrameLayout {
|
||||
} else {
|
||||
Logger.e( TAG, "create IMogoMapView instance failed." );
|
||||
}
|
||||
mMapView = machineMapView;
|
||||
onCreate( null );
|
||||
postDelayed( ()->{
|
||||
getMap().getUIController().showMyLocation( true );
|
||||
}, 5000 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display2DMap( boolean invokeCreateAuto, boolean invokeResumeAuto ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayVRMap( boolean invokeCreateAuto, boolean invokeResumeAuto ) {
|
||||
|
||||
}
|
||||
|
||||
private void addMapView() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,5 +50,6 @@ class MachineVisionMapViewHandler {
|
||||
if ( mMachineVisionMapView == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:id="@+id/module_mvision_map_root"
|
||||
android:layout_width="@dimen/module_mvision_view_width"
|
||||
android:layout_height="@dimen/module_mvision_view_height">
|
||||
|
||||
<com.mogo.module.machine.vision.MachineVisionMapView
|
||||
android:id="@+id/module_mvision_map_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_width="@dimen/module_mvision_view_width"
|
||||
android:layout_height="@dimen/module_mvision_view_height" />
|
||||
</FrameLayout>
|
||||
Reference in New Issue
Block a user