dev
This commit is contained in:
@@ -4,11 +4,11 @@ android {
|
|||||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId rootProject.ext.android.applicationId
|
|
||||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||||
versionCode rootProject.ext.android.versionCode
|
versionCode rootProject.ext.android.versionCode
|
||||||
versionName rootProject.ext.android.versionName
|
versionName rootProject.ext.android.versionName
|
||||||
|
applicationId rootProject.ext.android.applicationId
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
javaCompileOptions {
|
javaCompileOptions {
|
||||||
@@ -54,6 +54,16 @@ dependencies {
|
|||||||
testImplementation rootProject.ext.dependencies.leakcanary
|
testImplementation rootProject.ext.dependencies.leakcanary
|
||||||
releaseImplementation rootProject.ext.dependencies.leakcanarynoop
|
releaseImplementation rootProject.ext.dependencies.leakcanarynoop
|
||||||
releaseImplementation rootProject.ext.dependencies.androidxmultidex
|
releaseImplementation rootProject.ext.dependencies.androidxmultidex
|
||||||
|
|
||||||
|
if (Boolean.valueOf(RELEASE)) {
|
||||||
|
api rootProject.ext.dependencies.modulemain
|
||||||
|
api rootProject.ext.dependencies.mogocommons
|
||||||
|
implementation rootProject.ext.dependencies.moduledemo
|
||||||
|
implementation rootProject.ext.dependencies.moduledemo2
|
||||||
|
} else {
|
||||||
implementation project(':modules:mogo-module-main')
|
implementation project(':modules:mogo-module-main')
|
||||||
implementation project(':foudations:mogo-commons')
|
implementation project(':foudations:mogo-commons')
|
||||||
|
implementation project(':demo:demo-module-map')
|
||||||
|
implementation project(':demo:demo-module-map2')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
38
build.gradle
38
build.gradle
@@ -1,5 +1,6 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
apply from: "config.gradle"
|
apply from: "config.gradle"
|
||||||
|
apply from: "javadoc.gradle"
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.3.61+'
|
ext.kotlin_version = '1.3.61+'
|
||||||
repositories {
|
repositories {
|
||||||
@@ -44,8 +45,45 @@ allprojects {
|
|||||||
// dirs project(':libraries:map-baidu').file('libs')
|
// dirs project(':libraries:map-baidu').file('libs')
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getValueFromRootProperties(String key) {
|
||||||
|
File file = rootProject.file('gradle.properties')
|
||||||
|
String value = "";
|
||||||
|
if (file.exists()) {
|
||||||
|
//加载资源
|
||||||
|
InputStream inputStream = file.newDataInputStream();
|
||||||
|
Properties properties = new Properties()
|
||||||
|
properties.load(inputStream)
|
||||||
|
|
||||||
|
if (properties.containsKey(key)) {
|
||||||
|
value = properties.getProperty(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
rootProject.subprojects { project ->
|
||||||
|
project.afterEvaluate {
|
||||||
|
dependencies{
|
||||||
|
components {
|
||||||
|
all { ComponentMetadataDetails details ->
|
||||||
|
if (details.toString().endsWith("-SNAPSHOT")) {
|
||||||
|
details.changing = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
it.configurations.all {
|
||||||
|
resolutionStrategy.cacheChangingModulesFor 0, 'minutes'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,8 @@ ext {
|
|||||||
androidxappcompat : "androidx.appcompat:appcompat:1.0.2",
|
androidxappcompat : "androidx.appcompat:appcompat:1.0.2",
|
||||||
androidxconstraintlayout: "androidx.constraintlayout:constraintlayout:1.1.3",
|
androidxconstraintlayout: "androidx.constraintlayout:constraintlayout:1.1.3",
|
||||||
androidxmultidex : "androidx.multidex:multidex:2.0.1",
|
androidxmultidex : "androidx.multidex:multidex:2.0.1",
|
||||||
|
androidxviewpager2 : "androidx.viewpager2:viewpager2:1.0.0",
|
||||||
|
androidxrecyclerview : "androidx.recyclerview:recyclerview:1.1.0",
|
||||||
// 测试
|
// 测试
|
||||||
junit : "junit:junit:4.12",
|
junit : "junit:junit:4.12",
|
||||||
androidxjunit : "androidx.test.ext:junit:1.1.0",
|
androidxjunit : "androidx.test.ext:junit:1.1.0",
|
||||||
@@ -56,5 +58,24 @@ ext {
|
|||||||
// leakcanary
|
// leakcanary
|
||||||
leakcanary : 'com.squareup.leakcanary:leakcanary-android:1.5.4',
|
leakcanary : 'com.squareup.leakcanary:leakcanary-android:1.5.4',
|
||||||
leakcanarynoop : 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4',
|
leakcanarynoop : 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4',
|
||||||
|
|
||||||
|
// material
|
||||||
|
material : 'com.google.android.material:material:1.0.0',
|
||||||
|
|
||||||
|
|
||||||
|
// modules
|
||||||
|
moduledemo : "com.mogo.module:module-demo:${DEMO_MODULE_MAP_VERSION}",
|
||||||
|
moduledemo2 : "com.mogo.module:module-demo:${DEMO_MODULE_MAP2_VERSION}",
|
||||||
|
mogocommons : "com.mogo.commons:mogo-commons:${MOGO_COMMONS_VERSION}",
|
||||||
|
mogoutils : "com.mogo.commons:mogo-utils:${MOGO_UTILS_VERSION}",
|
||||||
|
mapamap : "com.mogo.map:map-amap:${MAP_AMAP_VERSION}",
|
||||||
|
mogomap : "com.mogo.map:mogo-map:${MOGO_MAP_VERSION}",
|
||||||
|
mogomapapi : "com.mogo.map:mogo-map-api:${MOGO_MAP_API_VERSION}",
|
||||||
|
modulecommon : "com.mogo.module:module-common:${MOGO_MODULE_COMMON_VERSION}",
|
||||||
|
modulemain : "com.mogo.module:module-main:${MOGO_MODULE_MAIN_VERSION}",
|
||||||
|
modulemap : "com.mogo.module:module-map:${MOGO_MODULE_MAP_VERSION}",
|
||||||
|
mogoservice : "com.mogo.service:mogo-service:${MOGO_SERVICE_VERSION}",
|
||||||
|
mogoserviceapi : "com.mogo.service:mogo-service-api:${MOGO_SERVICE_API_VERSION}",
|
||||||
|
moduleapps : "com.mogo.module:module-apps:${MOGO_MODULE_APPS_VERSION}",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -2,15 +2,13 @@ apply plugin: 'com.android.library'
|
|||||||
apply plugin: 'com.alibaba.arouter'
|
apply plugin: 'com.alibaba.arouter'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||||
buildToolsVersion "29.0.2"
|
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||||
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 19
|
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||||
targetSdkVersion 29
|
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||||
versionCode 1
|
versionCode Integer.valueOf(VERSION_CODE)
|
||||||
versionName "1.0"
|
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
consumerProguardFiles 'consumer-rules.pro'
|
consumerProguardFiles 'consumer-rules.pro'
|
||||||
@@ -34,13 +32,22 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
|
if (Boolean.valueOf(RELEASE)) {
|
||||||
|
implementation rootProject.ext.dependencies.mogomap
|
||||||
|
implementation rootProject.ext.dependencies.mogoutils
|
||||||
|
implementation rootProject.ext.dependencies.mogocommons
|
||||||
|
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||||
|
implementation rootProject.ext.dependencies.modulecommon
|
||||||
|
} else {
|
||||||
implementation project(":libraries:mogo-map")
|
implementation project(":libraries:mogo-map")
|
||||||
implementation project(":foudations:mogo-utils")
|
implementation project(":foudations:mogo-utils")
|
||||||
api project(":foudations:mogo-commons")
|
api project(":foudations:mogo-commons")
|
||||||
implementation project(':services:mogo-service-api')
|
implementation project(':services:mogo-service-api')
|
||||||
implementation project(':modules:mogo-module-common')
|
implementation project(':modules:mogo-module-common')
|
||||||
|
}
|
||||||
implementation rootProject.ext.dependencies.androidxappcompat
|
implementation rootProject.ext.dependencies.androidxappcompat
|
||||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||||
implementation rootProject.ext.dependencies.arouter
|
implementation rootProject.ext.dependencies.arouter
|
||||||
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
||||||
}
|
}
|
||||||
|
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||||
|
|||||||
3
demo/demo-module-map/gradle.properties
Normal file
3
demo/demo-module-map/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
GROUP=com.mogo.module
|
||||||
|
POM_ARTIFACT_ID=module-demo
|
||||||
|
VERSION_CODE=1
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
package com.mogo.demo.module.map;
|
package com.mogo.demo.module.map;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@@ -38,6 +35,7 @@ import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
|
|||||||
import com.mogo.map.uicontroller.EnumMapUI;
|
import com.mogo.map.uicontroller.EnumMapUI;
|
||||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||||
import com.mogo.service.MogoServicePaths;
|
import com.mogo.service.MogoServicePaths;
|
||||||
|
import com.mogo.service.imageloader.IMogoImageloader;
|
||||||
import com.mogo.service.map.IMogoMapService;
|
import com.mogo.service.map.IMogoMapService;
|
||||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||||
import com.mogo.utils.TipToast;
|
import com.mogo.utils.TipToast;
|
||||||
@@ -84,6 +82,9 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|||||||
private IMogoMapUIController mMapUIController;
|
private IMogoMapUIController mMapUIController;
|
||||||
|
|
||||||
private DemoInfoWindowAdapter mDemoInfoWindowAdapter;
|
private DemoInfoWindowAdapter mDemoInfoWindowAdapter;
|
||||||
|
private MogoLocation mLocation;
|
||||||
|
|
||||||
|
private IMogoImageloader mImageloader;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutId() {
|
protected int getLayoutId() {
|
||||||
@@ -96,10 +97,11 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|||||||
mNaviMode = findViewById( R.id.demo_module_id_navi_mode );
|
mNaviMode = findViewById( R.id.demo_module_id_navi_mode );
|
||||||
|
|
||||||
mMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( getContext() );
|
mMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( getContext() );
|
||||||
|
mImageloader = ( IMogoImageloader ) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_IMAGE_LOADER ).navigation( getContext() );
|
||||||
mPoiSearch = mMapService.getPoiSearch( getContext(), new MogoPoiSearchQuery() );
|
mPoiSearch = mMapService.getPoiSearch( getContext(), new MogoPoiSearchQuery() );
|
||||||
mPoiSearch.setPoiSearchListener( this );
|
mPoiSearch.setPoiSearchListener( this );
|
||||||
mLocationClient = mMapService.getSingletonLocationClient( getContext() );
|
mLocationClient = mMapService.getLocationClient( getContext() );
|
||||||
mLocationClient.addLocationListener( this );
|
mLocation = mLocationClient.getLastKnowLocation();
|
||||||
mMarkerManager = mMapService.getMarkerManager( getContext() );
|
mMarkerManager = mMapService.getMarkerManager( getContext() );
|
||||||
mNavi = mMapService.getNavi( getContext() );
|
mNavi = mMapService.getNavi( getContext() );
|
||||||
mMapUIController = mMapService.getMapUIController();
|
mMapUIController = mMapService.getMapUIController();
|
||||||
@@ -112,12 +114,12 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|||||||
new View.OnClickListener() {
|
new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick( View v ) {
|
public void onClick( View v ) {
|
||||||
mLocationClient.start( 1_000L );
|
mLocationClient.start( 4_000L );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
mDemoInfoWindowAdapter = new DemoInfoWindowAdapter( getContext(), mNavi );
|
mDemoInfoWindowAdapter = new DemoInfoWindowAdapter( getContext(), mNavi, mImageloader );
|
||||||
|
|
||||||
mMarkerIcon = BitmapFactory.decodeResource( getResources(), R.drawable.ic_search_poi_location );
|
mMarkerIcon = BitmapFactory.decodeResource( getResources(), R.drawable.ic_search_poi_location );
|
||||||
mClickedMarkerIcon = BitmapFactory.decodeResource( getResources(), R.drawable.ic_search_choice_point );
|
mClickedMarkerIcon = BitmapFactory.decodeResource( getResources(), R.drawable.ic_search_choice_point );
|
||||||
@@ -128,6 +130,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|||||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||||
.icon( mMarkerIcon )
|
.icon( mMarkerIcon )
|
||||||
.latitude( 39.974525d )
|
.latitude( 39.974525d )
|
||||||
|
.owner( DemoConstants.TAG )
|
||||||
.longitude( 116.41733d );
|
.longitude( 116.41733d );
|
||||||
IMogoMarker marker = mMarkerManager.addMarker( DemoConstants.TAG, options );
|
IMogoMarker marker = mMarkerManager.addMarker( DemoConstants.TAG, options );
|
||||||
marker.setInfoWindowAdapter( mDemoInfoWindowAdapter );
|
marker.setInfoWindowAdapter( mDemoInfoWindowAdapter );
|
||||||
@@ -142,9 +145,14 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|||||||
ArrayList< MogoMarkerOptions > optionsList = new ArrayList<>();
|
ArrayList< MogoMarkerOptions > optionsList = new ArrayList<>();
|
||||||
for ( int i = 0; i < 10; i++ ) {
|
for ( int i = 0; i < 10; i++ ) {
|
||||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||||
.icon( mMarkerIcon )
|
.owner( DemoConstants.TAG )
|
||||||
.latitude( 39.974525d + new Random().nextDouble() )
|
.latitude( 39.974525d + new Random().nextDouble() )
|
||||||
.longitude( 116.41733d + new Random().nextDouble() );
|
.longitude( 116.41733d + new Random().nextDouble() );
|
||||||
|
if ( i % 2 == 0 ) {
|
||||||
|
options.icon( mMarkerIcon );
|
||||||
|
} else {
|
||||||
|
options.icon( mDemoInfoWindowAdapter.getMarkerView( options ) );
|
||||||
|
}
|
||||||
optionsList.add( options );
|
optionsList.add( options );
|
||||||
}
|
}
|
||||||
List< IMogoMarker > iMogoMarkers = mMarkerManager.addMarkers( DemoConstants.TAG, optionsList, true );
|
List< IMogoMarker > iMogoMarkers = mMarkerManager.addMarkers( DemoConstants.TAG, optionsList, true );
|
||||||
@@ -176,7 +184,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|||||||
findViewById( R.id.demo_module_id_current ).setOnClickListener( new View.OnClickListener() {
|
findViewById( R.id.demo_module_id_current ).setOnClickListener( new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick( View v ) {
|
public void onClick( View v ) {
|
||||||
mMapUIController.moveToCurrentLocation();
|
mMapUIController.moveToCenter( new MogoLatLng( mLocation.getLatitude(), mLocation.getLongitude() ) );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
@@ -251,6 +259,14 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|||||||
mMapUIController.recoverLockMode();
|
mMapUIController.recoverLockMode();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
mLocationClient.addLocationListener( new IMogoLocationListener() {
|
||||||
|
@Override
|
||||||
|
public void onLocationChanged( MogoLocation location ) {
|
||||||
|
mLocation = location;
|
||||||
|
Logger.d( TAG, "demo模块定位,定位间隔4s" );
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -261,13 +277,13 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMarkerClicked( IMogoMarker marker ) {
|
public boolean onMarkerClicked( IMogoMarker marker ) {
|
||||||
if ( mLastClickedMarker != null ) {
|
// if ( mLastClickedMarker != null ) {
|
||||||
mLastClickedMarker.setIcon( this.mMarkerIcon );
|
// mLastClickedMarker.setIcon( this.mMarkerIcon );
|
||||||
}
|
// }
|
||||||
marker.setIcon( mClickedMarkerIcon );
|
// marker.setIcon( mClickedMarkerIcon );
|
||||||
mLastClickedMarker = marker;
|
// mLastClickedMarker = marker;
|
||||||
|
|
||||||
marker.showInfoWindow();
|
// marker.showInfoWindow();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,12 +296,12 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPerform() {
|
public void onPerform() {
|
||||||
TipToast.shortTip( "卡片有效" );
|
Logger.d( TAG, "卡片demo有效" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
TipToast.shortTip( "卡片无效" );
|
Logger.d( TAG, "卡片demo无效" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -335,8 +351,8 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLocationChanged( MogoLocation location ) {
|
public void onLocationChanged( MogoLocation location ) {
|
||||||
mLocationClient.stop();
|
mLocation = location;
|
||||||
Logger.i( TAG, location.toString() );
|
Logger.i( TAG, "接受到的地图模块定位信息" );
|
||||||
if ( mLocInfo != null ) {
|
if ( mLocInfo != null ) {
|
||||||
if ( location.getErrCode() == 0 ) {
|
if ( location.getErrCode() == 0 ) {
|
||||||
mLocInfo.setText( "当前位置:" + location.getAddress() );
|
mLocInfo.setText( "当前位置:" + location.getAddress() );
|
||||||
@@ -363,6 +379,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
|
Logger.w( TAG, "onDestroyView" );
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
getViewLifecycleOwner().getLifecycle().removeObserver( mPresenter );
|
getViewLifecycleOwner().getLifecycle().removeObserver( mPresenter );
|
||||||
mLocationClient.removeLocationListener( this );
|
mLocationClient.removeLocationListener( this );
|
||||||
|
|||||||
@@ -2,16 +2,28 @@ package com.mogo.demo.module.map;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||||
|
import com.mogo.map.MogoLatLng;
|
||||||
import com.mogo.map.listener.IMogoMapListener;
|
import com.mogo.map.listener.IMogoMapListener;
|
||||||
|
import com.mogo.map.location.IMogoLocationListener;
|
||||||
|
import com.mogo.map.location.MogoLocation;
|
||||||
|
import com.mogo.map.marker.IMogoMarker;
|
||||||
|
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||||
|
import com.mogo.map.model.MogoPoi;
|
||||||
import com.mogo.map.navi.IMogoNaviListener;
|
import com.mogo.map.navi.IMogoNaviListener;
|
||||||
|
import com.mogo.map.search.geo.MogoPoiItem;
|
||||||
|
import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
|
||||||
|
import com.mogo.map.search.poisearch.MogoPoiResult;
|
||||||
|
import com.mogo.map.uicontroller.EnumMapUI;
|
||||||
import com.mogo.module.common.MogoModulePaths;
|
import com.mogo.module.common.MogoModulePaths;
|
||||||
import com.mogo.service.module.IMogoModuleLifecycle;
|
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||||
import com.mogo.service.module.IMogoModuleProvider;
|
import com.mogo.service.module.IMogoModuleProvider;
|
||||||
|
import com.mogo.utils.logger.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author congtaowang
|
* @author congtaowang
|
||||||
@@ -22,12 +34,15 @@ import com.mogo.service.module.IMogoModuleProvider;
|
|||||||
@Route( path = MogoModulePaths.PATH_MODULE_DEMO )
|
@Route( path = MogoModulePaths.PATH_MODULE_DEMO )
|
||||||
public class DemoCardViewProvider implements IMogoModuleProvider {
|
public class DemoCardViewProvider implements IMogoModuleProvider {
|
||||||
|
|
||||||
|
private static final String TAG = "DemoCardViewProvider";
|
||||||
|
|
||||||
private DemoCardViewFragment fragment;
|
private DemoCardViewFragment fragment;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Fragment createFragment( Context context, Bundle data ) {
|
public Fragment createFragment( Context context, Bundle data ) {
|
||||||
fragment = new DemoCardViewFragment();
|
fragment = new DemoCardViewFragment();
|
||||||
fragment.setArguments( data );
|
fragment.setArguments( data );
|
||||||
|
Logger.i( TAG, "createFragment" );
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,22 +56,12 @@ public class DemoCardViewProvider implements IMogoModuleProvider {
|
|||||||
return DemoConstants.TAG;
|
return DemoConstants.TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IMogoModuleLifecycle getCardLifecycle() {
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View createView( Context context ) {
|
public View createView( Context context ) {
|
||||||
// don't
|
// don't
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IMogoMapListener getMapListener() {
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return IMogoModuleProvider.TYPE_FRAGMENT;
|
return IMogoModuleProvider.TYPE_FRAGMENT;
|
||||||
@@ -66,4 +71,20 @@ public class DemoCardViewProvider implements IMogoModuleProvider {
|
|||||||
public IMogoNaviListener getNaviListener() {
|
public IMogoNaviListener getNaviListener() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMogoModuleLifecycle getCardLifecycle() {
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMogoMapListener getMapListener() {
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMogoLocationListener getLocationListener() {
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.mogo.demo.module.map;
|
package com.mogo.demo.module.map;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@@ -8,9 +9,16 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.mogo.map.marker.IMogoInfoWindowAdapter;
|
import com.mogo.map.marker.IMogoInfoWindowAdapter;
|
||||||
import com.mogo.map.marker.IMogoMarker;
|
import com.mogo.map.marker.IMogoMarker;
|
||||||
|
import com.mogo.map.marker.MogoMarkerOptions;
|
||||||
import com.mogo.map.navi.IMogoNavi;
|
import com.mogo.map.navi.IMogoNavi;
|
||||||
import com.mogo.map.navi.MogoNaviConfig;
|
import com.mogo.map.navi.MogoNaviConfig;
|
||||||
import com.mogo.map.search.geo.MogoPoiItem;
|
import com.mogo.map.search.geo.MogoPoiItem;
|
||||||
|
import com.mogo.service.imageloader.IMogoImageLoaderListener;
|
||||||
|
import com.mogo.service.imageloader.IMogoImageloader;
|
||||||
|
import com.mogo.service.imageloader.MogoImageView;
|
||||||
|
import com.mogo.utils.WindowUtils;
|
||||||
|
import com.mogo.utils.logger.Logger;
|
||||||
|
import com.mogo.utils.network.utils.Util;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -23,12 +31,16 @@ import java.util.Date;
|
|||||||
*/
|
*/
|
||||||
public class DemoInfoWindowAdapter implements IMogoInfoWindowAdapter {
|
public class DemoInfoWindowAdapter implements IMogoInfoWindowAdapter {
|
||||||
|
|
||||||
|
private static final String TAG = "DemoInfoWindowAdapter";
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private IMogoNavi mNavi;
|
private IMogoNavi mNavi;
|
||||||
|
private IMogoImageloader mImageloader;
|
||||||
|
|
||||||
public DemoInfoWindowAdapter( Context mContext, IMogoNavi mNavi ) {
|
public DemoInfoWindowAdapter( Context mContext, IMogoNavi mNavi, IMogoImageloader iMogoImageloader ) {
|
||||||
this.mContext = mContext;
|
this.mContext = mContext;
|
||||||
this.mNavi = mNavi;
|
this.mNavi = mNavi;
|
||||||
|
this.mImageloader = iMogoImageloader;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -90,5 +102,31 @@ public class DemoInfoWindowAdapter implements IMogoInfoWindowAdapter {
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public View getMarkerView( final MogoMarkerOptions options ) {
|
||||||
|
final View view = LayoutInflater.from( mContext ).inflate( R.layout.demo_module_demo_bubble_marker, null );
|
||||||
|
final MogoImageView icon = view.findViewById( R.id.icon );
|
||||||
|
mImageloader.displayImage( "http://imgnews.gmw.cn/attachement/jpg/site2/20191229/00d86176ed0b1f71f4580f.jpg", icon, WindowUtils.dip2px( mContext, 50 ), WindowUtils.dip2px( mContext, 50 ),
|
||||||
|
new IMogoImageLoaderListener() {
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCompleted( Bitmap bitmap ) {
|
||||||
|
// 刷新图标
|
||||||
|
Logger.d( TAG, "loaded." );
|
||||||
|
options.icon( view );
|
||||||
|
options.notifyObservers();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure( Exception e ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
return view;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="300dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="#ff0000">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
|
android:background="#ff0000"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -155,5 +150,3 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.mogo.service.imageloader.MogoImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:miv_placeHolder="@drawable/ic_amap_app_main_current_location_bkg"
|
||||||
|
app:miv_shape="circle" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_search_poi_location"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/icon" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
1
demo/demo-module-map2/.gitignore
vendored
Normal file
1
demo/demo-module-map2/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
53
demo/demo-module-map2/build.gradle
Normal file
53
demo/demo-module-map2/build.gradle
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
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")
|
||||||
|
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
consumerProguardFiles 'consumer-rules.pro'
|
||||||
|
|
||||||
|
javaCompileOptions {
|
||||||
|
annotationProcessorOptions {
|
||||||
|
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
|
if (Boolean.valueOf(RELEASE)) {
|
||||||
|
implementation rootProject.ext.dependencies.mogomap
|
||||||
|
implementation rootProject.ext.dependencies.mogoutils
|
||||||
|
implementation rootProject.ext.dependencies.mogocommons
|
||||||
|
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||||
|
implementation rootProject.ext.dependencies.modulecommon
|
||||||
|
} else {
|
||||||
|
implementation project(":libraries:mogo-map")
|
||||||
|
implementation project(":foudations:mogo-utils")
|
||||||
|
api project(":foudations:mogo-commons")
|
||||||
|
implementation project(':services:mogo-service-api')
|
||||||
|
implementation project(':modules:mogo-module-common')
|
||||||
|
}
|
||||||
|
implementation rootProject.ext.dependencies.androidxappcompat
|
||||||
|
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||||
|
implementation rootProject.ext.dependencies.arouter
|
||||||
|
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
||||||
|
}
|
||||||
|
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||||
0
demo/demo-module-map2/consumer-rules.pro
Normal file
0
demo/demo-module-map2/consumer-rules.pro
Normal file
3
demo/demo-module-map2/gradle.properties
Normal file
3
demo/demo-module-map2/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
GROUP=com.mogo.module
|
||||||
|
POM_ARTIFACT_ID=module-demo2
|
||||||
|
VERSION_CODE=1
|
||||||
21
demo/demo-module-map2/proguard-rules.pro
vendored
Normal file
21
demo/demo-module-map2/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,27 @@
|
|||||||
|
package com.mogo.demo.module.map2;
|
||||||
|
|
||||||
|
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.demo.module.map2.test", appContext.getPackageName() );
|
||||||
|
}
|
||||||
|
}
|
||||||
2
demo/demo-module-map2/src/main/AndroidManifest.xml
Normal file
2
demo/demo-module-map2/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.mogo.demo.module.map2" />
|
||||||
@@ -0,0 +1,397 @@
|
|||||||
|
package com.mogo.demo.module.map2;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
|
import com.mogo.commons.mvp.IView;
|
||||||
|
import com.mogo.commons.mvp.MvpFragment;
|
||||||
|
import com.mogo.commons.mvp.Presenter;
|
||||||
|
import com.mogo.map.MogoLatLng;
|
||||||
|
import com.mogo.map.listener.IMogoMapListener;
|
||||||
|
import com.mogo.map.location.IMogoLocationClient;
|
||||||
|
import com.mogo.map.location.IMogoLocationListener;
|
||||||
|
import com.mogo.map.location.MogoLocation;
|
||||||
|
import com.mogo.map.marker.IMogoMarker;
|
||||||
|
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||||
|
import com.mogo.map.marker.IMogoMarkerManager;
|
||||||
|
import com.mogo.map.marker.MogoMarkerOptions;
|
||||||
|
import com.mogo.map.model.MogoPoi;
|
||||||
|
import com.mogo.map.navi.IMogoNavi;
|
||||||
|
import com.mogo.map.search.geo.MogoPoiItem;
|
||||||
|
import com.mogo.map.search.poisearch.IMogoPoiSearch;
|
||||||
|
import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
|
||||||
|
import com.mogo.map.search.poisearch.MogoPoiResult;
|
||||||
|
import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
|
||||||
|
import com.mogo.map.uicontroller.EnumMapUI;
|
||||||
|
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||||
|
import com.mogo.service.MogoServicePaths;
|
||||||
|
import com.mogo.service.imageloader.IMogoImageloader;
|
||||||
|
import com.mogo.service.map.IMogoMapService;
|
||||||
|
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||||
|
import com.mogo.utils.TipToast;
|
||||||
|
import com.mogo.utils.logger.Logger;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-24
|
||||||
|
* <p>
|
||||||
|
* 描述:demo测试各种接口
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class Demo2CardViewFragment extends MvpFragment< IView, Presenter< IView > >
|
||||||
|
implements IView,
|
||||||
|
IMogoMarkerClickListener,
|
||||||
|
IMogoModuleLifecycle,
|
||||||
|
IMogoMapListener,
|
||||||
|
IMogoPoiSearchListener,
|
||||||
|
IMogoLocationListener {
|
||||||
|
|
||||||
|
private static final String TAG = "demo.Demo2CardViewProvider";
|
||||||
|
|
||||||
|
private Button mAddMarker;
|
||||||
|
private Button mAddMarkers;
|
||||||
|
|
||||||
|
private Bitmap mMarkerIcon;
|
||||||
|
private Bitmap mClickedMarkerIcon;
|
||||||
|
private TextView mLocInfo;
|
||||||
|
private TextView mLoc;
|
||||||
|
private Button m2D3D;
|
||||||
|
private CheckBox mNaviMode;
|
||||||
|
|
||||||
|
private IMogoMarker mLastClickedMarker;
|
||||||
|
|
||||||
|
private IMogoMapService mMapService;
|
||||||
|
private IMogoPoiSearch mPoiSearch;
|
||||||
|
private IMogoLocationClient mLocationClient;
|
||||||
|
private IMogoMarkerManager mMarkerManager;
|
||||||
|
private IMogoNavi mNavi;
|
||||||
|
private IMogoMapUIController mMapUIController;
|
||||||
|
|
||||||
|
private Demo2InfoWindowAdapter mDemoInfoWindowAdapter;
|
||||||
|
private MogoLocation mLocation;
|
||||||
|
|
||||||
|
private IMogoImageloader mImageloader;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLayoutId() {
|
||||||
|
return R.layout.demo2_module_card_view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initViews() {
|
||||||
|
|
||||||
|
mNaviMode = findViewById( R.id.demo_module_id_navi_mode );
|
||||||
|
|
||||||
|
mMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( getContext() );
|
||||||
|
mImageloader = ( IMogoImageloader ) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_IMAGE_LOADER ).navigation( getContext() );
|
||||||
|
mPoiSearch = mMapService.getPoiSearch( getContext(), new MogoPoiSearchQuery() );
|
||||||
|
mPoiSearch.setPoiSearchListener( this );
|
||||||
|
mLocationClient = mMapService.getLocationClient( getContext() );
|
||||||
|
mLocation = mLocationClient.getLastKnowLocation();
|
||||||
|
mMarkerManager = mMapService.getMarkerManager( getContext() );
|
||||||
|
mNavi = mMapService.getNavi( getContext() );
|
||||||
|
mMapUIController = mMapService.getMapUIController();
|
||||||
|
|
||||||
|
m2D3D = findViewById( R.id.demo_module_id_2d3d );
|
||||||
|
|
||||||
|
mLocInfo = findViewById( R.id.demo_module_id_loc_info );
|
||||||
|
mLoc = findViewById( R.id.demo_module_id_loc );
|
||||||
|
mLoc.setOnClickListener(
|
||||||
|
new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
mLocationClient.start( 4_000L );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
mDemoInfoWindowAdapter = new Demo2InfoWindowAdapter( getContext(), mNavi, mImageloader );
|
||||||
|
|
||||||
|
mMarkerIcon = BitmapFactory.decodeResource( getResources(), R.drawable.ic_search_poi_location );
|
||||||
|
mClickedMarkerIcon = BitmapFactory.decodeResource( getResources(), R.drawable.ic_search_choice_point );
|
||||||
|
mAddMarker = findViewById( R.id.demo_module_id_add_marker );
|
||||||
|
mAddMarker.setOnClickListener( new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||||
|
.icon( mMarkerIcon )
|
||||||
|
.latitude( 39.974525d )
|
||||||
|
.owner( Demo2Constants.TAG )
|
||||||
|
.longitude( 116.41733d );
|
||||||
|
IMogoMarker marker = mMarkerManager.addMarker( Demo2Constants.TAG, options );
|
||||||
|
marker.setInfoWindowAdapter( mDemoInfoWindowAdapter );
|
||||||
|
marker.setOnMarkerClickListener( Demo2CardViewFragment.this );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
mAddMarkers = findViewById( R.id.demo_module_id_add_markers );
|
||||||
|
mAddMarkers.setOnClickListener( new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
|
||||||
|
ArrayList< MogoMarkerOptions > optionsList = new ArrayList<>();
|
||||||
|
for ( int i = 0; i < 10; i++ ) {
|
||||||
|
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||||
|
.owner( Demo2Constants.TAG )
|
||||||
|
.latitude( 39.974525d + new Random().nextDouble() )
|
||||||
|
.longitude( 116.41733d + new Random().nextDouble() );
|
||||||
|
if ( i % 2 == 0 ) {
|
||||||
|
options.icon( mMarkerIcon );
|
||||||
|
} else {
|
||||||
|
options.icon( mDemoInfoWindowAdapter.getMarkerView( options ) );
|
||||||
|
}
|
||||||
|
optionsList.add( options );
|
||||||
|
}
|
||||||
|
List< IMogoMarker > iMogoMarkers = mMarkerManager.addMarkers( Demo2Constants.TAG, optionsList, true );
|
||||||
|
for ( IMogoMarker iMogoMarker : iMogoMarkers ) {
|
||||||
|
iMogoMarker.setInfoWindowAdapter( mDemoInfoWindowAdapter );
|
||||||
|
iMogoMarker.setOnMarkerClickListener( Demo2CardViewFragment.this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
findViewById( R.id.demo_module_id_clear ).setOnClickListener( new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
mMarkerManager.removeMarkers( Demo2Constants.TAG );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
m2D3D.setOnClickListener( new View.OnClickListener() {
|
||||||
|
|
||||||
|
private EnumMapUI ui = EnumMapUI.NorthUP_2D;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
mMapUIController.changeMapMode( ui = ui.next() );
|
||||||
|
m2D3D.setText( ui.toString() );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
findViewById( R.id.demo_module_id_current ).setOnClickListener( new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
mMapUIController.moveToCenter( new MogoLatLng( mLocation.getLatitude(), mLocation.getLongitude() ) );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
findViewById( R.id.demo_module_id_start_navi ).setOnClickListener( new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
mNavi.startNavi( !mNaviMode.isChecked() );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
findViewById( R.id.demo_module_id_stop_navi ).setOnClickListener( new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
mNavi.stopNavi();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
findViewById( R.id.demo_module_id_traffic ).setOnClickListener( new View.OnClickListener() {
|
||||||
|
|
||||||
|
private boolean enable = true;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
mMapUIController.setTrafficEnabled( enable = !enable );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
findViewById( R.id.demo_module_id_zoom_in ).setOnClickListener( new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
mMapUIController.changeZoom( true );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
findViewById( R.id.demo_module_id_zoom_out ).setOnClickListener( new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
mMapUIController.changeZoom( false );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
findViewById( R.id.demo_module_id_day_light ).setOnClickListener( new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
mMapUIController.changeMapMode( EnumMapUI.Type_Light );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
findViewById( R.id.demo_module_id_day_night ).setOnClickListener( new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
mMapUIController.changeMapMode( EnumMapUI.Type_Night );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
findViewById( R.id.demo_module_id_display_overlay ).setOnClickListener( new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
mMapUIController.displayOverview();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
findViewById( R.id.demo_module_id_reverse_lock ).setOnClickListener( new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
mMapUIController.recoverLockMode();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
mLocationClient.addLocationListener( new IMogoLocationListener() {
|
||||||
|
@Override
|
||||||
|
public void onLocationChanged( MogoLocation location ) {
|
||||||
|
mLocation = location;
|
||||||
|
Logger.d( TAG, "demo模块定位,定位间隔4s" );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||||
|
super.onActivityCreated( savedInstanceState );
|
||||||
|
getViewLifecycleOwner().getLifecycle().addObserver( mPresenter );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onMarkerClicked( IMogoMarker marker ) {
|
||||||
|
// if ( mLastClickedMarker != null ) {
|
||||||
|
// mLastClickedMarker.setIcon( this.mMarkerIcon );
|
||||||
|
// }
|
||||||
|
// marker.setIcon( mClickedMarkerIcon );
|
||||||
|
// mLastClickedMarker = marker;
|
||||||
|
|
||||||
|
// marker.showInfoWindow();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
protected Presenter createPresenter() {
|
||||||
|
return new Presenter( this ) {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPerform() {
|
||||||
|
Logger.d( TAG, "卡片2有效" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
Logger.d( TAG, "卡片2无效" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMapLoaded() {
|
||||||
|
Logger.d( TAG, "地图加载事件" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTouch( MotionEvent motionEvent ) {
|
||||||
|
// Logger.d( TAG, "地图触摸事件" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPOIClick( MogoPoi poi ) {
|
||||||
|
if ( poi != null ) {
|
||||||
|
TipToast.shortTip( poi.getName() );
|
||||||
|
}
|
||||||
|
mPoiSearch.searchPOIIdAsyn( poi.getPoiId() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPoiSearched( MogoPoiResult result, int errorCode ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private IMogoMarker mPoiMarker;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPoiItemSearched( MogoPoiItem item, int errorCode ) {
|
||||||
|
if ( item == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( mPoiMarker != null ) {
|
||||||
|
mPoiMarker.destroy();
|
||||||
|
}
|
||||||
|
mPoiMarker = mMarkerManager.addMarker( Demo2Constants.TAG, new MogoMarkerOptions()
|
||||||
|
.longitude( item.getPoint().lng )
|
||||||
|
.latitude( item.getPoint().lat )
|
||||||
|
.icon( mMarkerIcon ) );
|
||||||
|
if ( mPoiMarker != null ) {
|
||||||
|
mPoiMarker.setInfoWindowAdapter( mDemoInfoWindowAdapter );
|
||||||
|
mPoiMarker.setObject( item );
|
||||||
|
mPoiMarker.showInfoWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLocationChanged( MogoLocation location ) {
|
||||||
|
mLocation = location;
|
||||||
|
Logger.i( TAG, "接受到的地图模块定位信息" );
|
||||||
|
if ( mLocInfo != null ) {
|
||||||
|
if ( location.getErrCode() == 0 ) {
|
||||||
|
mLocInfo.setText( "当前位置:" + location.getAddress() );
|
||||||
|
} else {
|
||||||
|
mLocInfo.setText( location.getErrInfo() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMapClick( MogoLatLng latLng ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLockMap( boolean isLock ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMapModeChanged( EnumMapUI ui ) {
|
||||||
|
Logger.d( TAG, ui.name() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
Logger.w( TAG, "onDestroyView" );
|
||||||
|
super.onDestroyView();
|
||||||
|
getViewLifecycleOwner().getLifecycle().removeObserver( mPresenter );
|
||||||
|
mLocationClient.removeLocationListener( this );
|
||||||
|
if ( mLastClickedMarker != null ) {
|
||||||
|
mLastClickedMarker.destroy();
|
||||||
|
mLastClickedMarker = null;
|
||||||
|
}
|
||||||
|
if ( mPoiSearch != null ) {
|
||||||
|
mPoiSearch.destroy();
|
||||||
|
}
|
||||||
|
mMapService = null;
|
||||||
|
mPoiSearch = null;
|
||||||
|
mLocationClient = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package com.mogo.demo.module.map2;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
|
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||||
|
import com.mogo.map.listener.IMogoMapListener;
|
||||||
|
import com.mogo.map.location.IMogoLocationListener;
|
||||||
|
import com.mogo.map.navi.IMogoNaviListener;
|
||||||
|
import com.mogo.module.common.MogoModulePaths;
|
||||||
|
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||||
|
import com.mogo.service.module.IMogoModuleProvider;
|
||||||
|
import com.mogo.utils.logger.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-24
|
||||||
|
* <p>
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
@Route( path = MogoModulePaths.PATH_MODULE_DEMO2 )
|
||||||
|
public class Demo2CardViewProvider implements IMogoModuleProvider {
|
||||||
|
|
||||||
|
private static final String TAG = "Demo2CardViewProvider";
|
||||||
|
|
||||||
|
private Demo2CardViewFragment fragment;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fragment createFragment( Context context, Bundle data ) {
|
||||||
|
fragment = new Demo2CardViewFragment();
|
||||||
|
fragment.setArguments( data );
|
||||||
|
Logger.i( TAG, "createFragment" );
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init( Context context ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModuleName() {
|
||||||
|
return Demo2Constants.TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMogoModuleLifecycle getCardLifecycle() {
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View createView( Context context ) {
|
||||||
|
// don't
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMogoMapListener getMapListener() {
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return IMogoModuleProvider.TYPE_FRAGMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMogoNaviListener getNaviListener() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMogoLocationListener getLocationListener() {
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.mogo.demo.module.map2;
|
||||||
|
|
||||||
|
import com.mogo.module.common.MogoModulePaths;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-24
|
||||||
|
* <p>
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
public class Demo2Constants {
|
||||||
|
|
||||||
|
public static final String TAG = MogoModulePaths.PATH_MODULE_DEMO2;
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
package com.mogo.demo.module.map2;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.mogo.map.marker.IMogoInfoWindowAdapter;
|
||||||
|
import com.mogo.map.marker.IMogoMarker;
|
||||||
|
import com.mogo.map.marker.MogoMarkerOptions;
|
||||||
|
import com.mogo.map.navi.IMogoNavi;
|
||||||
|
import com.mogo.map.navi.MogoNaviConfig;
|
||||||
|
import com.mogo.map.search.geo.MogoPoiItem;
|
||||||
|
import com.mogo.service.imageloader.IMogoImageLoaderListener;
|
||||||
|
import com.mogo.service.imageloader.IMogoImageloader;
|
||||||
|
import com.mogo.service.imageloader.MogoImageView;
|
||||||
|
import com.mogo.utils.WindowUtils;
|
||||||
|
import com.mogo.utils.logger.Logger;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-24
|
||||||
|
* <p>
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
public class Demo2InfoWindowAdapter implements IMogoInfoWindowAdapter {
|
||||||
|
|
||||||
|
private static final String TAG = "DemoInfoWindowAdapter";
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private IMogoNavi mNavi;
|
||||||
|
private IMogoImageloader mImageloader;
|
||||||
|
|
||||||
|
public Demo2InfoWindowAdapter( Context mContext, IMogoNavi mNavi, IMogoImageloader iMogoImageloader ) {
|
||||||
|
this.mContext = mContext;
|
||||||
|
this.mNavi = mNavi;
|
||||||
|
this.mImageloader = iMogoImageloader;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getInfoWindow( IMogoMarker marker ) {
|
||||||
|
if ( marker.getObject() instanceof MogoPoiItem ) {
|
||||||
|
View view = LayoutInflater.from( mContext ).inflate( R.layout.demo2_module_demo_poi_info_window, null );
|
||||||
|
renderPoiVew( view, marker, ( ( MogoPoiItem ) marker.getObject() ) );
|
||||||
|
return view;
|
||||||
|
} else {
|
||||||
|
View view = LayoutInflater.from( mContext ).inflate( R.layout.demo2_module_demo_info_window, null );
|
||||||
|
renderView( view, marker );
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderView( View view, final IMogoMarker marker ) {
|
||||||
|
final TextView time = view.findViewById( R.id.demo_module_id_iw_time );
|
||||||
|
Button refresh = view.findViewById( R.id.demo_module_id_iw_refresh );
|
||||||
|
time.setText( new SimpleDateFormat( "yyyyMMdd HHMMSS" ).format( new Date() ) );
|
||||||
|
refresh.setOnClickListener( new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
marker.showInfoWindow();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
Button navi2 = view.findViewById( R.id.demo_module_id_iw_navito );
|
||||||
|
navi2.setOnClickListener( new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
if ( mNavi != null ) {
|
||||||
|
mNavi.naviTo( marker.getPosition(), new MogoNaviConfig() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
Button stopNavi = view.findViewById( R.id.demo_module_id_iw_navi_stop );
|
||||||
|
stopNavi.setOnClickListener( new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
if ( mNavi != null ) {
|
||||||
|
mNavi.stopNavi();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderPoiVew( View view, final IMogoMarker marker, MogoPoiItem item ) {
|
||||||
|
final TextView time = view.findViewById( R.id.demo_module_id_iw_poi_title );
|
||||||
|
time.setText( item.getTitle() );
|
||||||
|
Button navi2 = view.findViewById( R.id.demo_module_id_iw_poi_navito );
|
||||||
|
navi2.setOnClickListener( new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick( View v ) {
|
||||||
|
if ( mNavi != null ) {
|
||||||
|
mNavi.naviTo( marker.getPosition(), new MogoNaviConfig() );
|
||||||
|
}
|
||||||
|
marker.hideInfoWindow();
|
||||||
|
marker.remove();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
public View getMarkerView( final MogoMarkerOptions options ) {
|
||||||
|
final View view = LayoutInflater.from( mContext ).inflate( R.layout.demo2_module_demo_bubble_marker, null );
|
||||||
|
final MogoImageView icon = view.findViewById( R.id.icon );
|
||||||
|
mImageloader.displayImage( "http://imgnews.gmw.cn/attachement/jpg/site2/20191229/00d86176ed0b1f71f4580f.jpg", icon, WindowUtils.dip2px( mContext, 50 ), WindowUtils.dip2px( mContext, 50 ),
|
||||||
|
new IMogoImageLoaderListener() {
|
||||||
|
@Override
|
||||||
|
public void onStart() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCompleted( Bitmap bitmap ) {
|
||||||
|
// 刷新图标
|
||||||
|
Logger.d( TAG, "loaded." );
|
||||||
|
options.icon( view );
|
||||||
|
options.notifyObservers();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure( Exception e ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="#ff0000"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/demo_module_id_loc_info"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_add_marker"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="添加一个覆盖物" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_add_markers"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="添加多个覆盖物" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_clear"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="清空覆盖物" />
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_loc"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="定位" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_current"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="当前位置" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_2d3d"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="2D/3D" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_traffic"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="交通态势" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_start_navi"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="开始导航" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_stop_navi"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="停止导航" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/demo_module_id_navi_mode"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="模拟导航" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_zoom_in"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="放大" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_zoom_out"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="缩小" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_day_light"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="白天" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_day_night"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="黑夜" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_display_overlay"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="全览" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_reverse_lock"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="继续导航" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.mogo.service.imageloader.MogoImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:miv_placeHolder="@drawable/ic_amap_app_main_current_location_bkg"
|
||||||
|
app:miv_shape="circle" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_search_poi_location"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/icon" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="#ff0000">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/demo_module_id_iw_time"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_iw_refresh"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:text="点击刷新当前时间"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_iw_navito"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="70dp"
|
||||||
|
android:text="导航去这里"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_iw_navi_stop"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="120dp"
|
||||||
|
android:text="停止导航"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="#ff0000">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/demo_module_id_iw_poi_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/demo_module_id_iw_poi_navito"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="70dp"
|
||||||
|
android:text="导航去这里"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
3
demo/demo-module-map2/src/main/res/values/strings.xml
Normal file
3
demo/demo-module-map2/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">demo-module-map2</string>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.mogo.demo.module.map2;
|
||||||
|
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
4
foudations/mogo-commons/apipackage.txt
Normal file
4
foudations/mogo-commons/apipackage.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
com.mogo.commons.mvp
|
||||||
|
com.mogo.commons.debug
|
||||||
|
com.mogo.commons.voice
|
||||||
|
com.mogo.commons.data
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||||
buildToolsVersion "29.0.2"
|
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||||
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 19
|
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||||
targetSdkVersion 29
|
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||||
versionCode 1
|
versionCode Integer.valueOf(VERSION_CODE)
|
||||||
versionName "1.0"
|
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
consumerProguardFiles 'consumer-rules.pro'
|
consumerProguardFiles 'consumer-rules.pro'
|
||||||
@@ -36,7 +34,13 @@ dependencies {
|
|||||||
api rootProject.ext.dependencies.aiassist
|
api rootProject.ext.dependencies.aiassist
|
||||||
api rootProject.ext.dependencies.androidxappcompat
|
api rootProject.ext.dependencies.androidxappcompat
|
||||||
api rootProject.ext.dependencies.analytics
|
api rootProject.ext.dependencies.analytics
|
||||||
implementation project(":foudations:mogo-utils")
|
|
||||||
implementation rootProject.ext.dependencies.arouter
|
implementation rootProject.ext.dependencies.arouter
|
||||||
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
||||||
|
if (Boolean.valueOf(RELEASE)) {
|
||||||
|
implementation rootProject.ext.dependencies.mogoutils
|
||||||
|
} else {
|
||||||
|
implementation project(":foudations:mogo-utils")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||||
3
foudations/mogo-commons/gradle.properties
Normal file
3
foudations/mogo-commons/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
GROUP=com.mogo.commons
|
||||||
|
POM_ARTIFACT_ID=mogo-commons
|
||||||
|
VERSION_CODE=1
|
||||||
@@ -4,16 +4,26 @@ package com.mogo.commons.debug;
|
|||||||
* @author congtaowang
|
* @author congtaowang
|
||||||
* @since 2019-12-23
|
* @since 2019-12-23
|
||||||
* <p>
|
* <p>
|
||||||
* 各个莫快递调试信息控制接口
|
* 各个模块递调试信息控制接口
|
||||||
*/
|
*/
|
||||||
public class DebugConfig {
|
public class DebugConfig {
|
||||||
|
|
||||||
private static boolean sDebug = true;
|
private static boolean sDebug = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为调试模式
|
||||||
|
*
|
||||||
|
* @return true - 调试模式 false - 非调试模式
|
||||||
|
*/
|
||||||
public static boolean isDebug() {
|
public static boolean isDebug() {
|
||||||
return sDebug;
|
return sDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置调试模式
|
||||||
|
*
|
||||||
|
* @param sDebug true - 调试模式 false - 非调试模式
|
||||||
|
*/
|
||||||
public static void setDebug( boolean sDebug ) {
|
public static void setDebug( boolean sDebug ) {
|
||||||
DebugConfig.sDebug = sDebug;
|
DebugConfig.sDebug = sDebug;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,10 @@ import android.content.Context;
|
|||||||
*/
|
*/
|
||||||
public interface IView {
|
public interface IView {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取上下文
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
Context getContext();
|
Context getContext();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public abstract class MvpActivity< V extends IView, P extends Presenter< V > >
|
|||||||
/**
|
/**
|
||||||
* 布局资源
|
* 布局资源
|
||||||
*
|
*
|
||||||
* @return
|
* @return 布局资源 id
|
||||||
*/
|
*/
|
||||||
protected abstract int getLayoutId();
|
protected abstract int getLayoutId();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
package com.mogo.commons.mvp;
|
package com.mogo.commons.mvp;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.PopupWindow;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.Lifecycle;
|
import androidx.lifecycle.Lifecycle;
|
||||||
import androidx.lifecycle.LifecycleObserver;
|
import androidx.lifecycle.LifecycleObserver;
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
@@ -14,7 +22,8 @@ import androidx.lifecycle.OnLifecycleEvent;
|
|||||||
*/
|
*/
|
||||||
public abstract class Presenter< V extends IView > implements LifecycleObserver {
|
public abstract class Presenter< V extends IView > implements LifecycleObserver {
|
||||||
|
|
||||||
private V mView;
|
protected V mView;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
public Presenter( V view ) {
|
public Presenter( V view ) {
|
||||||
this.mView = view;
|
this.mView = view;
|
||||||
@@ -49,4 +58,35 @@ public abstract class Presenter< V extends IView > implements LifecycleObserver
|
|||||||
@NonNull LifecycleOwner owner,
|
@NonNull LifecycleOwner owner,
|
||||||
@NonNull Lifecycle.Event event ) {
|
@NonNull Lifecycle.Event event ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Context getContext() {
|
||||||
|
if ( mContext != null ) {
|
||||||
|
return mContext;
|
||||||
|
}
|
||||||
|
if ( mView instanceof Activity ) {
|
||||||
|
mContext = ( ( Activity ) mView );
|
||||||
|
}
|
||||||
|
if ( mView instanceof Fragment ) {
|
||||||
|
mContext = ( ( Fragment ) mView ).getContext();
|
||||||
|
}
|
||||||
|
if ( mView instanceof android.app.Fragment ) {
|
||||||
|
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ) {
|
||||||
|
mContext = ( ( android.app.Fragment ) mView ).getContext();
|
||||||
|
} else {
|
||||||
|
mContext = ( ( android.app.Fragment ) mView ).getActivity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( mView instanceof Dialog ) {
|
||||||
|
mContext = ( ( Dialog ) mView ).getContext();
|
||||||
|
}
|
||||||
|
if ( mView instanceof PopupWindow ) {
|
||||||
|
if ( ( ( PopupWindow ) mView ).getContentView() != null ) {
|
||||||
|
mContext = ( ( PopupWindow ) mView ).getContentView().getContext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( mView instanceof View ) {
|
||||||
|
mContext = ( ( View ) mView ).getContext();
|
||||||
|
}
|
||||||
|
return mContext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||||
buildToolsVersion "29.0.2"
|
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||||
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 19
|
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||||
targetSdkVersion 29
|
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||||
versionCode 1
|
versionCode Integer.valueOf(VERSION_CODE)
|
||||||
versionName "1.0"
|
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
consumerProguardFiles 'consumer-rules.pro'
|
consumerProguardFiles 'consumer-rules.pro'
|
||||||
@@ -37,4 +35,11 @@ dependencies {
|
|||||||
api rootProject.ext.dependencies.retrofitconvertergson
|
api rootProject.ext.dependencies.retrofitconvertergson
|
||||||
api rootProject.ext.dependencies.retrofitconverterscalars
|
api rootProject.ext.dependencies.retrofitconverterscalars
|
||||||
implementation rootProject.ext.dependencies.androidxappcompat
|
implementation rootProject.ext.dependencies.androidxappcompat
|
||||||
|
if (Boolean.valueOf(RELEASE)) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||||
|
|||||||
3
foudations/mogo-utils/gradle.properties
Normal file
3
foudations/mogo-utils/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
GROUP=com.mogo.commons
|
||||||
|
POM_ARTIFACT_ID=mogo-utils
|
||||||
|
VERSION_CODE=1
|
||||||
@@ -17,4 +17,24 @@ org.gradle.jvmargs=-Xmx1536m
|
|||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
# Automatically convert third-party libraries to use AndroidX
|
# Automatically convert third-party libraries to use AndroidX
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
|
RELEASE_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-releases/
|
||||||
|
SNAPSHOT_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-snapshots/
|
||||||
|
USERNAME=xintai
|
||||||
|
PASSWORD=xintai2018
|
||||||
|
# 编译模式: false - 依赖本地版本, true - 依赖 maven 版本
|
||||||
|
RELEASE=false
|
||||||
|
# 模块版本
|
||||||
|
DEMO_MODULE_MAP_VERSION=1.0.0-SNAPSHOT
|
||||||
|
DEMO_MODULE_MAP2_VERSION=1.0.0-SNAPSHOT
|
||||||
|
MOGO_COMMONS_VERSION=1.0.0-SNAPSHOT
|
||||||
|
MOGO_UTILS_VERSION=1.0.0-SNAPSHOT
|
||||||
|
MAP_AMAP_VERSION=1.0.0-SNAPSHOT
|
||||||
|
MOGO_MAP_VERSION=1.0.0-SNAPSHOT
|
||||||
|
MOGO_MAP_API_VERSION=1.0.0-SNAPSHOT
|
||||||
|
MOGO_MODULE_COMMON_VERSION=1.0.0-SNAPSHOT
|
||||||
|
MOGO_MODULE_MAIN_VERSION=1.0.0-SNAPSHOT
|
||||||
|
MOGO_MODULE_MAP_VERSION=1.0.0-SNAPSHOT
|
||||||
|
MOGO_SERVICE_VERSION=1.0.0-SNAPSHOT
|
||||||
|
MOGO_SERVICE_API_VERSION=1.0.0-SNAPSHOT
|
||||||
|
MOGO_MODULE_APPS_VERSION=1.0.0-SNAPSHOT
|
||||||
|
|
||||||
|
|||||||
68
gradle/upload.gradle
Normal file
68
gradle/upload.gradle
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
apply plugin: 'maven'
|
||||||
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
|
task loggerSourcesJar(type: Jar) {
|
||||||
|
classifier = 'sources'
|
||||||
|
if (plugins.hasPlugin("java-library")) {
|
||||||
|
from sourceSets.main.java.srcDirs
|
||||||
|
} else if (plugins.hasPlugin("com.android.library")) {
|
||||||
|
from android.sourceSets.main.java.sourceFiles
|
||||||
|
} else if (plugins.hasPlugin('groovy')) {
|
||||||
|
from sourceSets.main.groovy.srcDirs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives loggerSourcesJar
|
||||||
|
}
|
||||||
|
|
||||||
|
task loggerUpload(dependsOn: [uploadArchives, loggerSourcesJar]) {
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadArchives {
|
||||||
|
repositories {
|
||||||
|
mavenDeployer {
|
||||||
|
|
||||||
|
println project.name
|
||||||
|
|
||||||
|
String versionNameKey = "${project.name.replace("-", "_").toUpperCase()}_VERSION"
|
||||||
|
String versionName = getVersionNameValue(versionNameKey)
|
||||||
|
println versionName
|
||||||
|
|
||||||
|
if (versionName == null || versionName.equals("")) {
|
||||||
|
project.logger.error("undefined versionName in root gradle.properties by ${versionNameKey}")
|
||||||
|
}
|
||||||
|
|
||||||
|
pom.project {
|
||||||
|
packaging = 'aar'
|
||||||
|
groupId = GROUP
|
||||||
|
artifactId = POM_ARTIFACT_ID
|
||||||
|
version = versionName
|
||||||
|
}
|
||||||
|
|
||||||
|
repository(url: rootProject.RELEASE_REPOSITORY_URL) {
|
||||||
|
authentication(userName: rootProject.USERNAME, password: rootProject.PASSWORD)
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshotRepository(url: rootProject.SNAPSHOT_REPOSITORY_URL) {
|
||||||
|
authentication(userName: rootProject.USERNAME, password: rootProject.PASSWORD)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getVersionNameValue(String key) {
|
||||||
|
File file = rootProject.file('gradle.properties')
|
||||||
|
String value = "";
|
||||||
|
if (file.exists()) {
|
||||||
|
//加载资源
|
||||||
|
InputStream inputStream = file.newDataInputStream();
|
||||||
|
Properties properties = new Properties()
|
||||||
|
properties.load(inputStream)
|
||||||
|
|
||||||
|
if (properties.containsKey(key)) {
|
||||||
|
value = properties.getProperty(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
25
javadoc.gradle
Normal file
25
javadoc.gradle
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
afterEvaluate {
|
||||||
|
rootProject.subprojects { project ->
|
||||||
|
println project.name
|
||||||
|
project.task("generateApiDoc", {
|
||||||
|
group "javadoc"
|
||||||
|
def rootProjectPath = rootProject.buildDir.absolutePath
|
||||||
|
def projectPath = new File("").absolutePath
|
||||||
|
def apiPackageFile = new File(projectPath, "apipackage.txt")
|
||||||
|
def sourcePath = new File(projectPath, "src/main/java")
|
||||||
|
def outputDocPath = new File(rootProjectPath, "javadoc/${project.name}")
|
||||||
|
doFirst {
|
||||||
|
println "javadoc -sourcepath ${sourcePath} -d ${outputDocPath} @${apiPackageFile}"
|
||||||
|
if (!apiPackageFile.exists()) {
|
||||||
|
throw new Exception("不是api模块")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
doLast {
|
||||||
|
exec {
|
||||||
|
commandLine "javadoc", "-sourcepath", sourcePath, "-d", outputDocPath, "-encoding", "UTF-8", "@${apiPackageFile}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||||
buildToolsVersion "29.0.2"
|
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||||
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 19
|
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||||
targetSdkVersion 29
|
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||||
versionCode 1
|
versionCode Integer.valueOf(VERSION_CODE)
|
||||||
versionName "1.0"
|
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
consumerProguardFiles 'consumer-rules.pro'
|
consumerProguardFiles 'consumer-rules.pro'
|
||||||
@@ -32,6 +30,13 @@ dependencies {
|
|||||||
implementation rootProject.ext.dependencies.amapsearch
|
implementation rootProject.ext.dependencies.amapsearch
|
||||||
implementation rootProject.ext.dependencies.amaplocation
|
implementation rootProject.ext.dependencies.amaplocation
|
||||||
|
|
||||||
|
if (Boolean.valueOf(RELEASE)) {
|
||||||
|
implementation rootProject.ext.dependencies.mogoutils
|
||||||
|
implementation rootProject.ext.dependencies.mogomapapi
|
||||||
|
} else {
|
||||||
implementation project(':foudations:mogo-utils')
|
implementation project(':foudations:mogo-utils')
|
||||||
implementation project(':libraries:mogo-map-api')
|
implementation project(':libraries:mogo-map-api')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||||
|
|||||||
3
libraries/map-amap/gradle.properties
Normal file
3
libraries/map-amap/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
GROUP=com.mogo.map
|
||||||
|
POM_ARTIFACT_ID=map-amap
|
||||||
|
VERSION_CODE=1
|
||||||
@@ -6,5 +6,7 @@
|
|||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.amap.api.v2.apikey"
|
android:name="com.amap.api.v2.apikey"
|
||||||
android:value="a36b9f7b086fa3951bb35338a5a06dd3" />
|
android:value="a36b9f7b086fa3951bb35338a5a06dd3" />
|
||||||
|
<!--定位服务-->
|
||||||
|
<service android:name="com.amap.api.location.APSService" />
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.mogo.map.impl.amap;
|
|||||||
import com.amap.api.maps.model.Marker;
|
import com.amap.api.maps.model.Marker;
|
||||||
import com.mogo.map.marker.IMogoMarker;
|
import com.mogo.map.marker.IMogoMarker;
|
||||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||||
|
import com.mogo.map.marker.MogoMarkersHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author congtaowang
|
* @author congtaowang
|
||||||
@@ -17,9 +18,11 @@ public class AMapMarkerClickHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( marker.getObject() instanceof IMogoMarker ) {
|
if ( marker.getObject() instanceof IMogoMarker ) {
|
||||||
final IMogoMarkerClickListener listener = ( ( IMogoMarker ) marker.getObject() ).getOnMarkerClickListener();
|
IMogoMarker mogoMarker = ( ( IMogoMarker ) marker.getObject() );
|
||||||
|
MogoMarkersHandler.getInstance().onMarkerClicked( mogoMarker );
|
||||||
|
final IMogoMarkerClickListener listener = mogoMarker.getOnMarkerClickListener();
|
||||||
if ( listener != null ) {
|
if ( listener != null ) {
|
||||||
return listener.onMarkerClicked( ( ( IMogoMarker ) marker.getObject() ) );
|
return listener.onMarkerClicked( mogoMarker );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.mogo.map.impl.amap;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -17,13 +18,15 @@ import com.amap.api.maps.model.Polyline;
|
|||||||
import com.amap.api.navi.AMapNaviView;
|
import com.amap.api.navi.AMapNaviView;
|
||||||
import com.amap.api.navi.AMapNaviViewListener;
|
import com.amap.api.navi.AMapNaviViewListener;
|
||||||
import com.amap.api.navi.AMapNaviViewOptions;
|
import com.amap.api.navi.AMapNaviViewOptions;
|
||||||
|
import com.amap.api.navi.model.NaviInfo;
|
||||||
import com.mogo.map.IMogoMap;
|
import com.mogo.map.IMogoMap;
|
||||||
import com.mogo.map.IMogoMapView;
|
import com.mogo.map.IMogoMapView;
|
||||||
import com.mogo.map.impl.amap.location.ALocationClient;
|
import com.mogo.map.MogoLatLng;
|
||||||
|
import com.mogo.map.impl.amap.message.AMapMessageListener;
|
||||||
|
import com.mogo.map.impl.amap.message.AMapMessageManager;
|
||||||
import com.mogo.map.impl.amap.navi.NaviClient;
|
import com.mogo.map.impl.amap.navi.NaviClient;
|
||||||
import com.mogo.map.impl.amap.utils.ObjectUtils;
|
import com.mogo.map.impl.amap.utils.ObjectUtils;
|
||||||
import com.mogo.map.listener.MogoMapListenerHandler;
|
import com.mogo.map.listener.MogoMapListenerHandler;
|
||||||
import com.mogo.map.location.MogoLocation;
|
|
||||||
import com.mogo.map.uicontroller.EnumMapUI;
|
import com.mogo.map.uicontroller.EnumMapUI;
|
||||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||||
import com.mogo.utils.logger.Logger;
|
import com.mogo.utils.logger.Logger;
|
||||||
@@ -41,7 +44,8 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
|||||||
AMap.OnPOIClickListener,
|
AMap.OnPOIClickListener,
|
||||||
AMap.OnMapClickListener,
|
AMap.OnMapClickListener,
|
||||||
AMap.OnPolylineClickListener,
|
AMap.OnPolylineClickListener,
|
||||||
AMapNaviViewListener {
|
AMapNaviViewListener,
|
||||||
|
AMapMessageListener {
|
||||||
|
|
||||||
private static final String TAG = "AMapNaviViewWrapper";
|
private static final String TAG = "AMapNaviViewWrapper";
|
||||||
|
|
||||||
@@ -70,7 +74,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
|||||||
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
|
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
|
||||||
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
|
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
|
||||||
// 设置自车的图片对象
|
// 设置自车的图片对象
|
||||||
options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(), R.drawable.ic_search_poi_location ) );
|
options.setCarBitmap( BitmapFactory.decodeResource( getContext().getResources(), R.drawable.ic_amap_navi_cursor ) );
|
||||||
// 设置指南针图标否在导航界面显示,默认显示。true,显示;false,隐藏。
|
// 设置指南针图标否在导航界面显示,默认显示。true,显示;false,隐藏。
|
||||||
options.setCompassEnabled( false );
|
options.setCompassEnabled( false );
|
||||||
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
|
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
|
||||||
@@ -120,6 +124,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
|||||||
|
|
||||||
}
|
}
|
||||||
mMapView.setRouteOverlayVisible( false );
|
mMapView.setRouteOverlayVisible( false );
|
||||||
|
mMapView.setCarOverlayVisible( false );
|
||||||
mMapView.setNaviMode( AMapNaviView.NORTH_UP_MODE );
|
mMapView.setNaviMode( AMapNaviView.NORTH_UP_MODE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,6 +140,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
|||||||
mMapView.getMap().setOnPOIClickListener( this );
|
mMapView.getMap().setOnPOIClickListener( this );
|
||||||
mMapView.getMap().setOnMapClickListener( this );
|
mMapView.getMap().setOnMapClickListener( this );
|
||||||
}
|
}
|
||||||
|
AMapMessageManager.getInstance().registerAMapMessageListener( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Context getContext() {
|
private Context getContext() {
|
||||||
@@ -324,9 +330,16 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
|||||||
} else {
|
} else {
|
||||||
mMapView.zoomOut();
|
mMapView.zoomOut();
|
||||||
}
|
}
|
||||||
|
Logger.i( TAG, "mapview zoom = " + mMapView.getMap().getCameraPosition().zoom );
|
||||||
|
Logger.i( TAG, "scalePerPixel = " + getMap().getScalePerPixel() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changeZoom( float zoom ) {
|
||||||
|
getMap().changeZoom( zoom );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeMapMode( EnumMapUI ui ) {
|
public void changeMapMode( EnumMapUI ui ) {
|
||||||
if ( ui == null ) {
|
if ( ui == null ) {
|
||||||
@@ -370,11 +383,12 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void moveToCurrentLocation() {
|
public void moveToCenter( MogoLatLng latLng ) {
|
||||||
MogoLocation location = ALocationClient.getInstance( getContext() ).getLastKnowLocation();
|
if ( latLng == null ) {
|
||||||
if ( location != null ) {
|
Logger.e( TAG, "latlng = null" );
|
||||||
mMapView.getMap().animateCamera( CameraUpdateFactory.newLatLng( new LatLng( location.getLatitude(), location.getLongitude() ) ) );
|
return;
|
||||||
}
|
}
|
||||||
|
mMapView.getMap().animateCamera( CameraUpdateFactory.newLatLng( new LatLng( latLng.lat, latLng.lng ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -383,7 +397,11 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
|||||||
mMapView.getMap().setMyLocationEnabled( true );
|
mMapView.getMap().setMyLocationEnabled( true );
|
||||||
MyLocationStyle style = mMapView.getMap().getMyLocationStyle();
|
MyLocationStyle style = mMapView.getMap().getMyLocationStyle();
|
||||||
style.showMyLocation( visible );
|
style.showMyLocation( visible );
|
||||||
style.myLocationIcon( BitmapDescriptorFactory.fromResource( R.drawable.ic_search_poi_location ) );
|
style.myLocationType( MyLocationStyle.LOCATION_TYPE_FOLLOW_NO_CENTER );
|
||||||
|
style.strokeColor( Color.TRANSPARENT );
|
||||||
|
style.strokeWidth( 0 );
|
||||||
|
style.radiusFillColor( Color.TRANSPARENT );
|
||||||
|
style.myLocationIcon( BitmapDescriptorFactory.fromResource( R.drawable.ic_current_location_cursor ) );
|
||||||
mMapView.getMap().setMyLocationStyle( style );
|
mMapView.getMap().setMyLocationStyle( style );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -401,4 +419,28 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
|||||||
mMapView.displayOverview();
|
mMapView.displayOverview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getScalePerPixel() {
|
||||||
|
return getMap().getScalePerPixel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNaviStarted() {
|
||||||
|
if ( checkAMapView() ) {
|
||||||
|
mMapView.setCarOverlayVisible( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNaviStopped() {
|
||||||
|
if ( checkAMapView() ) {
|
||||||
|
mMapView.setCarOverlayVisible( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNaviInfoUpdat( NaviInfo naviInfo ) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,25 +4,17 @@ import android.content.Context;
|
|||||||
|
|
||||||
import com.amap.api.maps.AMap;
|
import com.amap.api.maps.AMap;
|
||||||
import com.amap.api.maps.CameraUpdateFactory;
|
import com.amap.api.maps.CameraUpdateFactory;
|
||||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
|
||||||
import com.amap.api.maps.model.LatLng;
|
|
||||||
import com.amap.api.maps.model.Marker;
|
import com.amap.api.maps.model.Marker;
|
||||||
import com.amap.api.maps.model.MarkerOptions;
|
import com.amap.api.maps.model.MarkerOptions;
|
||||||
import com.amap.api.maps.model.MyLocationStyle;
|
|
||||||
import com.amap.api.navi.AMapNaviView;
|
import com.amap.api.navi.AMapNaviView;
|
||||||
import com.amap.api.navi.AMapNaviViewOptions;
|
|
||||||
import com.amap.api.navi.model.AMapNaviMarkerOptions;
|
|
||||||
import com.mogo.map.IMogoMap;
|
import com.mogo.map.IMogoMap;
|
||||||
import com.mogo.map.IMogoUiSettings;
|
import com.mogo.map.IMogoUiSettings;
|
||||||
import com.mogo.map.impl.amap.location.ALocationClient;
|
|
||||||
import com.mogo.map.impl.amap.marker.AMapInfoWindowAdapter;
|
import com.mogo.map.impl.amap.marker.AMapInfoWindowAdapter;
|
||||||
import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
|
import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
|
||||||
import com.mogo.map.impl.amap.utils.ObjectUtils;
|
import com.mogo.map.impl.amap.utils.ObjectUtils;
|
||||||
import com.mogo.map.location.MogoLocation;
|
|
||||||
import com.mogo.map.marker.IMogoMarker;
|
import com.mogo.map.marker.IMogoMarker;
|
||||||
import com.mogo.map.marker.MogoMarkerOptions;
|
import com.mogo.map.marker.MogoMarkerOptions;
|
||||||
import com.mogo.map.marker.MogoMarkersHandler;
|
import com.mogo.map.marker.MogoMarkersHandler;
|
||||||
import com.mogo.map.uicontroller.EnumMapUI;
|
|
||||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||||
import com.mogo.utils.logger.Logger;
|
import com.mogo.utils.logger.Logger;
|
||||||
|
|
||||||
@@ -83,7 +75,7 @@ public class AMapWrapper implements IMogoMap {
|
|||||||
Logger.e( TAG, "marker参数为空" );
|
Logger.e( TAG, "marker参数为空" );
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final IMogoMarker mogoMarker = new AMapMarkerWrapper( mAMap.addMarker( markerOptions ) );
|
final IMogoMarker mogoMarker = new AMapMarkerWrapper( mAMap.addMarker( markerOptions ), options );
|
||||||
MogoMarkersHandler.getInstance().add( tag, mogoMarker );
|
MogoMarkersHandler.getInstance().add( tag, mogoMarker );
|
||||||
return mogoMarker;
|
return mogoMarker;
|
||||||
}
|
}
|
||||||
@@ -124,11 +116,12 @@ public class AMapWrapper implements IMogoMap {
|
|||||||
if ( markers == null || markers.isEmpty() ) {
|
if ( markers == null || markers.isEmpty() ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for ( Marker marker : markers ) {
|
for ( int i = 0; i < markers.size(); i++ ) {
|
||||||
|
Marker marker = markers.get( i );
|
||||||
if ( marker == null ) {
|
if ( marker == null ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mogoMarkers.add( new AMapMarkerWrapper( marker ) );
|
mogoMarkers.add( new AMapMarkerWrapper( marker, options.get( i ) ) );
|
||||||
}
|
}
|
||||||
MogoMarkersHandler.getInstance().add( tag, mogoMarkers );
|
MogoMarkersHandler.getInstance().add( tag, mogoMarkers );
|
||||||
return mogoMarkers;
|
return mogoMarkers;
|
||||||
@@ -197,6 +190,21 @@ public class AMapWrapper implements IMogoMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getScalePerPixel() {
|
||||||
|
if ( checkAMap() ) {
|
||||||
|
return mAMap.getScalePerPixel();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changeZoom( float zoom ) {
|
||||||
|
if ( checkAMap() ) {
|
||||||
|
mAMap.moveCamera( CameraUpdateFactory.zoomTo( zoom ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkAMap() {
|
private boolean checkAMap() {
|
||||||
if ( mAMap == null ) {
|
if ( mAMap == null ) {
|
||||||
Logger.e( TAG, "高德map实例为空,请检查" );
|
Logger.e( TAG, "高德map实例为空,请检查" );
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import com.amap.api.location.AMapLocationClient;
|
|||||||
import com.amap.api.location.AMapLocationClientOption;
|
import com.amap.api.location.AMapLocationClientOption;
|
||||||
import com.amap.api.location.AMapLocationListener;
|
import com.amap.api.location.AMapLocationListener;
|
||||||
import com.mogo.map.impl.amap.utils.ObjectUtils;
|
import com.mogo.map.impl.amap.utils.ObjectUtils;
|
||||||
import com.mogo.map.location.IMogoLocationListener;
|
|
||||||
import com.mogo.map.location.IMogoLocationClient;
|
import com.mogo.map.location.IMogoLocationClient;
|
||||||
|
import com.mogo.map.location.IMogoLocationListener;
|
||||||
import com.mogo.map.location.MogoLocation;
|
import com.mogo.map.location.MogoLocation;
|
||||||
import com.mogo.utils.logger.Logger;
|
import com.mogo.utils.logger.Logger;
|
||||||
|
|
||||||
@@ -26,25 +26,19 @@ public class ALocationClient implements IMogoLocationClient {
|
|||||||
|
|
||||||
private static final String TAG = "LocationClient";
|
private static final String TAG = "LocationClient";
|
||||||
|
|
||||||
private static volatile ALocationClient sInstance;
|
private Set< IMogoLocationListener > sListeners = new HashSet<>( 10 );
|
||||||
private static Set< IMogoLocationListener > sListeners = new HashSet<>( 10 );
|
private MogoLocation mLastLocation;
|
||||||
private static MogoLocation sLastLocation = new MogoLocation();
|
private AMapLocationListener mListener = new InternalLocationListener();
|
||||||
|
|
||||||
private ALocationClient( Context context ) {
|
private boolean mIsDestroyed = false;
|
||||||
|
|
||||||
|
public ALocationClient( Context context ) {
|
||||||
mClient = new AMapLocationClient( context );
|
mClient = new AMapLocationClient( context );
|
||||||
mClient.setLocationListener( new InternalLocationListener() );
|
mClient.setLocationListener( mListener );
|
||||||
sLastLocation = ObjectUtils.fromAMap( mClient.getLastKnownLocation() );
|
mLastLocation = ObjectUtils.fromAMap( mClient.getLastKnownLocation() );
|
||||||
|
if ( mLastLocation != null ) {
|
||||||
|
mLastLocation = new MogoLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ALocationClient getInstance( Context context ) {
|
|
||||||
if ( sInstance == null ) {
|
|
||||||
synchronized ( ALocationClient.class ) {
|
|
||||||
if ( sInstance == null ) {
|
|
||||||
sInstance = new ALocationClient( context );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sInstance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private AMapLocationClient mClient;
|
private AMapLocationClient mClient;
|
||||||
@@ -56,26 +50,38 @@ public class ALocationClient implements IMogoLocationClient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start( long interval ) {
|
public void start( long interval ) {
|
||||||
stop();
|
if ( mIsDestroyed ) {
|
||||||
|
destroyWarming();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( mClient != null ) {
|
||||||
AMapLocationClientOption option = new AMapLocationClientOption();
|
AMapLocationClientOption option = new AMapLocationClientOption();
|
||||||
option.setLocationMode( AMapLocationClientOption.AMapLocationMode.Hight_Accuracy );
|
option.setLocationMode( AMapLocationClientOption.AMapLocationMode.Hight_Accuracy );
|
||||||
option.setNeedAddress( true );
|
option.setNeedAddress( true );
|
||||||
|
option.setGpsFirst( true );
|
||||||
option.setInterval( interval );
|
option.setInterval( interval );
|
||||||
if ( mClient != null ) {
|
|
||||||
mClient.setLocationOption( option );
|
mClient.setLocationOption( option );
|
||||||
}
|
|
||||||
mClient.startLocation();
|
mClient.startLocation();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if ( mClient != null ) {
|
if ( mIsDestroyed ) {
|
||||||
|
destroyWarming();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( mClient != null && mClient.isStarted() ) {
|
||||||
mClient.stopLocation();
|
mClient.stopLocation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addLocationListener( IMogoLocationListener listener ) {
|
public void addLocationListener( IMogoLocationListener listener ) {
|
||||||
|
if ( mIsDestroyed ) {
|
||||||
|
destroyWarming();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( listener != null ) {
|
if ( listener != null ) {
|
||||||
synchronized ( sListeners ) {
|
synchronized ( sListeners ) {
|
||||||
sListeners.add( listener );
|
sListeners.add( listener );
|
||||||
@@ -85,6 +91,10 @@ public class ALocationClient implements IMogoLocationClient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeLocationListener( IMogoLocationListener listener ) {
|
public void removeLocationListener( IMogoLocationListener listener ) {
|
||||||
|
if ( mIsDestroyed ) {
|
||||||
|
destroyWarming();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( listener != null ) {
|
if ( listener != null ) {
|
||||||
synchronized ( sListeners ) {
|
synchronized ( sListeners ) {
|
||||||
sListeners.remove( listener );
|
sListeners.remove( listener );
|
||||||
@@ -94,25 +104,52 @@ public class ALocationClient implements IMogoLocationClient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MogoLocation getLastKnowLocation() {
|
public MogoLocation getLastKnowLocation() {
|
||||||
return sLastLocation;
|
if ( mIsDestroyed ) {
|
||||||
|
destroyWarming();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return mLastLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class InternalLocationListener implements AMapLocationListener {
|
@Override
|
||||||
|
public synchronized void destroy() {
|
||||||
|
mIsDestroyed = true;
|
||||||
|
if ( sListeners != null ) {
|
||||||
|
sListeners.clear();
|
||||||
|
}
|
||||||
|
sListeners = null;
|
||||||
|
if ( mClient != null ) {
|
||||||
|
mClient.unRegisterLocationListener( mListener );
|
||||||
|
mClient.stopLocation();
|
||||||
|
mClient.onDestroy();
|
||||||
|
}
|
||||||
|
mClient = null;
|
||||||
|
mLastLocation = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class InternalLocationListener implements AMapLocationListener {
|
||||||
@Override
|
@Override
|
||||||
public void onLocationChanged( AMapLocation aMapLocation ) {
|
public void onLocationChanged( AMapLocation aMapLocation ) {
|
||||||
|
if ( mIsDestroyed ) {
|
||||||
|
destroyWarming();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( aMapLocation == null ||
|
if ( aMapLocation == null ||
|
||||||
aMapLocation.getLatitude() == 0.0D ||
|
aMapLocation.getLatitude() == 0.0D ||
|
||||||
aMapLocation.getLongitude() == 0.0D ) {
|
aMapLocation.getLongitude() == 0.0D ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Logger.d( TAG, aMapLocation.toString() );
|
mLastLocation = ObjectUtils.fromAMap( aMapLocation );
|
||||||
sLastLocation = ObjectUtils.fromAMap( aMapLocation );
|
|
||||||
synchronized ( sListeners ) {
|
synchronized ( sListeners ) {
|
||||||
Iterator< IMogoLocationListener > listenerIterator = sListeners.iterator();
|
Iterator< IMogoLocationListener > listenerIterator = sListeners.iterator();
|
||||||
while ( listenerIterator.hasNext() ) {
|
while ( listenerIterator.hasNext() ) {
|
||||||
listenerIterator.next().onLocationChanged( sLastLocation.clone() );
|
listenerIterator.next().onLocationChanged( mLastLocation.clone() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void destroyWarming() {
|
||||||
|
Logger.w( TAG, "location client has destroyed." );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.mogo.map.impl.amap.marker;
|
package com.mogo.map.impl.amap.marker;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import com.amap.api.maps.model.BitmapDescriptor;
|
import com.amap.api.maps.model.BitmapDescriptor;
|
||||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||||
@@ -12,9 +13,12 @@ import com.mogo.map.impl.amap.utils.ObjectUtils;
|
|||||||
import com.mogo.map.marker.IMogoInfoWindowAdapter;
|
import com.mogo.map.marker.IMogoInfoWindowAdapter;
|
||||||
import com.mogo.map.marker.IMogoMarker;
|
import com.mogo.map.marker.IMogoMarker;
|
||||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||||
|
import com.mogo.map.marker.IMogoMarkerIconViewCreator;
|
||||||
import com.mogo.map.marker.MogoMarkerOptions;
|
import com.mogo.map.marker.MogoMarkerOptions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Observable;
|
||||||
|
import java.util.Observer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author congtaowang
|
* @author congtaowang
|
||||||
@@ -22,7 +26,7 @@ import java.util.ArrayList;
|
|||||||
* <p>
|
* <p>
|
||||||
* 高德marker
|
* 高德marker
|
||||||
*/
|
*/
|
||||||
public class AMapMarkerWrapper implements IMogoMarker {
|
public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||||
|
|
||||||
private Marker mMarker;
|
private Marker mMarker;
|
||||||
private Object mObject;
|
private Object mObject;
|
||||||
@@ -31,16 +35,33 @@ public class AMapMarkerWrapper implements IMogoMarker {
|
|||||||
|
|
||||||
private boolean mIsDestroy = false;
|
private boolean mIsDestroy = false;
|
||||||
|
|
||||||
public AMapMarkerWrapper( Marker marker ) {
|
private MogoMarkerOptions mMogoMarkerOptions;
|
||||||
|
private String mOwner;
|
||||||
|
|
||||||
|
public AMapMarkerWrapper( Marker marker, MogoMarkerOptions mogoMarkerOptions ) {
|
||||||
this.mMarker = marker;
|
this.mMarker = marker;
|
||||||
if ( marker != null ) {
|
if ( marker != null ) {
|
||||||
// 设置高德 marker 的object对象为 IMogoMarker 实例。!!!!
|
// 设置高德 marker 的object对象为 IMogoMarker 实例。!!!!
|
||||||
marker.setObject( this );
|
marker.setObject( this );
|
||||||
}
|
}
|
||||||
|
this.mMogoMarkerOptions = mogoMarkerOptions;
|
||||||
|
mMogoMarkerOptions.addObserver( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update( Observable o, Object arg ) {
|
||||||
|
if ( isDestroyed() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setMarkerOptions( mMogoMarkerOptions );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
if ( mMogoMarkerOptions != null ) {
|
||||||
|
mMogoMarkerOptions.deleteObservers();
|
||||||
|
mMogoMarkerOptions = null;
|
||||||
|
}
|
||||||
if ( mMarker != null ) {
|
if ( mMarker != null ) {
|
||||||
mMarker.destroy();
|
mMarker.destroy();
|
||||||
mMarker.setObject( null );
|
mMarker.setObject( null );
|
||||||
@@ -236,8 +257,28 @@ public class AMapMarkerWrapper implements IMogoMarker {
|
|||||||
return mMogoInfoWindowAdapter;
|
return mMogoInfoWindowAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMarkerIconView( IMogoMarkerIconViewCreator creator ) {
|
||||||
|
if ( creator != null ) {
|
||||||
|
View iconView = creator.createView( this );
|
||||||
|
if ( iconView != null ) {
|
||||||
|
mMarker.setIcon( BitmapDescriptorFactory.fromView( iconView ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDestroyed() {
|
public boolean isDestroyed() {
|
||||||
return mIsDestroy;
|
return mIsDestroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOwner( String mOwner ) {
|
||||||
|
this.mOwner = mOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwner() {
|
||||||
|
return this.mOwner == null ? mMogoMarkerOptions.getOwner() : mOwner;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.mogo.map.impl.amap.message;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.os.Message;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-28
|
||||||
|
* <p>
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
public class AMapMessageConsts {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导航开始
|
||||||
|
*/
|
||||||
|
public static final int MSG_NAVI_START = 1000;
|
||||||
|
/**
|
||||||
|
* 取消导航
|
||||||
|
*/
|
||||||
|
public static final int MSG_NAVI_STOP = 1001;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.mogo.map.impl.amap.message;
|
||||||
|
|
||||||
|
import com.amap.api.navi.model.NaviInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-28
|
||||||
|
* <p>
|
||||||
|
* 消息回调
|
||||||
|
*/
|
||||||
|
public interface AMapMessageListener {
|
||||||
|
|
||||||
|
void onNaviStarted();
|
||||||
|
|
||||||
|
void onNaviStopped();
|
||||||
|
|
||||||
|
void onNaviInfoUpdat( NaviInfo naviInfo );
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package com.mogo.map.impl.amap.message;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.os.Message;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.amap.api.navi.model.NaviInfo;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-28
|
||||||
|
* <p>
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
public class AMapMessageManager {
|
||||||
|
|
||||||
|
private static volatile AMapMessageManager sInstance;
|
||||||
|
|
||||||
|
private List< AMapMessageListener > mListeners = new ArrayList<>();
|
||||||
|
|
||||||
|
private AMapMessageManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AMapMessageManager getInstance() {
|
||||||
|
if ( sInstance == null ) {
|
||||||
|
synchronized ( AMapMessageManager.class ) {
|
||||||
|
if ( sInstance == null ) {
|
||||||
|
sInstance = new AMapMessageManager();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void release() {
|
||||||
|
sInstance = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void registerAMapMessageListener( AMapMessageListener listener ) {
|
||||||
|
if ( !mListeners.contains( listener ) ) {
|
||||||
|
mListeners.add( listener );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void unregisterAMapMessageListener( AMapMessageListener listener ) {
|
||||||
|
mListeners.remove( listener );
|
||||||
|
}
|
||||||
|
|
||||||
|
private Handler mHandler = new Handler( Looper.getMainLooper() ) {
|
||||||
|
@Override
|
||||||
|
public void handleMessage( @NonNull Message msg ) {
|
||||||
|
super.handleMessage( msg );
|
||||||
|
AMapMessageManager.this.handleMessage( msg );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public void sendMessage( Message msg ) {
|
||||||
|
if ( msg != null ) {
|
||||||
|
mHandler.sendMessage( msg );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMessage( int what ) {
|
||||||
|
sendMessage( what, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMessage( int what, Object obj ) {
|
||||||
|
Message msg = Message.obtain();
|
||||||
|
msg.what = what;
|
||||||
|
msg.obj = obj;
|
||||||
|
sendMessage( msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void postNaviStarted() {
|
||||||
|
sendMessage( AMapMessageConsts.MSG_NAVI_START );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void postNaviStopped() {
|
||||||
|
sendMessage( AMapMessageConsts.MSG_NAVI_STOP );
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void handleMessage( Message msg ) {
|
||||||
|
if ( msg == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch ( msg.what ) {
|
||||||
|
case AMapMessageConsts.MSG_NAVI_START:
|
||||||
|
handleNaviStartedMsg();
|
||||||
|
break;
|
||||||
|
case AMapMessageConsts.MSG_NAVI_STOP:
|
||||||
|
handleNaviStoppedMsg();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleNaviStartedMsg() {
|
||||||
|
if ( mListeners == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for ( AMapMessageListener listener : mListeners ) {
|
||||||
|
listener.onNaviStarted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleNaviStoppedMsg() {
|
||||||
|
if ( mListeners == null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for ( AMapMessageListener listener : mListeners ) {
|
||||||
|
listener.onNaviStopped();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,8 +6,11 @@ import com.amap.api.maps.model.Polyline;
|
|||||||
import com.amap.api.navi.AMapNavi;
|
import com.amap.api.navi.AMapNavi;
|
||||||
import com.amap.api.navi.enums.NaviType;
|
import com.amap.api.navi.enums.NaviType;
|
||||||
import com.amap.api.navi.model.AMapCalcRouteResult;
|
import com.amap.api.navi.model.AMapCalcRouteResult;
|
||||||
|
import com.amap.api.navi.model.AMapNaviInfo;
|
||||||
|
import com.amap.api.navi.model.AMapNaviLocation;
|
||||||
import com.amap.api.navi.model.NaviInfo;
|
import com.amap.api.navi.model.NaviInfo;
|
||||||
import com.mogo.map.impl.amap.AMapWrapper;
|
import com.mogo.map.impl.amap.AMapWrapper;
|
||||||
|
import com.mogo.map.impl.amap.message.AMapMessageManager;
|
||||||
import com.mogo.map.impl.amap.utils.ObjectUtils;
|
import com.mogo.map.impl.amap.utils.ObjectUtils;
|
||||||
import com.mogo.map.navi.MogoNaviListenerHandler;
|
import com.mogo.map.navi.MogoNaviListenerHandler;
|
||||||
import com.mogo.utils.logger.Logger;
|
import com.mogo.utils.logger.Logger;
|
||||||
@@ -85,6 +88,7 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
|
|||||||
mAMapNavi.startSpeak();
|
mAMapNavi.startSpeak();
|
||||||
}
|
}
|
||||||
MogoNaviListenerHandler.getInstance().onStartNavi();
|
MogoNaviListenerHandler.getInstance().onStartNavi();
|
||||||
|
AMapMessageManager.getInstance().postNaviStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -92,6 +96,7 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
|
|||||||
setNaviing( false );
|
setNaviing( false );
|
||||||
setStopped( true );
|
setStopped( true );
|
||||||
MogoNaviListenerHandler.getInstance().onStopNavi();
|
MogoNaviListenerHandler.getInstance().onStopNavi();
|
||||||
|
AMapMessageManager.getInstance().postNaviStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -99,11 +104,13 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
|
|||||||
setNaviing( false );
|
setNaviing( false );
|
||||||
setStopped( true );
|
setStopped( true );
|
||||||
MogoNaviListenerHandler.getInstance().onStopNavi();
|
MogoNaviListenerHandler.getInstance().onStopNavi();
|
||||||
|
AMapMessageManager.getInstance().postNaviStopped();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNaviInfoUpdate( NaviInfo naviInfo ) {
|
public void onNaviInfoUpdate( NaviInfo naviInfo ) {
|
||||||
MogoNaviListenerHandler.getInstance().onNaviInfoUpdate( ObjectUtils.fromAMap( naviInfo ) );
|
MogoNaviListenerHandler.getInstance().onNaviInfoUpdate( ObjectUtils.fromAMap( naviInfo ) );
|
||||||
|
mNaviOverlayHelper.handleNaviInfoUpdate( naviInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -121,17 +128,24 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
|
|||||||
mNaviOverlayHelper.showCalculatedPaths();
|
mNaviOverlayHelper.showCalculatedPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLocationChange( AMapNaviLocation aMapNaviLocation ) {
|
||||||
|
super.onLocationChange( aMapNaviLocation );
|
||||||
|
mNaviOverlayHelper.handlePassedLocation( aMapNaviLocation );
|
||||||
|
}
|
||||||
|
|
||||||
public void stopNavi() {
|
public void stopNavi() {
|
||||||
setStopped( true );
|
setStopped( true );
|
||||||
setNaviing( false );
|
setNaviing( false );
|
||||||
mAMapNavi.stopNavi();
|
mAMapNavi.stopNavi();
|
||||||
MogoNaviListenerHandler.getInstance().onStopNavi();
|
MogoNaviListenerHandler.getInstance().onStopNavi();
|
||||||
|
AMapMessageManager.getInstance().postNaviStopped();
|
||||||
mNaviOverlayHelper.clearCalculatedOverlay();
|
mNaviOverlayHelper.clearCalculatedOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleClickedPolyline( Polyline polyline ) {
|
public void handleClickedPolyline( Polyline polyline ) {
|
||||||
if ( mNaviOverlayHelper != null ) {
|
if ( mNaviOverlayHelper != null ) {
|
||||||
mNaviOverlayHelper.handleClickedPolyline( polyline );
|
mNaviOverlayHelper.handleClickedPolyline( polyline, isNaviing() );
|
||||||
if ( isNaviing() ) {
|
if ( isNaviing() ) {
|
||||||
mAMapNavi.stopNavi();
|
mAMapNavi.stopNavi();
|
||||||
mAMapNavi.selectRouteId( mNaviOverlayHelper.getSelectedPathId() );
|
mAMapNavi.selectRouteId( mNaviOverlayHelper.getSelectedPathId() );
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import com.amap.api.maps.CameraUpdateFactory;
|
|||||||
import com.amap.api.maps.model.LatLngBounds;
|
import com.amap.api.maps.model.LatLngBounds;
|
||||||
import com.amap.api.maps.model.Polyline;
|
import com.amap.api.maps.model.Polyline;
|
||||||
import com.amap.api.navi.AMapNavi;
|
import com.amap.api.navi.AMapNavi;
|
||||||
|
import com.amap.api.navi.model.AMapNaviLocation;
|
||||||
import com.amap.api.navi.model.AMapNaviPath;
|
import com.amap.api.navi.model.AMapNaviPath;
|
||||||
|
import com.amap.api.navi.model.NaviInfo;
|
||||||
import com.mogo.map.impl.amap.R;
|
import com.mogo.map.impl.amap.R;
|
||||||
import com.mogo.map.impl.amap.overlay.RouteOverLayWrapper;
|
import com.mogo.map.impl.amap.overlay.RouteOverLayWrapper;
|
||||||
import com.mogo.utils.WindowUtils;
|
import com.mogo.utils.WindowUtils;
|
||||||
@@ -50,6 +52,7 @@ public class NaviOverlayHelper {
|
|||||||
private List< CalculatePathItem > mCalculatePathItems;
|
private List< CalculatePathItem > mCalculatePathItems;
|
||||||
|
|
||||||
private int mSelectedPathId;
|
private int mSelectedPathId;
|
||||||
|
private CalculatePathItem mSelectedCalculatePathItem;
|
||||||
|
|
||||||
public NaviOverlayHelper( AMapNavi mAMapNavi, AMap mAMap, Context mContext ) {
|
public NaviOverlayHelper( AMapNavi mAMapNavi, AMap mAMap, Context mContext ) {
|
||||||
this.mAMapNavi = mAMapNavi;
|
this.mAMapNavi = mAMapNavi;
|
||||||
@@ -138,7 +141,9 @@ public class NaviOverlayHelper {
|
|||||||
wrapper.setTrafficLightsVisible( false );
|
wrapper.setTrafficLightsVisible( false );
|
||||||
// 默认选中第一个
|
// 默认选中第一个
|
||||||
if ( i == 0 ) {
|
if ( i == 0 ) {
|
||||||
wrapper.setStartBitmap( R.drawable.ic_amap_navi_cursor ).setEndBitmap( R.drawable.ic_search_choice_point );
|
mSelectedPathId = item.getId();
|
||||||
|
mSelectedCalculatePathItem = item;
|
||||||
|
wrapper.setStartBitmap( R.drawable.ic_search_poi_location ).setEndBitmap( R.drawable.ic_search_choice_point );
|
||||||
mAMapNavi.selectRouteId( item.getId() );
|
mAMapNavi.selectRouteId( item.getId() );
|
||||||
}
|
}
|
||||||
wrapper.addToMap();
|
wrapper.addToMap();
|
||||||
@@ -167,16 +172,17 @@ public class NaviOverlayHelper {
|
|||||||
* @param polyline 选中的线
|
* @param polyline 选中的线
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean handleClickedPolyline( Polyline polyline ) {
|
public boolean handleClickedPolyline( Polyline polyline, boolean isNaviing ) {
|
||||||
if ( polyline == null ) {
|
if ( polyline == null ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.i( TAG, "polyline id = " + polyline.getId() );
|
Logger.i( TAG, "polyline id = " + polyline.getId() );
|
||||||
CalculatePathItem calculatePathItem = isCalculatePolyline( polyline );
|
mSelectedCalculatePathItem = isCalculatePolyline( polyline );
|
||||||
if ( calculatePathItem == null ) {
|
if ( mSelectedCalculatePathItem == null ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mSelectedPathId = calculatePathItem.getId();
|
mSelectedPathId = mSelectedCalculatePathItem.getId();
|
||||||
if ( mCalculatePathItems != null ) {
|
if ( mCalculatePathItems != null ) {
|
||||||
for ( CalculatePathItem item : mCalculatePathItems ) {
|
for ( CalculatePathItem item : mCalculatePathItems ) {
|
||||||
final RouteOverLayWrapper wrapper = item.getOverLazWrapper( false );
|
final RouteOverLayWrapper wrapper = item.getOverLazWrapper( false );
|
||||||
@@ -184,7 +190,7 @@ public class NaviOverlayHelper {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
wrapper.setTransparency(
|
wrapper.setTransparency(
|
||||||
item == calculatePathItem
|
item == mSelectedCalculatePathItem
|
||||||
? AMAP_ROUTE_OVERLAY_TRANSPARENCY_SELECTED
|
? AMAP_ROUTE_OVERLAY_TRANSPARENCY_SELECTED
|
||||||
: AMAP_ROUTE_OVERLAY_TRANSPARENCY_UNSELECTED
|
: AMAP_ROUTE_OVERLAY_TRANSPARENCY_UNSELECTED
|
||||||
);
|
);
|
||||||
@@ -220,4 +226,27 @@ public class NaviOverlayHelper {
|
|||||||
public int getSelectedPathId() {
|
public int getSelectedPathId() {
|
||||||
return mSelectedPathId;
|
return mSelectedPathId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆拐弯时绘制转向箭头
|
||||||
|
*
|
||||||
|
* @param naviInfo
|
||||||
|
*/
|
||||||
|
public void handleNaviInfoUpdate( NaviInfo naviInfo ) {
|
||||||
|
if ( mSelectedCalculatePathItem != null ) {
|
||||||
|
RouteOverLayWrapper wrapper = mSelectedCalculatePathItem.getOverLazWrapper( false );
|
||||||
|
if ( wrapper != null ) {
|
||||||
|
wrapper.drawArrow( naviInfo );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handlePassedLocation( AMapNaviLocation location ) {
|
||||||
|
if ( mSelectedCalculatePathItem != null ) {
|
||||||
|
RouteOverLayWrapper wrapper = mSelectedCalculatePathItem.getOverLazWrapper( false );
|
||||||
|
if ( wrapper != null ) {
|
||||||
|
wrapper.updatePolyline( location );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.mogo.map.impl.amap.uicontroller;
|
package com.mogo.map.impl.amap.uicontroller;
|
||||||
|
|
||||||
|
import com.mogo.map.MogoLatLng;
|
||||||
import com.mogo.map.MogoMap;
|
import com.mogo.map.MogoMap;
|
||||||
import com.mogo.map.uicontroller.EnumMapUI;
|
import com.mogo.map.uicontroller.EnumMapUI;
|
||||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||||
@@ -56,6 +57,13 @@ public class AMapUIController implements IMogoMapUIController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changeZoom( float zoom ) {
|
||||||
|
if ( mClient != null ) {
|
||||||
|
mClient.changeZoom( zoom );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeMapMode( EnumMapUI mode ) {
|
public void changeMapMode( EnumMapUI mode ) {
|
||||||
if ( mClient != null ) {
|
if ( mClient != null ) {
|
||||||
@@ -64,9 +72,9 @@ public class AMapUIController implements IMogoMapUIController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void moveToCurrentLocation() {
|
public void moveToCenter( MogoLatLng latLng ) {
|
||||||
if ( mClient != null ) {
|
if ( mClient != null ) {
|
||||||
mClient.moveToCurrentLocation();
|
mClient.moveToCenter(latLng);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,4 +98,12 @@ public class AMapUIController implements IMogoMapUIController {
|
|||||||
mClient.displayOverview();
|
mClient.displayOverview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getScalePerPixel() {
|
||||||
|
if ( mClient != null ) {
|
||||||
|
return mClient.getScalePerPixel();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.mogo.map.impl.amap.utils;
|
package com.mogo.map.impl.amap.utils;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import com.amap.api.location.AMapLocation;
|
import com.amap.api.location.AMapLocation;
|
||||||
import com.amap.api.maps.model.BitmapDescriptor;
|
import com.amap.api.maps.model.BitmapDescriptor;
|
||||||
@@ -33,6 +34,7 @@ import com.amap.api.services.poisearch.SubPoiItem;
|
|||||||
import com.amap.api.services.road.Crossroad;
|
import com.amap.api.services.road.Crossroad;
|
||||||
import com.mogo.map.MogoLatLng;
|
import com.mogo.map.MogoLatLng;
|
||||||
import com.mogo.map.location.MogoLocation;
|
import com.mogo.map.location.MogoLocation;
|
||||||
|
import com.mogo.map.marker.IMogoMarkerIconViewCreator;
|
||||||
import com.mogo.map.marker.MogoMarkerOptions;
|
import com.mogo.map.marker.MogoMarkerOptions;
|
||||||
import com.mogo.map.model.MogoPoi;
|
import com.mogo.map.model.MogoPoi;
|
||||||
import com.mogo.map.navi.MogoNaviInfo;
|
import com.mogo.map.navi.MogoNaviInfo;
|
||||||
@@ -81,15 +83,19 @@ public class ObjectUtils {
|
|||||||
if ( icon == null || icon.isRecycled() ) {
|
if ( icon == null || icon.isRecycled() ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptors.add( BitmapDescriptorFactory.fromBitmap( icon ) );
|
descriptors.add( BitmapDescriptorFactory.fromBitmap( icon ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo( opt );
|
||||||
|
|
||||||
return new MarkerOptions()
|
return new MarkerOptions()
|
||||||
.position( new LatLng( opt.getLatitude(), opt.getLongitude() ) )
|
.position( new LatLng( opt.getLatitude(), opt.getLongitude() ) )
|
||||||
.title( opt.getTitle() )
|
.title( opt.getTitle() )
|
||||||
.snippet( opt.getSnippet() )
|
.snippet( opt.getSnippet() )
|
||||||
.icon( BitmapDescriptorFactory.fromBitmap( opt.getIcon() ) )
|
.icon( descriptor )
|
||||||
|
.anchor( opt.getU(), opt.getV() )
|
||||||
.icons( descriptors )
|
.icons( descriptors )
|
||||||
.period( opt.getPeriod() )
|
.period( opt.getPeriod() )
|
||||||
.rotateAngle( opt.getRotate() )
|
.rotateAngle( opt.getRotate() )
|
||||||
@@ -104,6 +110,21 @@ public class ObjectUtils {
|
|||||||
.zIndex( opt.getzIndex() );
|
.zIndex( opt.getzIndex() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static BitmapDescriptor getBitmapDescriptorFromMogo( MogoMarkerOptions options ) {
|
||||||
|
if ( options == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Bitmap icon = options.getIcon();
|
||||||
|
if ( icon != null ) {
|
||||||
|
return BitmapDescriptorFactory.fromBitmap( icon );
|
||||||
|
}
|
||||||
|
View view = options.getIconView();
|
||||||
|
if ( view != null ) {
|
||||||
|
return BitmapDescriptorFactory.fromView( view );
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static MogoLocation fromAMap( AMapLocation aLocation ) {
|
public static MogoLocation fromAMap( AMapLocation aLocation ) {
|
||||||
if ( aLocation == null ) {
|
if ( aLocation == null ) {
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||||
buildToolsVersion "29.0.2"
|
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||||
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 19
|
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||||
targetSdkVersion 29
|
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||||
versionCode 1
|
versionCode Integer.valueOf(VERSION_CODE)
|
||||||
versionName "1.0"
|
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
consumerProguardFiles 'consumer-rules.pro'
|
consumerProguardFiles 'consumer-rules.pro'
|
||||||
@@ -56,3 +54,5 @@ dependencies {
|
|||||||
transitive = true
|
transitive = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||||
|
|||||||
3
libraries/map-baidu/gradle.properties
Normal file
3
libraries/map-baidu/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
GROUP=com.mogo.map
|
||||||
|
POM_ARTIFACT_ID=map-baidu
|
||||||
|
VERSION_CODE=1
|
||||||
15
libraries/mogo-map-api/apipackage.txt
Normal file
15
libraries/mogo-map-api/apipackage.txt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
com.mogo.map.uicontroller
|
||||||
|
com.mogo.map.search.poisearch
|
||||||
|
com.mogo.map.search.poisearch.query
|
||||||
|
com.mogo.map.search.inputtips
|
||||||
|
com.mogo.map.search.inputtips.query
|
||||||
|
com.mogo.map.search.geo.query
|
||||||
|
com.mogo.map.search.geo
|
||||||
|
com.mogo.map.search
|
||||||
|
com.mogo.map.navi
|
||||||
|
com.mogo.map.marker
|
||||||
|
com.mogo.map.model
|
||||||
|
com.mogo.map.location
|
||||||
|
com.mogo.map.listener
|
||||||
|
com.mogo.map.exception
|
||||||
|
com.mogo.map
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||||
buildToolsVersion "29.0.2"
|
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||||
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 19
|
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||||
targetSdkVersion 29
|
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||||
versionCode 1
|
versionCode Integer.valueOf(VERSION_CODE)
|
||||||
versionName "1.0"
|
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
consumerProguardFiles 'consumer-rules.pro'
|
consumerProguardFiles 'consumer-rules.pro'
|
||||||
@@ -28,5 +26,11 @@ dependencies {
|
|||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
implementation rootProject.ext.dependencies.androidxappcompat
|
implementation rootProject.ext.dependencies.androidxappcompat
|
||||||
|
if (Boolean.valueOf(RELEASE)) {
|
||||||
|
implementation rootProject.ext.dependencies.mogoutils
|
||||||
|
} else {
|
||||||
implementation project(':foudations:mogo-utils')
|
implementation project(':foudations:mogo-utils')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||||
|
|||||||
3
libraries/mogo-map-api/gradle.properties
Normal file
3
libraries/mogo-map-api/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
GROUP=com.mogo.map
|
||||||
|
POM_ARTIFACT_ID=mogo-map-api
|
||||||
|
VERSION_CODE=1
|
||||||
@@ -106,4 +106,13 @@ public interface IMogoMap {
|
|||||||
* 停止当前执行的改变地图状态的动画。
|
* 停止当前执行的改变地图状态的动画。
|
||||||
*/
|
*/
|
||||||
void stopAnimation();
|
void stopAnimation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取比例尺
|
||||||
|
*
|
||||||
|
* @return 当前缩放级别下,地图上1像素点对应的长度,单位米
|
||||||
|
*/
|
||||||
|
float getScalePerPixel();
|
||||||
|
|
||||||
|
void changeZoom(float zoom);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.mogo.map.listener;
|
||||||
|
|
||||||
|
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||||
|
import com.mogo.map.marker.IMogoMarkerClickListenerRegister;
|
||||||
|
import com.mogo.map.navi.IMogoNaviListenerRegister;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-29
|
||||||
|
* <p>
|
||||||
|
* 主模块需要注册监听的事件
|
||||||
|
*/
|
||||||
|
public interface IMogoHosListenerRegister extends IMogoNaviListenerRegister,
|
||||||
|
IMogoMapListenerRegister,
|
||||||
|
IMogoMarkerClickListenerRegister {
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.mogo.map.listener;
|
package com.mogo.map.listener;
|
||||||
|
|
||||||
import com.mogo.map.exception.MogoMapException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author congtaowang
|
* @author congtaowang
|
||||||
* @since 2019-12-23
|
* @since 2019-12-23
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package com.mogo.map.listener;
|
||||||
|
|
||||||
|
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||||
|
import com.mogo.map.marker.MogoMarkersHandler;
|
||||||
|
import com.mogo.map.navi.IMogoNaviListener;
|
||||||
|
import com.mogo.map.navi.MogoNaviListenerHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-29
|
||||||
|
* <p>
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
public class MogoHosListenerRegister implements IMogoHosListenerRegister {
|
||||||
|
|
||||||
|
private static volatile MogoHosListenerRegister sInstance;
|
||||||
|
|
||||||
|
private MogoHosListenerRegister() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MogoHosListenerRegister getInstance() {
|
||||||
|
if ( sInstance == null ) {
|
||||||
|
synchronized ( MogoHosListenerRegister.class ) {
|
||||||
|
if ( sInstance == null ) {
|
||||||
|
sInstance = new MogoHosListenerRegister();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void release() {
|
||||||
|
sInstance = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHostMapListener( IMogoMapListener listener ) {
|
||||||
|
MogoMapListenerHandler.getInstance().registerHostMapListener( listener );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregisterHostMapListener() {
|
||||||
|
MogoMapListenerHandler.getInstance().unregisterHostMapListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHostNaviListener( IMogoNaviListener listener ) {
|
||||||
|
MogoNaviListenerHandler.getInstance().registerHostNaviListener( listener );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregisterHostNaviListener() {
|
||||||
|
MogoNaviListenerHandler.getInstance().unregisterHostNaviListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerMarkerClickListener( IMogoMarkerClickListener listener ) {
|
||||||
|
MogoMarkersHandler.getInstance().registerMarkerClickListener( listener );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregisterMarkerClickListener() {
|
||||||
|
MogoMarkersHandler.getInstance().unregisterMarkerClickListener();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -40,4 +40,6 @@ public interface IMogoLocationClient {
|
|||||||
void removeLocationListener( IMogoLocationListener listener );
|
void removeLocationListener( IMogoLocationListener listener );
|
||||||
|
|
||||||
MogoLocation getLastKnowLocation();
|
MogoLocation getLastKnowLocation();
|
||||||
|
|
||||||
|
void destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,11 @@ import android.view.View;
|
|||||||
*/
|
*/
|
||||||
public interface IMogoInfoWindowAdapter {
|
public interface IMogoInfoWindowAdapter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取infowindow的布局
|
||||||
|
*
|
||||||
|
* @param marker
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
View getInfoWindow( IMogoMarker marker );
|
View getInfoWindow( IMogoMarker marker );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.mogo.map.marker;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
import com.mogo.map.MogoLatLng;
|
import com.mogo.map.MogoLatLng;
|
||||||
import com.mogo.map.location.IMogoLocationClient;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -168,7 +167,38 @@ public interface IMogoMarker {
|
|||||||
*/
|
*/
|
||||||
void setInfoWindowAdapter( IMogoInfoWindowAdapter adapter );
|
void setInfoWindowAdapter( IMogoInfoWindowAdapter adapter );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义 infowindow 样式接口
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
IMogoInfoWindowAdapter getInfoWindowAdapter();
|
IMogoInfoWindowAdapter getInfoWindowAdapter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义marker样式
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void setMarkerIconView( IMogoMarkerIconViewCreator creator );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否被销毁
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
boolean isDestroyed();
|
boolean isDestroyed();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置marker的归属模块
|
||||||
|
*
|
||||||
|
* @param mOwner
|
||||||
|
*/
|
||||||
|
void setOwner( String mOwner );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取marker的归属模块
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getOwner();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.mogo.map.marker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-23
|
||||||
|
* <p>
|
||||||
|
* 地图操作回调
|
||||||
|
*/
|
||||||
|
public interface IMogoMarkerClickListenerRegister {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册marker回调,各业务模块不用关注
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
*/
|
||||||
|
void registerMarkerClickListener( IMogoMarkerClickListener listener );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注销marker回调,各业务模块不需要关注
|
||||||
|
*/
|
||||||
|
void unregisterMarkerClickListener();
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.mogo.map.marker;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-29
|
||||||
|
* <p>
|
||||||
|
* 动态变换 marker 样式接口
|
||||||
|
*/
|
||||||
|
public interface IMogoMarkerIconViewCreator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回自定义marker样式
|
||||||
|
*
|
||||||
|
* @param marker marker 的数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
View createView( IMogoMarker marker );
|
||||||
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.mogo.map.marker;
|
package com.mogo.map.marker;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Observable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author congtaowang
|
* @author congtaowang
|
||||||
@@ -10,7 +12,7 @@ import java.util.ArrayList;
|
|||||||
* <p>
|
* <p>
|
||||||
* 地图marker
|
* 地图marker
|
||||||
*/
|
*/
|
||||||
public class MogoMarkerOptions {
|
public class MogoMarkerOptions extends Observable {
|
||||||
|
|
||||||
private double latitude;
|
private double latitude;
|
||||||
private double longitude;
|
private double longitude;
|
||||||
@@ -41,7 +43,7 @@ public class MogoMarkerOptions {
|
|||||||
// Marker覆盖物锚点在水平范围的比例。
|
// Marker覆盖物锚点在水平范围的比例。
|
||||||
private float u = 0.5f;
|
private float u = 0.5f;
|
||||||
// Marker覆盖物锚点垂直范围的比例。
|
// Marker覆盖物锚点垂直范围的比例。
|
||||||
private float v = 0.5f;
|
private float v = 1f;
|
||||||
|
|
||||||
// 设置Marker覆盖物是否可拖拽。
|
// 设置Marker覆盖物是否可拖拽。
|
||||||
private boolean draggable = false;
|
private boolean draggable = false;
|
||||||
@@ -53,6 +55,10 @@ public class MogoMarkerOptions {
|
|||||||
|
|
||||||
// 设置Marker覆盖物 zIndex。
|
// 设置Marker覆盖物 zIndex。
|
||||||
private int zIndex = 0;
|
private int zIndex = 0;
|
||||||
|
// 自定义样式
|
||||||
|
private View mIconView;
|
||||||
|
// marker 归属模块
|
||||||
|
private String mOwner;
|
||||||
|
|
||||||
public MogoMarkerOptions latitude( double latitude ) {
|
public MogoMarkerOptions latitude( double latitude ) {
|
||||||
this.latitude = latitude;
|
this.latitude = latitude;
|
||||||
@@ -74,6 +80,12 @@ public class MogoMarkerOptions {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优先使用icon作为marker资源
|
||||||
|
*
|
||||||
|
* @param icon
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public MogoMarkerOptions icon( Bitmap icon ) {
|
public MogoMarkerOptions icon( Bitmap icon ) {
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
return this;
|
return this;
|
||||||
@@ -144,6 +156,22 @@ public class MogoMarkerOptions {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义marker图层样式,优先使用 icon {@link #icon(Bitmap)}作为marker资源
|
||||||
|
*
|
||||||
|
* @param iconView
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public MogoMarkerOptions icon( View iconView ) {
|
||||||
|
this.mIconView = iconView;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MogoMarkerOptions owner( String owner ) {
|
||||||
|
this.mOwner = owner;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public double getLatitude() {
|
public double getLatitude() {
|
||||||
return latitude;
|
return latitude;
|
||||||
}
|
}
|
||||||
@@ -219,4 +247,12 @@ public class MogoMarkerOptions {
|
|||||||
public int getzIndex() {
|
public int getzIndex() {
|
||||||
return zIndex;
|
return zIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public View getIconView() {
|
||||||
|
return mIconView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwner() {
|
||||||
|
return mOwner;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.mogo.map.marker;
|
package com.mogo.map.marker;
|
||||||
|
|
||||||
|
import com.mogo.map.listener.IMogoMapListener;
|
||||||
|
import com.mogo.map.listener.IMogoMapListenerRegister;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -12,9 +15,10 @@ import java.util.Map;
|
|||||||
* <p>
|
* <p>
|
||||||
* 管理地图上的所有marker
|
* 管理地图上的所有marker
|
||||||
*/
|
*/
|
||||||
public class MogoMarkersHandler {
|
public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarkerClickListenerRegister {
|
||||||
|
|
||||||
private static volatile MogoMarkersHandler sInstance;
|
private static volatile MogoMarkersHandler sInstance;
|
||||||
|
private IMogoMarkerClickListener mDelegate;
|
||||||
|
|
||||||
public static MogoMarkersHandler getInstance() {
|
public static MogoMarkersHandler getInstance() {
|
||||||
if ( sInstance == null ) {
|
if ( sInstance == null ) {
|
||||||
@@ -86,4 +90,22 @@ public class MogoMarkersHandler {
|
|||||||
}
|
}
|
||||||
mServicesMarkers.get( tag ).addAll( markers );
|
mServicesMarkers.get( tag ).addAll( markers );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerMarkerClickListener( IMogoMarkerClickListener listener ) {
|
||||||
|
mDelegate = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregisterMarkerClickListener() {
|
||||||
|
mDelegate = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onMarkerClicked( IMogoMarker marker ) {
|
||||||
|
if ( mDelegate != null ) {
|
||||||
|
return mDelegate.onMarkerClicked( marker );
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.mogo.map.uicontroller;
|
package com.mogo.map.uicontroller;
|
||||||
|
|
||||||
|
import com.mogo.map.MogoLatLng;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author congtaowang
|
* @author congtaowang
|
||||||
* @since 2019-12-26
|
* @since 2019-12-26
|
||||||
@@ -22,6 +24,13 @@ public interface IMogoMapUIController {
|
|||||||
*/
|
*/
|
||||||
void changeZoom( boolean zoomIn );
|
void changeZoom( boolean zoomIn );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改缩放级别
|
||||||
|
*
|
||||||
|
* @param zoom
|
||||||
|
*/
|
||||||
|
void changeZoom( float zoom );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 切换2D/3D模式
|
* 切换2D/3D模式
|
||||||
*
|
*
|
||||||
@@ -32,7 +41,7 @@ public interface IMogoMapUIController {
|
|||||||
/**
|
/**
|
||||||
* 将地图移动至当前位置
|
* 将地图移动至当前位置
|
||||||
*/
|
*/
|
||||||
void moveToCurrentLocation();
|
void moveToCenter( MogoLatLng latLng );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 显示我的位置
|
* 显示我的位置
|
||||||
@@ -50,4 +59,11 @@ public interface IMogoMapUIController {
|
|||||||
* 预览全程
|
* 预览全程
|
||||||
*/
|
*/
|
||||||
void displayOverview();
|
void displayOverview();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取比例尺数据
|
||||||
|
*
|
||||||
|
* @return 当前缩放级别下,地图上1像素点对应的长度,单位米
|
||||||
|
*/
|
||||||
|
float getScalePerPixel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||||
buildToolsVersion "29.0.2"
|
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||||
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 19
|
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||||
targetSdkVersion 29
|
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||||
versionCode 1
|
versionCode Integer.valueOf(VERSION_CODE)
|
||||||
versionName "1.0"
|
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
consumerProguardFiles 'consumer-rules.pro'
|
consumerProguardFiles 'consumer-rules.pro'
|
||||||
@@ -27,7 +25,15 @@ dependencies {
|
|||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation rootProject.ext.dependencies.androidxappcompat
|
implementation rootProject.ext.dependencies.androidxappcompat
|
||||||
|
|
||||||
|
if (Boolean.valueOf(RELEASE)) {
|
||||||
|
implementation rootProject.ext.dependencies.mogoutils
|
||||||
|
implementation rootProject.ext.dependencies.mogomapapi
|
||||||
|
api rootProject.ext.dependencies.mapamap
|
||||||
|
} else {
|
||||||
implementation project(':foudations:mogo-utils')
|
implementation project(':foudations:mogo-utils')
|
||||||
implementation project(':libraries:mogo-map-api')
|
implementation project(':libraries:mogo-map-api')
|
||||||
api project(':libraries:map-amap')
|
api project(':libraries:map-amap')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||||
|
|||||||
3
libraries/mogo-map/gradle.properties
Normal file
3
libraries/mogo-map/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
GROUP=com.mogo.map
|
||||||
|
POM_ARTIFACT_ID=mogo-map
|
||||||
|
VERSION_CODE=1
|
||||||
@@ -3,8 +3,8 @@ package com.mogo.map;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import com.mogo.map.impl.amap.location.ALocationClient;
|
import com.mogo.map.impl.amap.location.ALocationClient;
|
||||||
import com.mogo.map.location.IMogoLocationListener;
|
|
||||||
import com.mogo.map.location.IMogoLocationClient;
|
import com.mogo.map.location.IMogoLocationClient;
|
||||||
|
import com.mogo.map.location.IMogoLocationListener;
|
||||||
import com.mogo.map.location.MogoLocation;
|
import com.mogo.map.location.MogoLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,8 +16,8 @@ public class MogoLocationClient implements IMogoLocationClient {
|
|||||||
|
|
||||||
private static volatile MogoLocationClient sInstance;
|
private static volatile MogoLocationClient sInstance;
|
||||||
|
|
||||||
private MogoLocationClient( Context context ) {
|
public MogoLocationClient( Context context ) {
|
||||||
mDelegate = ALocationClient.getInstance( context );
|
mDelegate = new ALocationClient( context );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MogoLocationClient getInstance( Context context ) {
|
public static MogoLocationClient getInstance( Context context ) {
|
||||||
@@ -75,4 +75,11 @@ public class MogoLocationClient implements IMogoLocationClient {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
if ( mDelegate != null ) {
|
||||||
|
mDelegate.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,13 @@ public class MogoMapUIController implements IMogoMapUIController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changeZoom( float zoom ) {
|
||||||
|
if ( mDelegate != null ) {
|
||||||
|
mDelegate.changeZoom( zoom );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeMapMode( EnumMapUI mode ) {
|
public void changeMapMode( EnumMapUI mode ) {
|
||||||
if ( mDelegate != null ) {
|
if ( mDelegate != null ) {
|
||||||
@@ -57,9 +64,9 @@ public class MogoMapUIController implements IMogoMapUIController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void moveToCurrentLocation() {
|
public void moveToCenter( MogoLatLng latLng ) {
|
||||||
if ( mDelegate != null ) {
|
if ( mDelegate != null ) {
|
||||||
mDelegate.moveToCurrentLocation();
|
mDelegate.moveToCenter( latLng );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,4 +90,12 @@ public class MogoMapUIController implements IMogoMapUIController {
|
|||||||
mDelegate.displayOverview();
|
mDelegate.displayOverview();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getScalePerPixel() {
|
||||||
|
if ( mDelegate != null ) {
|
||||||
|
return mDelegate.getScalePerPixel();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
modules/mogo-module-apps/.gitignore
vendored
Normal file
1
modules/mogo-module-apps/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
59
modules/mogo-module-apps/build.gradle
Normal file
59
modules/mogo-module-apps/build.gradle
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
|
implementation rootProject.ext.dependencies.androidxappcompat
|
||||||
|
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
||||||
|
implementation rootProject.ext.dependencies.arouter
|
||||||
|
implementation rootProject.ext.dependencies.material
|
||||||
|
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
||||||
|
implementation rootProject.ext.dependencies.androidxrecyclerview
|
||||||
|
|
||||||
|
if (Boolean.valueOf(RELEASE)) {
|
||||||
|
implementation rootProject.ext.dependencies.mogomap
|
||||||
|
implementation rootProject.ext.dependencies.mogomapapi
|
||||||
|
implementation rootProject.ext.dependencies.mogoutils
|
||||||
|
api rootProject.ext.dependencies.mogocommons
|
||||||
|
api rootProject.ext.dependencies.mogoserviceapi
|
||||||
|
implementation rootProject.ext.dependencies.modulecommon
|
||||||
|
} else {
|
||||||
|
implementation project(":libraries:mogo-map")
|
||||||
|
implementation project(":libraries:mogo-map-api")
|
||||||
|
implementation 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-module-apps/consumer-rules.pro
Normal file
0
modules/mogo-module-apps/consumer-rules.pro
Normal file
3
modules/mogo-module-apps/gradle.properties
Normal file
3
modules/mogo-module-apps/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
GROUP=com.mogo.module
|
||||||
|
POM_ARTIFACT_ID=module-apps
|
||||||
|
VERSION_CODE=1
|
||||||
21
modules/mogo-module-apps/proguard-rules.pro
vendored
Normal file
21
modules/mogo-module-apps/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 mName 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 mName.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.mogo.mogo.module.apps;
|
||||||
|
|
||||||
|
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.mogo.module.apps.test", appContext.getPackageName() );
|
||||||
|
}
|
||||||
|
}
|
||||||
26
modules/mogo-module-apps/src/main/AndroidManifest.xml
Normal file
26
modules/mogo-module-apps/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.mogo.module.apps">
|
||||||
|
|
||||||
|
<application>
|
||||||
|
<receiver
|
||||||
|
android:name=".receiver.AppInstallReceiver"
|
||||||
|
android:label="@string/app_name">
|
||||||
|
<intent-filter>
|
||||||
|
<!-- 一个新应用包已经安装在设备上,数据包括包名(最新安装的包程序不能接收到这个广播)-->
|
||||||
|
<action android:name="android.intent.action.PACKAGE_ADDED" />
|
||||||
|
<!-- 一个新版本的应用安装到设备,替换之前已经存在的版本-->
|
||||||
|
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||||
|
<!-- 一个已存在的应用程序包已经从设备上移除,包括包名(正在被安装的包程序不能接收到这个广播)-->
|
||||||
|
<action android:name="android.intent.action.PACKAGE_REMOVED" />
|
||||||
|
<!-- 一个已存在的应用程序包已经改变,包括包名-->
|
||||||
|
<action android:name="android.intent.action.ACTION_PACKAGE_CHANGED" />
|
||||||
|
<!-- 用户重新开始一个包,包的所有进程将被杀死,所有与其联系的运行时间状态应该被移除,包括包名(重新开始包程序不能接收到这个广播-->
|
||||||
|
<action android:name="android.intent.action.ACTION_PACKAGE_RESTARTED" />
|
||||||
|
<!-- 用户已经清楚一个包的数据,包括包名(清除包程序不能接收到这个广播)-->
|
||||||
|
<action android:name="android.intent.action.ACTION_PACKAGE_DATA_CLEARED" />
|
||||||
|
|
||||||
|
<data android:scheme="package" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.mogo.module.apps;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.mogo.module.apps.model.AppInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-30
|
||||||
|
* <p>
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
public class AppsAdapter extends RecyclerView.Adapter< AppsAdapter.AppsViewHolder > {
|
||||||
|
|
||||||
|
private List< AppInfo > mAppInfos;
|
||||||
|
|
||||||
|
public AppsAdapter( List< AppInfo > appInfos ) {
|
||||||
|
this.mAppInfos = appInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshAppInfos( List< AppInfo > mAppInfos ) {
|
||||||
|
this.mAppInfos = mAppInfos;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public AppsViewHolder onCreateViewHolder( @NonNull ViewGroup parent, int viewType ) {
|
||||||
|
return new AppsViewHolder( LayoutInflater.from( parent.getContext() ).inflate( R.layout.module_apps_item_app, null ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder( @NonNull AppsViewHolder holder, int position ) {
|
||||||
|
final AppInfo appInfo = mAppInfos.get( position );
|
||||||
|
holder.mIcon.setImageDrawable( appInfo.getIcon() );
|
||||||
|
holder.mName.setText( appInfo.getName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return mAppInfos == null ? 0 : mAppInfos.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AppsViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
public ImageView mIcon;
|
||||||
|
public TextView mName;
|
||||||
|
|
||||||
|
public AppsViewHolder( @NonNull View itemView ) {
|
||||||
|
super( itemView );
|
||||||
|
mIcon = itemView.findViewById( R.id.module_apps_id_app_icon );
|
||||||
|
mName = itemView.findViewById( R.id.module_apps_id_app_name );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package com.mogo.module.apps;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||||
|
import com.mogo.commons.mvp.MvpFragment;
|
||||||
|
import com.mogo.module.apps.model.AppInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-30
|
||||||
|
* <p>
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
public class AppsFragment extends MvpFragment< AppsView, AppsPresenter > implements AppsView {
|
||||||
|
|
||||||
|
private BottomSheetBehavior mBottomSheetBehavior;
|
||||||
|
private RecyclerView mAppsList;
|
||||||
|
private AppsAdapter mAppsAdapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getLayoutId() {
|
||||||
|
return R.layout.module_apps_fragment_apps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initViews() {
|
||||||
|
mAppsList = findViewById( R.id.module_apps_id_apps );
|
||||||
|
mAppsList.setLayoutManager( new GridLayoutManager( getContext(), 3 ) );
|
||||||
|
|
||||||
|
mBottomSheetBehavior = BottomSheetBehavior.from( mAppsList );
|
||||||
|
mBottomSheetBehavior.setSkipCollapsed( true );
|
||||||
|
mBottomSheetBehavior.setBottomSheetCallback( new BottomSheetBehavior.BottomSheetCallback() {
|
||||||
|
@Override
|
||||||
|
public void onStateChanged( @NonNull View bottomSheet, int newState ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSlide( @NonNull View bottomSheet, float slideOffset ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
mBottomSheetBehavior.setState( BottomSheetBehavior.STATE_COLLAPSED );
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
protected AppsPresenter createPresenter() {
|
||||||
|
return new AppsPresenter( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
|
||||||
|
super.onActivityCreated( savedInstanceState );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderApps( List< AppInfo > appInfos ) {
|
||||||
|
if ( mAppsAdapter == null ) {
|
||||||
|
mAppsAdapter = new AppsAdapter( appInfos );
|
||||||
|
mAppsList.setAdapter( mAppsAdapter );
|
||||||
|
} else {
|
||||||
|
mAppsAdapter.refreshAppInfos( appInfos );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package com.mogo.module.apps;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
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.map.listener.IMogoMapListener;
|
||||||
|
import com.mogo.map.location.IMogoLocationListener;
|
||||||
|
import com.mogo.map.navi.IMogoNaviListener;
|
||||||
|
import com.mogo.module.common.MogoModulePaths;
|
||||||
|
import com.mogo.service.module.IMogoModuleLifecycle;
|
||||||
|
import com.mogo.service.module.IMogoModuleProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-30
|
||||||
|
* <p>
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Route( path = MogoModulePaths.PATH_MODULE_APPS )
|
||||||
|
public class AppsFragmentProvider implements IMogoModuleProvider {
|
||||||
|
|
||||||
|
private AppsFragment mAppsFragment;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Fragment createFragment( Context context, Bundle data ) {
|
||||||
|
mAppsFragment = new AppsFragment();
|
||||||
|
mAppsFragment.setArguments( data );
|
||||||
|
return mAppsFragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View createView( Context context ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String getModuleName() {
|
||||||
|
return MogoModulePaths.PATH_MODULE_APPS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMogoModuleLifecycle getCardLifecycle() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMogoMapListener getMapListener() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getType() {
|
||||||
|
return IMogoModuleProvider.TYPE_FRAGMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMogoNaviListener getNaviListener() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMogoLocationListener getLocationListener() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init( Context context ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.mogo.module.apps;
|
||||||
|
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
|
import androidx.lifecycle.Observer;
|
||||||
|
|
||||||
|
import com.mogo.commons.mvp.Presenter;
|
||||||
|
import com.mogo.module.apps.model.AppInfo;
|
||||||
|
import com.mogo.utils.ThreadPoolService;
|
||||||
|
import com.mogo.utils.UiThreadHandler;
|
||||||
|
import com.mogo.utils.logger.Logger;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-30
|
||||||
|
* <p>
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
public class AppsPresenter extends Presenter< AppsView > {
|
||||||
|
|
||||||
|
private static final String TAG = "AppsPresenter";
|
||||||
|
|
||||||
|
public AppsPresenter( AppsView view ) {
|
||||||
|
super( view );
|
||||||
|
RefreshAppsListLiveData.getInstance().observeForever( new Observer< String >() {
|
||||||
|
@Override
|
||||||
|
public void onChanged( String s ) {
|
||||||
|
renderAppsList();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate( @NonNull LifecycleOwner owner ) {
|
||||||
|
super.onCreate( owner );
|
||||||
|
renderAppsList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderAppsList() {
|
||||||
|
ThreadPoolService.execute( new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final List< AppInfo > appInfoList = loadAppsList();
|
||||||
|
UiThreadHandler.post( new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if ( mView != null ) {
|
||||||
|
mView.renderApps( appInfoList );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
private List< AppInfo > loadAppsList() {
|
||||||
|
Logger.i( TAG, "load apps list." );
|
||||||
|
final List< AppInfo > appInfos = new ArrayList<>();
|
||||||
|
final PackageManager packageManager = getContext().getPackageManager();
|
||||||
|
List< PackageInfo > packages = packageManager.getInstalledPackages( 0 );
|
||||||
|
for ( int i = 0; i < packages.size(); ++i ) {
|
||||||
|
PackageInfo packageInfo = packages.get( i );
|
||||||
|
//获取非系统应用
|
||||||
|
if ( ( packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM ) == 0 ) {
|
||||||
|
String appName = packageInfo.applicationInfo.loadLabel( packageManager ).toString();
|
||||||
|
String packageName = packageInfo.packageName;
|
||||||
|
String versionName = packageInfo.versionName;
|
||||||
|
int versionCode = packageInfo.versionCode;
|
||||||
|
Drawable appIcon = packageInfo.applicationInfo.loadIcon( packageManager );
|
||||||
|
AppInfo appInfo = new AppInfo( appName, packageName, versionName, versionCode, appIcon );
|
||||||
|
appInfos.add( appInfo );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return appInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.mogo.module.apps;
|
||||||
|
|
||||||
|
import com.mogo.commons.mvp.IView;
|
||||||
|
import com.mogo.module.apps.model.AppInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-30
|
||||||
|
* <p>
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
public interface AppsView extends IView {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示加载的app列表
|
||||||
|
*
|
||||||
|
* @param appInfos
|
||||||
|
*/
|
||||||
|
void renderApps( List< AppInfo > appInfos );
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.mogo.module.apps;
|
||||||
|
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-30
|
||||||
|
* <p>
|
||||||
|
* 刷新app列表
|
||||||
|
*/
|
||||||
|
public class RefreshAppsListLiveData extends MutableLiveData< String > {
|
||||||
|
|
||||||
|
private static volatile RefreshAppsListLiveData sInstance;
|
||||||
|
|
||||||
|
private RefreshAppsListLiveData() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RefreshAppsListLiveData getInstance() {
|
||||||
|
if ( sInstance == null ) {
|
||||||
|
synchronized ( RefreshAppsListLiveData.class ) {
|
||||||
|
if ( sInstance == null ) {
|
||||||
|
sInstance = new RefreshAppsListLiveData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void release() {
|
||||||
|
sInstance = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.mogo.module.apps.model;
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2019-12-30
|
||||||
|
* <p>
|
||||||
|
* app 信息
|
||||||
|
*/
|
||||||
|
public class AppInfo {
|
||||||
|
|
||||||
|
private final String mName;
|
||||||
|
private final String mPackageName;
|
||||||
|
private final String mVersionName;
|
||||||
|
private final int mVersionCode;
|
||||||
|
private final Drawable mIcon;
|
||||||
|
|
||||||
|
public AppInfo( String name, String mPackageName, String mVersionName, int versionCode, Drawable icon ) {
|
||||||
|
this.mName = name;
|
||||||
|
this.mPackageName = mPackageName;
|
||||||
|
this.mVersionName = mVersionName;
|
||||||
|
this.mVersionCode = versionCode;
|
||||||
|
this.mIcon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return mName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPackageName() {
|
||||||
|
return mPackageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersionName() {
|
||||||
|
return mVersionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVersionCode() {
|
||||||
|
return mVersionCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Drawable getIcon() {
|
||||||
|
return mIcon;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
package com.mogo.module.apps.receiver;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
|
||||||
|
public class AppInstallReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive( Context context, Intent intent ) {
|
||||||
|
if ( intent.getAction().equals( Intent.ACTION_PACKAGE_ADDED ) ) {
|
||||||
|
String packageName = intent.getData().getSchemeSpecificPart();
|
||||||
|
notifyRefreshAppsList( packageName );
|
||||||
|
}
|
||||||
|
if ( intent.getAction().equals( Intent.ACTION_PACKAGE_REMOVED ) ) {
|
||||||
|
String packageName = intent.getData().getSchemeSpecificPart();
|
||||||
|
notifyRefreshAppsList( packageName );
|
||||||
|
}
|
||||||
|
if ( intent.getAction().equals( Intent.ACTION_PACKAGE_REPLACED ) ) {
|
||||||
|
String packageName = intent.getData().getSchemeSpecificPart();
|
||||||
|
notifyRefreshAppsList( packageName );
|
||||||
|
}
|
||||||
|
if ( intent.getAction().equals( Intent.ACTION_PACKAGE_CHANGED ) ) {
|
||||||
|
String packageName = intent.getData().getSchemeSpecificPart();
|
||||||
|
notifyRefreshAppsList( packageName );
|
||||||
|
}
|
||||||
|
if ( intent.getAction().equals( Intent.ACTION_PACKAGE_RESTARTED ) ) {
|
||||||
|
String packageName = intent.getData().getSchemeSpecificPart();
|
||||||
|
notifyRefreshAppsList( packageName );
|
||||||
|
}
|
||||||
|
if ( intent.getAction().equals( Intent.ACTION_PACKAGE_DATA_CLEARED ) ) {
|
||||||
|
String packageName = intent.getData().getSchemeSpecificPart();
|
||||||
|
notifyRefreshAppsList( packageName );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyRefreshAppsList( String packageName ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/module_apps_id_apps"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:behavior_hideable="false"
|
||||||
|
app:behavior_peekHeight="50dp"
|
||||||
|
app:layout_behavior="@string/bottom_sheet_behavior" />
|
||||||
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/module_apps_id_app_icon"
|
||||||
|
android:layout_width="75dp"
|
||||||
|
android:layout_height="75dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/module_apps_id_app_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
</LinearLayout>
|
||||||
3
modules/mogo-module-apps/src/main/res/values/strings.xml
Normal file
3
modules/mogo-module-apps/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">mogo-module-apps</string>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.mogo.mogo.module.apps;
|
||||||
|
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||||
buildToolsVersion "29.0.2"
|
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||||
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 19
|
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||||
targetSdkVersion 29
|
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||||
versionCode 1
|
versionCode Integer.valueOf(VERSION_CODE)
|
||||||
versionName "1.0"
|
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
consumerProguardFiles 'consumer-rules.pro'
|
consumerProguardFiles 'consumer-rules.pro'
|
||||||
@@ -27,8 +25,11 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
implementation rootProject.ext.dependencies.androidxappcompat
|
||||||
testImplementation 'junit:junit:4.12'
|
if (Boolean.valueOf(RELEASE)) {
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
} else {
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||||
|
|||||||
3
modules/mogo-module-common/gradle.properties
Normal file
3
modules/mogo-module-common/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
GROUP=com.mogo.module
|
||||||
|
POM_ARTIFACT_ID=module-common
|
||||||
|
VERSION_CODE=1
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.mogo.module.common;
|
package com.mogo.module.common;
|
||||||
|
|
||||||
|
import androidx.annotation.Keep;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author congtaowang
|
* @author congtaowang
|
||||||
* @since 2019-12-23
|
* @since 2019-12-23
|
||||||
@@ -11,10 +13,23 @@ public class MogoModulePaths {
|
|||||||
/**
|
/**
|
||||||
* 地图模块 fragment 路径
|
* 地图模块 fragment 路径
|
||||||
*/
|
*/
|
||||||
public static final String PATH_MODULE_MAP = "/module/map";
|
public static final String PATH_MODULE_MAP = "/map/ui";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试模块
|
* 测试模块
|
||||||
*/
|
*/
|
||||||
public static final String PATH_MODULE_DEMO = "/demo/module/demo";
|
public static final String PATH_MODULE_DEMO = "/demo/ui";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试模块
|
||||||
|
*/
|
||||||
|
public static final String PATH_MODULE_DEMO2 = "/demo2/ui";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* app列表模块实例化路径
|
||||||
|
*/
|
||||||
|
@Keep
|
||||||
|
public static final String PATH_MODULE_APPS = "/appslist/ui";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 29
|
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||||
buildToolsVersion "29.0.2"
|
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||||
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 19
|
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||||
targetSdkVersion 29
|
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||||
versionCode 1
|
versionCode Integer.valueOf(VERSION_CODE)
|
||||||
versionName "1.0"
|
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
consumerProguardFiles 'consumer-rules.pro'
|
consumerProguardFiles 'consumer-rules.pro'
|
||||||
@@ -33,6 +31,20 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
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)) {
|
||||||
|
implementation rootProject.ext.dependencies.mogoutils
|
||||||
|
implementation rootProject.ext.dependencies.mogocommons
|
||||||
|
implementation rootProject.ext.dependencies.modulecommon
|
||||||
|
implementation rootProject.ext.dependencies.modulemap
|
||||||
|
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||||
|
implementation rootProject.ext.dependencies.mogoservice
|
||||||
|
implementation rootProject.ext.dependencies.moduledemo
|
||||||
|
implementation rootProject.ext.dependencies.moduleapps
|
||||||
|
} else {
|
||||||
implementation project(":foudations:mogo-utils")
|
implementation project(":foudations:mogo-utils")
|
||||||
implementation project(":foudations:mogo-commons")
|
implementation project(":foudations:mogo-commons")
|
||||||
implementation project(':modules:mogo-module-common')
|
implementation project(':modules:mogo-module-common')
|
||||||
@@ -40,8 +52,8 @@ dependencies {
|
|||||||
implementation project(':services:mogo-service-api')
|
implementation project(':services:mogo-service-api')
|
||||||
implementation project(':services:mogo-service')
|
implementation project(':services:mogo-service')
|
||||||
implementation project(':demo:demo-module-map')
|
implementation project(':demo:demo-module-map')
|
||||||
implementation rootProject.ext.dependencies.androidxappcompat
|
implementation project(':modules:mogo-module-apps')
|
||||||
implementation rootProject.ext.dependencies.androidxconstraintlayout
|
|
||||||
implementation rootProject.ext.dependencies.arouter
|
|
||||||
annotationProcessor rootProject.ext.dependencies.aroutercompiler
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||||
|
|||||||
3
modules/mogo-module-main/gradle.properties
Normal file
3
modules/mogo-module-main/gradle.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
GROUP=com.mogo.module
|
||||||
|
POM_ARTIFACT_ID=module-main
|
||||||
|
VERSION_CODE=1
|
||||||
@@ -1,17 +1,26 @@
|
|||||||
package com.mogo.module.main;
|
package com.mogo.module.main;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
import com.alibaba.android.arouter.launcher.ARouter;
|
import com.alibaba.android.arouter.launcher.ARouter;
|
||||||
import com.mogo.commons.mvp.MvpActivity;
|
import com.mogo.commons.mvp.MvpActivity;
|
||||||
|
import com.mogo.map.location.IMogoLocationClient;
|
||||||
|
import com.mogo.map.location.IMogoLocationListener;
|
||||||
|
import com.mogo.map.location.MogoLocation;
|
||||||
|
import com.mogo.module.main.cards.CardModulesAdapter;
|
||||||
import com.mogo.module.main.cards.MogoModulesHandler;
|
import com.mogo.module.main.cards.MogoModulesHandler;
|
||||||
import com.mogo.module.main.cards.MogoModulesManager;
|
import com.mogo.module.main.cards.MogoModulesManager;
|
||||||
|
import com.mogo.module.main.cards.OrientedViewPager;
|
||||||
|
import com.mogo.module.main.cards.VerticalStackTransformer;
|
||||||
import com.mogo.service.MogoServicePaths;
|
import com.mogo.service.MogoServicePaths;
|
||||||
import com.mogo.service.map.IMogoMapService;
|
import com.mogo.service.map.IMogoMapService;
|
||||||
import com.mogo.service.module.IMogoModuleProvider;
|
import com.mogo.service.module.IMogoModuleProvider;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author congtaowang
|
* @author congtaowang
|
||||||
@@ -19,10 +28,19 @@ import java.util.Collection;
|
|||||||
* <p>
|
* <p>
|
||||||
* 描述
|
* 描述
|
||||||
*/
|
*/
|
||||||
public class MainActivity extends MvpActivity< MainView, MainPresenter > implements MainView {
|
public class MainActivity extends MvpActivity< MainView, MainPresenter > implements MainView,
|
||||||
|
IMogoLocationListener {
|
||||||
|
|
||||||
IMogoMapService mMogoMapService;
|
private IMogoMapService mMogoMapService;
|
||||||
MogoModulesHandler mMogoModuleHandler;
|
private MogoModulesHandler mMogoModuleHandler;
|
||||||
|
|
||||||
|
private OrientedViewPager mCardsContainer;
|
||||||
|
private CardModulesAdapter mCardModulesAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主模块管控定位,可以向各个模块发送统一定位信息
|
||||||
|
*/
|
||||||
|
private IMogoLocationClient mLocationClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutId() {
|
protected int getLayoutId() {
|
||||||
@@ -31,30 +49,57 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initViews() {
|
protected void initViews() {
|
||||||
|
mCardsContainer = findViewById( R.id.module_main_id_cards_container );
|
||||||
|
mCardsContainer.setOrientation( OrientedViewPager.Orientation.VERTICAL );
|
||||||
|
|
||||||
|
mCardsContainer.setOnPageChangeListener( new ViewPager.OnPageChangeListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels ) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageSelected( int position ) {
|
||||||
|
try {
|
||||||
|
mMogoModuleHandler.setEnable( mCardModulesAdapter.getProvider( position ).getModuleName() );
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPageScrollStateChanged( int state ) {
|
||||||
|
if ( state == ViewPager.SCROLL_STATE_IDLE ) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate( @Nullable Bundle savedInstanceState ) {
|
||||||
|
super.onCreate( savedInstanceState );
|
||||||
mMogoModuleHandler = new MogoModulesManager( this );
|
mMogoModuleHandler = new MogoModulesManager( this );
|
||||||
mMogoMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation();
|
mMogoMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation();
|
||||||
if ( mMogoMapService != null ) {
|
if ( mMogoMapService != null ) {
|
||||||
mMogoMapService.registerHostMapListener( mMogoModuleHandler );
|
mMogoMapService.getHostListenerRegister().registerHostMapListener( mMogoModuleHandler );
|
||||||
mMogoMapService.registerHostNaviListener( mMogoModuleHandler );
|
mMogoMapService.getHostListenerRegister().registerHostNaviListener( mMogoModuleHandler );
|
||||||
|
mMogoMapService.getHostListenerRegister().registerMarkerClickListener( mMogoModuleHandler );
|
||||||
}
|
}
|
||||||
mMogoModuleHandler.loadMap( R.id.module_main_id_map_fragment_container );
|
|
||||||
|
|
||||||
Collection< IMogoModuleProvider > providers = mMogoModuleHandler.loadCards();
|
mMogoModuleHandler.loadMap( R.id.module_main_id_map_fragment_container );
|
||||||
for ( IMogoModuleProvider provider : providers ) {
|
mMogoModuleHandler.loadAppsList( R.id.module_main_id_fragment_container );
|
||||||
if ( provider == null ) {
|
|
||||||
continue;
|
mLocationClient = mMogoMapService.getSingletonLocationClient( getApplicationContext() );
|
||||||
}
|
mLocationClient.addLocationListener( this );
|
||||||
if ( provider.getType() == IMogoModuleProvider.TYPE_FRAGMENT ) {
|
mLocationClient.start();
|
||||||
final Fragment fragment = provider.createFragment( this, null );
|
|
||||||
if ( fragment != null ) {
|
List< IMogoModuleProvider > providers = mMogoModuleHandler.loadCards();
|
||||||
getSupportFragmentManager().beginTransaction()
|
mCardModulesAdapter = new CardModulesAdapter( this, providers );
|
||||||
.add( R.id.module_main_id_fragment_container, fragment )
|
mCardsContainer.setOffscreenPageLimit( providers.size() );
|
||||||
.commitAllowingStateLoss();
|
mCardsContainer.setPageTransformer( true, new VerticalStackTransformer( this ) );
|
||||||
}
|
mCardsContainer.setAdapter( mCardModulesAdapter );
|
||||||
}
|
mCardsContainer.setCurrentItem( 0 );
|
||||||
}
|
|
||||||
mMogoModuleHandler.setEnable( providers.iterator().next().getModuleName() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -62,4 +107,26 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
|||||||
protected MainPresenter createPresenter() {
|
protected MainPresenter createPresenter() {
|
||||||
return new MainPresenter( this );
|
return new MainPresenter( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLocationChanged( MogoLocation location ) {
|
||||||
|
if ( mMogoModuleHandler != null ) {
|
||||||
|
mMogoModuleHandler.onLocationChanged( location );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if ( mLocationClient != null ) {
|
||||||
|
mLocationClient.removeLocationListener( this );
|
||||||
|
mLocationClient.destroy();
|
||||||
|
}
|
||||||
|
mLocationClient = null;
|
||||||
|
mMogoMapService = null;
|
||||||
|
if ( mMogoModuleHandler != null ) {
|
||||||
|
mMogoModuleHandler.destroy();
|
||||||
|
mMogoModuleHandler = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user