dev
This commit is contained in:
1
modules/mogo-modules-mvision/.gitignore
vendored
Normal file
1
modules/mogo-modules-mvision/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
60
modules/mogo-modules-mvision/build.gradle
Normal file
60
modules/mogo-modules-mvision/build.gradle
Normal file
@@ -0,0 +1,60 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.alibaba.arouter'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
// buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||
}
|
||||
}
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
targetCompatibility 1.8
|
||||
sourceCompatibility 1.8
|
||||
}
|
||||
|
||||
}
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
api rootProject.ext.dependencies.mogomap
|
||||
api rootProject.ext.dependencies.mogomapapi
|
||||
api rootProject.ext.dependencies.mogoutils
|
||||
api rootProject.ext.dependencies.mogocommons
|
||||
api rootProject.ext.dependencies.mogoserviceapi
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
} else {
|
||||
api project(":libraries:mogo-map")
|
||||
api project(":libraries:mogo-map-api")
|
||||
api project(":foudations:mogo-utils")
|
||||
api project(":foudations:mogo-commons")
|
||||
api project(':services:mogo-service-api')
|
||||
implementation project(':modules:mogo-module-common')
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
0
modules/mogo-modules-mvision/consumer-rules.pro
Normal file
0
modules/mogo-modules-mvision/consumer-rules.pro
Normal file
3
modules/mogo-modules-mvision/gradle.properties
Normal file
3
modules/mogo-modules-mvision/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
GROUP=com.mogo.module
|
||||
POM_ARTIFACT_ID=module-machine-vision
|
||||
VERSION_CODE=1
|
||||
21
modules/mogo-modules-mvision/proguard-rules.pro
vendored
Normal file
21
modules/mogo-modules-mvision/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.module.machine.vision;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith( AndroidJUnit4.class )
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals( "com.mogo.module.machine.vision.test", appContext.getPackageName() );
|
||||
}
|
||||
}
|
||||
10
modules/mogo-modules-mvision/src/main/AndroidManifest.xml
Normal file
10
modules/mogo-modules-mvision/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.module.machine.vision">
|
||||
|
||||
<application>
|
||||
<service
|
||||
android:name=".MachineVisionMapService"
|
||||
android:exported="false"
|
||||
android:process=":machinevision" />
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.module.machine.vision;
|
||||
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/27
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
interface IMogoMachineVisionProvider extends IMogoModuleProvider {
|
||||
|
||||
String path = "/machinevision/api";
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.mogo.module.machine.vision;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.view.Gravity;
|
||||
|
||||
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;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/26
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class MachineVisionMapService extends Service {
|
||||
|
||||
private static final String TAG = "MachineVisionMapService";
|
||||
|
||||
private IBinder mBinder;
|
||||
|
||||
private WindowManagerView mMachineVisionMapViewManager;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind( Intent intent ) {
|
||||
mBinder = new MachineVisionMapServiceBinder();
|
||||
addMachineVisionMapView();
|
||||
Logger.d( TAG, "onBind" );
|
||||
return mBinder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onUnbind( Intent intent ) {
|
||||
if ( mMachineVisionMapViewManager != null && mMachineVisionMapViewManager.isShowing() ) {
|
||||
mMachineVisionMapViewManager.dismiss();
|
||||
}
|
||||
mMachineVisionMapViewManager = null;
|
||||
Logger.d( TAG, "onUnbind" );
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRebind( Intent intent ) {
|
||||
super.onRebind( intent );
|
||||
addMachineVisionMapView();
|
||||
Logger.d( TAG, "onRebind" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
}
|
||||
|
||||
public class MachineVisionMapServiceBinder extends IMachineVisionInterface.Stub {
|
||||
|
||||
private static final String TAG = "MachineVisionMapServiceBinder";
|
||||
|
||||
@Override
|
||||
public void postData( MogoSnapshotSetData data ) throws RemoteException {
|
||||
Logger.d( TAG, "current Thread:%s", Thread.currentThread().getName() );
|
||||
MachineVisionMapViewHandler.getInstance().renderSnapshotSetData( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void linkToDeath( @NonNull DeathRecipient recipient, int flags ) {
|
||||
super.linkToDeath( recipient, flags );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unlinkToDeath( @NonNull DeathRecipient recipient, int flags ) {
|
||||
return super.unlinkToDeath( recipient, flags );
|
||||
}
|
||||
}
|
||||
|
||||
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 )
|
||||
)
|
||||
.position(
|
||||
getResources().getDimensionPixelOffset( R.dimen.module_mvision_view_x ),
|
||||
getResources().getDimensionPixelOffset( R.dimen.module_mvision_view_y )
|
||||
)
|
||||
.gravity( Gravity.TOP | Gravity.LEFT )
|
||||
.showInWindowManager();
|
||||
|
||||
MachineVisionMapViewHandler.getInstance().setMachineVisionMapView( mMachineVisionMapViewManager.findViewById( R.id.module_mvision_map_view ) );
|
||||
mMachineVisionMapViewManager.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if ( mMachineVisionMapViewManager != null ) {
|
||||
mMachineVisionMapViewManager.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.mogo.module.machine.vision;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.map.IMogoMapView;
|
||||
import com.mogo.map.impl.custom.CustomMapView;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/26
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class MachineVisionMapView extends FrameLayout {
|
||||
|
||||
private static final String TAG = "MachineVisionMapView";
|
||||
|
||||
public MachineVisionMapView( Context context ) {
|
||||
this( context, null );
|
||||
}
|
||||
|
||||
public MachineVisionMapView( Context context, @Nullable AttributeSet attrs ) {
|
||||
this( context, attrs, 0 );
|
||||
}
|
||||
|
||||
public MachineVisionMapView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
addMapView();
|
||||
}
|
||||
|
||||
private void addMapView() {
|
||||
IMogoMapView machineMapView = new CustomMapView().create( getContext() );
|
||||
if ( machineMapView != null ) {
|
||||
final View mapView = machineMapView.getMapView();
|
||||
if ( mapView != null ) {
|
||||
addView( mapView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) );
|
||||
} else {
|
||||
Logger.e( TAG, "create MapView instance failed." );
|
||||
}
|
||||
} else {
|
||||
Logger.e( TAG, "create IMogoMapView instance failed." );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.mogo.module.machine.vision;
|
||||
|
||||
import com.mogo.module.common.entity.MogoSnapshotSetData;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/27
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class MachineVisionMapViewHandler {
|
||||
|
||||
private static volatile MachineVisionMapViewHandler sInstance;
|
||||
|
||||
private MachineVisionMapViewHandler() {
|
||||
}
|
||||
|
||||
public static MachineVisionMapViewHandler getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( MachineVisionMapViewHandler.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new MachineVisionMapViewHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
mMachineVisionMapView = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private MachineVisionMapView mMachineVisionMapView;
|
||||
|
||||
public void setMachineVisionMapView( MachineVisionMapView mMachineVisionMapView ) {
|
||||
this.mMachineVisionMapView = mMachineVisionMapView;
|
||||
}
|
||||
|
||||
public void renderSnapshotSetData( MogoSnapshotSetData data ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.mogo.module.machine.vision;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/27
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = IMogoMachineVisionProvider.path)
|
||||
class MogoMachineVisionProvider implements IMogoMachineVisionProvider {
|
||||
|
||||
private static final String TAG = "MogoMachineVisionProvider";
|
||||
|
||||
private Intent mMachineVisionServiceIntent;
|
||||
|
||||
@Override
|
||||
public Fragment createFragment( Context context, Bundle data ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView( Context context ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getModuleName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
mMachineVisionServiceIntent = new Intent( context, MachineVisionMapService.class );
|
||||
context.startService( mMachineVisionServiceIntent );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if ( mMachineVisionServiceIntent != null ) {
|
||||
AbsMogoApplication.getApp().stopService( mMachineVisionServiceIntent );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?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">
|
||||
|
||||
<com.mogo.module.machine.vision.MachineVisionMapView
|
||||
android:id="@+id/module_mvision_map_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="module_mvision_view_width">600px</dimen>
|
||||
<dimen name="module_mvision_view_height">480px</dimen>
|
||||
<dimen name="module_mvision_view_x">300px</dimen>
|
||||
<dimen name="module_mvision_view_y">100px</dimen>
|
||||
</resources>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.module.machine.vision;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals( 4, 2 + 2 );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user