dev
This commit is contained in:
@@ -4,11 +4,11 @@ android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
applicationId rootProject.ext.android.applicationId
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode rootProject.ext.android.versionCode
|
||||
versionName rootProject.ext.android.versionName
|
||||
applicationId rootProject.ext.android.applicationId
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
javaCompileOptions {
|
||||
@@ -54,6 +54,16 @@ dependencies {
|
||||
testImplementation rootProject.ext.dependencies.leakcanary
|
||||
releaseImplementation rootProject.ext.dependencies.leakcanarynoop
|
||||
releaseImplementation rootProject.ext.dependencies.androidxmultidex
|
||||
implementation project(':modules:mogo-module-main')
|
||||
implementation project(':foudations:mogo-commons')
|
||||
|
||||
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(':foudations:mogo-commons')
|
||||
implementation project(':demo:demo-module-map')
|
||||
implementation project(':demo:demo-module-map2')
|
||||
}
|
||||
}
|
||||
|
||||
44
build.gradle
44
build.gradle
@@ -1,5 +1,6 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
apply from: "config.gradle"
|
||||
apply from: "javadoc.gradle"
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.61+'
|
||||
repositories {
|
||||
@@ -38,14 +39,51 @@ allprojects {
|
||||
google()
|
||||
jcenter()
|
||||
// flatDir {
|
||||
// 由于Library module中引用了 youkuplayer 库的 aar,在多 module 的情况下,
|
||||
// 其他的module编译会报错,所以需要在所有工程的repositories
|
||||
// 下把Library module中的libs目录添加到依赖关系中
|
||||
// 由于Library module中引用了 youkuplayer 库的 aar,在多 module 的情况下,
|
||||
// 其他的module编译会报错,所以需要在所有工程的repositories
|
||||
// 下把Library module中的libs目录添加到依赖关系中
|
||||
// dirs project(':libraries:map-baidu').file('libs')
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
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",
|
||||
androidxconstraintlayout: "androidx.constraintlayout:constraintlayout:1.1.3",
|
||||
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",
|
||||
androidxjunit : "androidx.test.ext:junit:1.1.0",
|
||||
@@ -56,5 +58,24 @@ ext {
|
||||
// leakcanary
|
||||
leakcanary : 'com.squareup.leakcanary:leakcanary-android: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'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
|
||||
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
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'
|
||||
@@ -34,13 +32,22 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
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')
|
||||
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()
|
||||
|
||||
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;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
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.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;
|
||||
@@ -84,6 +82,9 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
||||
private IMogoMapUIController mMapUIController;
|
||||
|
||||
private DemoInfoWindowAdapter mDemoInfoWindowAdapter;
|
||||
private MogoLocation mLocation;
|
||||
|
||||
private IMogoImageloader mImageloader;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -96,10 +97,11 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
||||
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.getSingletonLocationClient( getContext() );
|
||||
mLocationClient.addLocationListener( this );
|
||||
mLocationClient = mMapService.getLocationClient( getContext() );
|
||||
mLocation = mLocationClient.getLastKnowLocation();
|
||||
mMarkerManager = mMapService.getMarkerManager( getContext() );
|
||||
mNavi = mMapService.getNavi( getContext() );
|
||||
mMapUIController = mMapService.getMapUIController();
|
||||
@@ -112,12 +114,12 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
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 );
|
||||
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()
|
||||
.icon( mMarkerIcon )
|
||||
.latitude( 39.974525d )
|
||||
.owner( DemoConstants.TAG )
|
||||
.longitude( 116.41733d );
|
||||
IMogoMarker marker = mMarkerManager.addMarker( DemoConstants.TAG, options );
|
||||
marker.setInfoWindowAdapter( mDemoInfoWindowAdapter );
|
||||
@@ -142,9 +145,14 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
||||
ArrayList< MogoMarkerOptions > optionsList = new ArrayList<>();
|
||||
for ( int i = 0; i < 10; i++ ) {
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.icon( mMarkerIcon )
|
||||
.owner( DemoConstants.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( 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() {
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
} );
|
||||
|
||||
mLocationClient.addLocationListener( new IMogoLocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged( MogoLocation location ) {
|
||||
mLocation = location;
|
||||
Logger.d( TAG, "demo模块定位,定位间隔4s" );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -261,13 +277,13 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
||||
|
||||
@Override
|
||||
public boolean onMarkerClicked( IMogoMarker marker ) {
|
||||
if ( mLastClickedMarker != null ) {
|
||||
mLastClickedMarker.setIcon( this.mMarkerIcon );
|
||||
}
|
||||
marker.setIcon( mClickedMarkerIcon );
|
||||
mLastClickedMarker = marker;
|
||||
// if ( mLastClickedMarker != null ) {
|
||||
// mLastClickedMarker.setIcon( this.mMarkerIcon );
|
||||
// }
|
||||
// marker.setIcon( mClickedMarkerIcon );
|
||||
// mLastClickedMarker = marker;
|
||||
|
||||
marker.showInfoWindow();
|
||||
// marker.showInfoWindow();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -280,12 +296,12 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
||||
|
||||
@Override
|
||||
public void onPerform() {
|
||||
TipToast.shortTip( "卡片有效" );
|
||||
Logger.d( TAG, "卡片demo有效" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
TipToast.shortTip( "卡片无效" );
|
||||
Logger.d( TAG, "卡片demo无效" );
|
||||
}
|
||||
|
||||
|
||||
@@ -335,8 +351,8 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
||||
|
||||
@Override
|
||||
public void onLocationChanged( MogoLocation location ) {
|
||||
mLocationClient.stop();
|
||||
Logger.i( TAG, location.toString() );
|
||||
mLocation = location;
|
||||
Logger.i( TAG, "接受到的地图模块定位信息" );
|
||||
if ( mLocInfo != null ) {
|
||||
if ( location.getErrCode() == 0 ) {
|
||||
mLocInfo.setText( "当前位置:" + location.getAddress() );
|
||||
@@ -363,6 +379,7 @@ public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView >
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
Logger.w( TAG, "onDestroyView" );
|
||||
super.onDestroyView();
|
||||
getViewLifecycleOwner().getLifecycle().removeObserver( mPresenter );
|
||||
mLocationClient.removeLocationListener( this );
|
||||
|
||||
@@ -2,16 +2,28 @@ package com.mogo.demo.module.map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
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.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.service.module.IMogoModuleLifecycle;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -22,12 +34,15 @@ import com.mogo.service.module.IMogoModuleProvider;
|
||||
@Route( path = MogoModulePaths.PATH_MODULE_DEMO )
|
||||
public class DemoCardViewProvider implements IMogoModuleProvider {
|
||||
|
||||
private static final String TAG = "DemoCardViewProvider";
|
||||
|
||||
private DemoCardViewFragment fragment;
|
||||
|
||||
@Override
|
||||
public Fragment createFragment( Context context, Bundle data ) {
|
||||
fragment = new DemoCardViewFragment();
|
||||
fragment.setArguments( data );
|
||||
Logger.i( TAG, "createFragment" );
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@@ -41,22 +56,12 @@ public class DemoCardViewProvider implements IMogoModuleProvider {
|
||||
return DemoConstants.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;
|
||||
@@ -66,4 +71,20 @@ public class DemoCardViewProvider implements IMogoModuleProvider {
|
||||
public IMogoNaviListener getNaviListener() {
|
||||
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;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
@@ -8,9 +9,16 @@ 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 com.mogo.utils.network.utils.Util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
@@ -23,12 +31,16 @@ import java.util.Date;
|
||||
*/
|
||||
public class DemoInfoWindowAdapter implements IMogoInfoWindowAdapter {
|
||||
|
||||
private static final String TAG = "DemoInfoWindowAdapter";
|
||||
|
||||
private Context mContext;
|
||||
private IMogoNavi mNavi;
|
||||
private IMogoImageloader mImageloader;
|
||||
|
||||
public DemoInfoWindowAdapter( Context mContext, IMogoNavi mNavi ) {
|
||||
public DemoInfoWindowAdapter( Context mContext, IMogoNavi mNavi, IMogoImageloader iMogoImageloader ) {
|
||||
this.mContext = mContext;
|
||||
this.mNavi = mNavi;
|
||||
this.mImageloader = iMogoImageloader;
|
||||
}
|
||||
|
||||
@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,159 +1,152 @@
|
||||
<?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 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="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
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>
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/demo_module_id_clear"
|
||||
android:layout_width="200dp"
|
||||
android:id="@+id/demo_module_id_add_marker"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="清空覆盖物" />
|
||||
android:text="添加一个覆盖物" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
<Button
|
||||
android:id="@+id/demo_module_id_add_markers"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:text="添加多个覆盖物" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/demo_module_id_loc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="定位" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/demo_module_id_current"
|
||||
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
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/demo_module_id_loc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:text="定位" />
|
||||
|
||||
<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
|
||||
<Button
|
||||
android:id="@+id/demo_module_id_current"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:text="当前位置" />
|
||||
</LinearLayout>
|
||||
|
||||
<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="停止导航" />
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/demo_module_id_navi_mode"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="模拟导航" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
<Button
|
||||
android:id="@+id/demo_module_id_2d3d"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:text="2D/3D" />
|
||||
|
||||
<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
|
||||
<Button
|
||||
android:id="@+id/demo_module_id_traffic"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<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">
|
||||
|
||||
<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>
|
||||
android:layout_height="wrap_content"
|
||||
android:text="交通态势" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</ScrollView>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<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">
|
||||
|
||||
<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">
|
||||
|
||||
<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">
|
||||
|
||||
<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>
|
||||
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'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
|
||||
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
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'
|
||||
@@ -36,7 +34,13 @@ dependencies {
|
||||
api rootProject.ext.dependencies.aiassist
|
||||
api rootProject.ext.dependencies.androidxappcompat
|
||||
api rootProject.ext.dependencies.analytics
|
||||
implementation project(":foudations:mogo-utils")
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
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
|
||||
* @since 2019-12-23
|
||||
* <p>
|
||||
* 各个莫快递调试信息控制接口
|
||||
* 各个模块递调试信息控制接口
|
||||
*/
|
||||
public class DebugConfig {
|
||||
|
||||
private static boolean sDebug = true;
|
||||
|
||||
/**
|
||||
* 是否为调试模式
|
||||
*
|
||||
* @return true - 调试模式 false - 非调试模式
|
||||
*/
|
||||
public static boolean isDebug() {
|
||||
return sDebug;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置调试模式
|
||||
*
|
||||
* @param sDebug true - 调试模式 false - 非调试模式
|
||||
*/
|
||||
public static void setDebug( boolean sDebug ) {
|
||||
DebugConfig.sDebug = sDebug;
|
||||
}
|
||||
|
||||
@@ -10,5 +10,10 @@ import android.content.Context;
|
||||
*/
|
||||
public interface IView {
|
||||
|
||||
/**
|
||||
* 获取上下文
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Context getContext();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public abstract class MvpActivity< V extends IView, P extends Presenter< V > >
|
||||
/**
|
||||
* 布局资源
|
||||
*
|
||||
* @return
|
||||
* @return 布局资源 id
|
||||
*/
|
||||
protected abstract int getLayoutId();
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
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.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
@@ -14,7 +22,8 @@ import androidx.lifecycle.OnLifecycleEvent;
|
||||
*/
|
||||
public abstract class Presenter< V extends IView > implements LifecycleObserver {
|
||||
|
||||
private V mView;
|
||||
protected V mView;
|
||||
private Context mContext;
|
||||
|
||||
public Presenter( V view ) {
|
||||
this.mView = view;
|
||||
@@ -49,4 +58,35 @@ public abstract class Presenter< V extends IView > implements LifecycleObserver
|
||||
@NonNull LifecycleOwner owner,
|
||||
@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'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
|
||||
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
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'
|
||||
@@ -37,4 +35,11 @@ dependencies {
|
||||
api rootProject.ext.dependencies.retrofitconvertergson
|
||||
api rootProject.ext.dependencies.retrofitconverterscalars
|
||||
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
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
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'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
|
||||
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
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'
|
||||
@@ -32,6 +30,13 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.amapsearch
|
||||
implementation rootProject.ext.dependencies.amaplocation
|
||||
|
||||
implementation project(':foudations:mogo-utils')
|
||||
implementation project(':libraries:mogo-map-api')
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
implementation rootProject.ext.dependencies.mogoutils
|
||||
implementation rootProject.ext.dependencies.mogomapapi
|
||||
} else {
|
||||
implementation project(':foudations:mogo-utils')
|
||||
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
|
||||
android:name="com.amap.api.v2.apikey"
|
||||
android:value="a36b9f7b086fa3951bb35338a5a06dd3" />
|
||||
<!--定位服务-->
|
||||
<service android:name="com.amap.api.location.APSService" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.map.impl.amap;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -17,9 +18,11 @@ public class AMapMarkerClickHandler {
|
||||
return false;
|
||||
}
|
||||
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 ) {
|
||||
return listener.onMarkerClicked( ( ( IMogoMarker ) marker.getObject() ) );
|
||||
return listener.onMarkerClicked( mogoMarker );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.map.impl.amap;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
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.AMapNaviViewListener;
|
||||
import com.amap.api.navi.AMapNaviViewOptions;
|
||||
import com.amap.api.navi.model.NaviInfo;
|
||||
import com.mogo.map.IMogoMap;
|
||||
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.utils.ObjectUtils;
|
||||
import com.mogo.map.listener.MogoMapListenerHandler;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -41,7 +44,8 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
||||
AMap.OnPOIClickListener,
|
||||
AMap.OnMapClickListener,
|
||||
AMap.OnPolylineClickListener,
|
||||
AMapNaviViewListener {
|
||||
AMapNaviViewListener,
|
||||
AMapMessageListener {
|
||||
|
||||
private static final String TAG = "AMapNaviViewWrapper";
|
||||
|
||||
@@ -70,7 +74,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
||||
// 设置路线相关的配置属性,如:路线的路况颜色,路线上是否显示摄像头气泡等。
|
||||
// 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,隐藏。
|
||||
options.setCompassEnabled( false );
|
||||
//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
|
||||
@@ -120,6 +124,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
||||
|
||||
}
|
||||
mMapView.setRouteOverlayVisible( false );
|
||||
mMapView.setCarOverlayVisible( false );
|
||||
mMapView.setNaviMode( AMapNaviView.NORTH_UP_MODE );
|
||||
}
|
||||
}
|
||||
@@ -135,6 +140,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
||||
mMapView.getMap().setOnPOIClickListener( this );
|
||||
mMapView.getMap().setOnMapClickListener( this );
|
||||
}
|
||||
AMapMessageManager.getInstance().registerAMapMessageListener( this );
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
@@ -324,9 +330,16 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
||||
} else {
|
||||
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
|
||||
public void changeMapMode( EnumMapUI ui ) {
|
||||
if ( ui == null ) {
|
||||
@@ -370,11 +383,12 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveToCurrentLocation() {
|
||||
MogoLocation location = ALocationClient.getInstance( getContext() ).getLastKnowLocation();
|
||||
if ( location != null ) {
|
||||
mMapView.getMap().animateCamera( CameraUpdateFactory.newLatLng( new LatLng( location.getLatitude(), location.getLongitude() ) ) );
|
||||
public void moveToCenter( MogoLatLng latLng ) {
|
||||
if ( latLng == null ) {
|
||||
Logger.e( TAG, "latlng = null" );
|
||||
return;
|
||||
}
|
||||
mMapView.getMap().animateCamera( CameraUpdateFactory.newLatLng( new LatLng( latLng.lat, latLng.lng ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -383,7 +397,11 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
||||
mMapView.getMap().setMyLocationEnabled( true );
|
||||
MyLocationStyle style = mMapView.getMap().getMyLocationStyle();
|
||||
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 );
|
||||
}
|
||||
}
|
||||
@@ -401,4 +419,28 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
||||
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.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.MarkerOptions;
|
||||
import com.amap.api.maps.model.MyLocationStyle;
|
||||
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.IMogoUiSettings;
|
||||
import com.mogo.map.impl.amap.location.ALocationClient;
|
||||
import com.mogo.map.impl.amap.marker.AMapInfoWindowAdapter;
|
||||
import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
|
||||
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.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -83,7 +75,7 @@ public class AMapWrapper implements IMogoMap {
|
||||
Logger.e( TAG, "marker参数为空" );
|
||||
return null;
|
||||
}
|
||||
final IMogoMarker mogoMarker = new AMapMarkerWrapper( mAMap.addMarker( markerOptions ) );
|
||||
final IMogoMarker mogoMarker = new AMapMarkerWrapper( mAMap.addMarker( markerOptions ), options );
|
||||
MogoMarkersHandler.getInstance().add( tag, mogoMarker );
|
||||
return mogoMarker;
|
||||
}
|
||||
@@ -124,11 +116,12 @@ public class AMapWrapper implements IMogoMap {
|
||||
if ( markers == null || markers.isEmpty() ) {
|
||||
return null;
|
||||
}
|
||||
for ( Marker marker : markers ) {
|
||||
for ( int i = 0; i < markers.size(); i++ ) {
|
||||
Marker marker = markers.get( i );
|
||||
if ( marker == null ) {
|
||||
continue;
|
||||
}
|
||||
mogoMarkers.add( new AMapMarkerWrapper( marker ) );
|
||||
mogoMarkers.add( new AMapMarkerWrapper( marker, options.get( i ) ) );
|
||||
}
|
||||
MogoMarkersHandler.getInstance().add( tag, 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() {
|
||||
if ( mAMap == null ) {
|
||||
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.AMapLocationListener;
|
||||
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.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -26,25 +26,19 @@ public class ALocationClient implements IMogoLocationClient {
|
||||
|
||||
private static final String TAG = "LocationClient";
|
||||
|
||||
private static volatile ALocationClient sInstance;
|
||||
private static Set< IMogoLocationListener > sListeners = new HashSet<>( 10 );
|
||||
private static MogoLocation sLastLocation = new MogoLocation();
|
||||
private Set< IMogoLocationListener > sListeners = new HashSet<>( 10 );
|
||||
private MogoLocation mLastLocation;
|
||||
private AMapLocationListener mListener = new InternalLocationListener();
|
||||
|
||||
private ALocationClient( Context context ) {
|
||||
private boolean mIsDestroyed = false;
|
||||
|
||||
public ALocationClient( Context context ) {
|
||||
mClient = new AMapLocationClient( context );
|
||||
mClient.setLocationListener( new InternalLocationListener() );
|
||||
sLastLocation = ObjectUtils.fromAMap( mClient.getLastKnownLocation() );
|
||||
}
|
||||
|
||||
public static ALocationClient getInstance( Context context ) {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( ALocationClient.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new ALocationClient( context );
|
||||
}
|
||||
}
|
||||
mClient.setLocationListener( mListener );
|
||||
mLastLocation = ObjectUtils.fromAMap( mClient.getLastKnownLocation() );
|
||||
if ( mLastLocation != null ) {
|
||||
mLastLocation = new MogoLocation();
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private AMapLocationClient mClient;
|
||||
@@ -56,26 +50,38 @@ public class ALocationClient implements IMogoLocationClient {
|
||||
|
||||
@Override
|
||||
public void start( long interval ) {
|
||||
stop();
|
||||
AMapLocationClientOption option = new AMapLocationClientOption();
|
||||
option.setLocationMode( AMapLocationClientOption.AMapLocationMode.Hight_Accuracy );
|
||||
option.setNeedAddress( true );
|
||||
option.setInterval( interval );
|
||||
if ( mClient != null ) {
|
||||
mClient.setLocationOption( option );
|
||||
if ( mIsDestroyed ) {
|
||||
destroyWarming();
|
||||
return;
|
||||
}
|
||||
if ( mClient != null ) {
|
||||
AMapLocationClientOption option = new AMapLocationClientOption();
|
||||
option.setLocationMode( AMapLocationClientOption.AMapLocationMode.Hight_Accuracy );
|
||||
option.setNeedAddress( true );
|
||||
option.setGpsFirst( true );
|
||||
option.setInterval( interval );
|
||||
mClient.setLocationOption( option );
|
||||
mClient.startLocation();
|
||||
}
|
||||
mClient.startLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if ( mClient != null ) {
|
||||
if ( mIsDestroyed ) {
|
||||
destroyWarming();
|
||||
return;
|
||||
}
|
||||
if ( mClient != null && mClient.isStarted() ) {
|
||||
mClient.stopLocation();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLocationListener( IMogoLocationListener listener ) {
|
||||
if ( mIsDestroyed ) {
|
||||
destroyWarming();
|
||||
return;
|
||||
}
|
||||
if ( listener != null ) {
|
||||
synchronized ( sListeners ) {
|
||||
sListeners.add( listener );
|
||||
@@ -85,6 +91,10 @@ public class ALocationClient implements IMogoLocationClient {
|
||||
|
||||
@Override
|
||||
public void removeLocationListener( IMogoLocationListener listener ) {
|
||||
if ( mIsDestroyed ) {
|
||||
destroyWarming();
|
||||
return;
|
||||
}
|
||||
if ( listener != null ) {
|
||||
synchronized ( sListeners ) {
|
||||
sListeners.remove( listener );
|
||||
@@ -94,25 +104,52 @@ public class ALocationClient implements IMogoLocationClient {
|
||||
|
||||
@Override
|
||||
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
|
||||
public void onLocationChanged( AMapLocation aMapLocation ) {
|
||||
if ( mIsDestroyed ) {
|
||||
destroyWarming();
|
||||
return;
|
||||
}
|
||||
if ( aMapLocation == null ||
|
||||
aMapLocation.getLatitude() == 0.0D ||
|
||||
aMapLocation.getLongitude() == 0.0D ) {
|
||||
return;
|
||||
}
|
||||
Logger.d( TAG, aMapLocation.toString() );
|
||||
sLastLocation = ObjectUtils.fromAMap( aMapLocation );
|
||||
mLastLocation = ObjectUtils.fromAMap( aMapLocation );
|
||||
synchronized ( sListeners ) {
|
||||
Iterator< IMogoLocationListener > listenerIterator = sListeners.iterator();
|
||||
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;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
|
||||
import com.amap.api.maps.model.BitmapDescriptor;
|
||||
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.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.IMogoMarkerIconViewCreator;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -22,7 +26,7 @@ import java.util.ArrayList;
|
||||
* <p>
|
||||
* 高德marker
|
||||
*/
|
||||
public class AMapMarkerWrapper implements IMogoMarker {
|
||||
public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
|
||||
private Marker mMarker;
|
||||
private Object mObject;
|
||||
@@ -31,16 +35,33 @@ public class AMapMarkerWrapper implements IMogoMarker {
|
||||
|
||||
private boolean mIsDestroy = false;
|
||||
|
||||
public AMapMarkerWrapper( Marker marker ) {
|
||||
private MogoMarkerOptions mMogoMarkerOptions;
|
||||
private String mOwner;
|
||||
|
||||
public AMapMarkerWrapper( Marker marker, MogoMarkerOptions mogoMarkerOptions ) {
|
||||
this.mMarker = marker;
|
||||
if ( marker != null ) {
|
||||
// 设置高德 marker 的object对象为 IMogoMarker 实例。!!!!
|
||||
marker.setObject( this );
|
||||
}
|
||||
this.mMogoMarkerOptions = mogoMarkerOptions;
|
||||
mMogoMarkerOptions.addObserver( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update( Observable o, Object arg ) {
|
||||
if ( isDestroyed() ) {
|
||||
return;
|
||||
}
|
||||
setMarkerOptions( mMogoMarkerOptions );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if ( mMogoMarkerOptions != null ) {
|
||||
mMogoMarkerOptions.deleteObservers();
|
||||
mMogoMarkerOptions = null;
|
||||
}
|
||||
if ( mMarker != null ) {
|
||||
mMarker.destroy();
|
||||
mMarker.setObject( null );
|
||||
@@ -236,8 +257,28 @@ public class AMapMarkerWrapper implements IMogoMarker {
|
||||
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
|
||||
public boolean isDestroyed() {
|
||||
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.enums.NaviType;
|
||||
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.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.navi.MogoNaviListenerHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -85,6 +88,7 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
|
||||
mAMapNavi.startSpeak();
|
||||
}
|
||||
MogoNaviListenerHandler.getInstance().onStartNavi();
|
||||
AMapMessageManager.getInstance().postNaviStarted();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,6 +96,7 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
|
||||
setNaviing( false );
|
||||
setStopped( true );
|
||||
MogoNaviListenerHandler.getInstance().onStopNavi();
|
||||
AMapMessageManager.getInstance().postNaviStopped();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,11 +104,13 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
|
||||
setNaviing( false );
|
||||
setStopped( true );
|
||||
MogoNaviListenerHandler.getInstance().onStopNavi();
|
||||
AMapMessageManager.getInstance().postNaviStopped();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviInfoUpdate( NaviInfo naviInfo ) {
|
||||
MogoNaviListenerHandler.getInstance().onNaviInfoUpdate( ObjectUtils.fromAMap( naviInfo ) );
|
||||
mNaviOverlayHelper.handleNaviInfoUpdate( naviInfo );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,17 +128,24 @@ public class NaviListenerAdapter extends AMapNaviListenerAdapter {
|
||||
mNaviOverlayHelper.showCalculatedPaths();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChange( AMapNaviLocation aMapNaviLocation ) {
|
||||
super.onLocationChange( aMapNaviLocation );
|
||||
mNaviOverlayHelper.handlePassedLocation( aMapNaviLocation );
|
||||
}
|
||||
|
||||
public void stopNavi() {
|
||||
setStopped( true );
|
||||
setNaviing( false );
|
||||
mAMapNavi.stopNavi();
|
||||
MogoNaviListenerHandler.getInstance().onStopNavi();
|
||||
AMapMessageManager.getInstance().postNaviStopped();
|
||||
mNaviOverlayHelper.clearCalculatedOverlay();
|
||||
}
|
||||
|
||||
public void handleClickedPolyline( Polyline polyline ) {
|
||||
if ( mNaviOverlayHelper != null ) {
|
||||
mNaviOverlayHelper.handleClickedPolyline( polyline );
|
||||
mNaviOverlayHelper.handleClickedPolyline( polyline, isNaviing() );
|
||||
if ( isNaviing() ) {
|
||||
mAMapNavi.stopNavi();
|
||||
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.Polyline;
|
||||
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.NaviInfo;
|
||||
import com.mogo.map.impl.amap.R;
|
||||
import com.mogo.map.impl.amap.overlay.RouteOverLayWrapper;
|
||||
import com.mogo.utils.WindowUtils;
|
||||
@@ -50,6 +52,7 @@ public class NaviOverlayHelper {
|
||||
private List< CalculatePathItem > mCalculatePathItems;
|
||||
|
||||
private int mSelectedPathId;
|
||||
private CalculatePathItem mSelectedCalculatePathItem;
|
||||
|
||||
public NaviOverlayHelper( AMapNavi mAMapNavi, AMap mAMap, Context mContext ) {
|
||||
this.mAMapNavi = mAMapNavi;
|
||||
@@ -138,7 +141,9 @@ public class NaviOverlayHelper {
|
||||
wrapper.setTrafficLightsVisible( false );
|
||||
// 默认选中第一个
|
||||
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() );
|
||||
}
|
||||
wrapper.addToMap();
|
||||
@@ -167,16 +172,17 @@ public class NaviOverlayHelper {
|
||||
* @param polyline 选中的线
|
||||
* @return
|
||||
*/
|
||||
public boolean handleClickedPolyline( Polyline polyline ) {
|
||||
public boolean handleClickedPolyline( Polyline polyline, boolean isNaviing ) {
|
||||
if ( polyline == null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Logger.i( TAG, "polyline id = " + polyline.getId() );
|
||||
CalculatePathItem calculatePathItem = isCalculatePolyline( polyline );
|
||||
if ( calculatePathItem == null ) {
|
||||
mSelectedCalculatePathItem = isCalculatePolyline( polyline );
|
||||
if ( mSelectedCalculatePathItem == null ) {
|
||||
return false;
|
||||
}
|
||||
mSelectedPathId = calculatePathItem.getId();
|
||||
mSelectedPathId = mSelectedCalculatePathItem.getId();
|
||||
if ( mCalculatePathItems != null ) {
|
||||
for ( CalculatePathItem item : mCalculatePathItems ) {
|
||||
final RouteOverLayWrapper wrapper = item.getOverLazWrapper( false );
|
||||
@@ -184,7 +190,7 @@ public class NaviOverlayHelper {
|
||||
continue;
|
||||
}
|
||||
wrapper.setTransparency(
|
||||
item == calculatePathItem
|
||||
item == mSelectedCalculatePathItem
|
||||
? AMAP_ROUTE_OVERLAY_TRANSPARENCY_SELECTED
|
||||
: AMAP_ROUTE_OVERLAY_TRANSPARENCY_UNSELECTED
|
||||
);
|
||||
@@ -220,4 +226,27 @@ public class NaviOverlayHelper {
|
||||
public int getSelectedPathId() {
|
||||
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;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.MogoMap;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
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
|
||||
public void changeMapMode( EnumMapUI mode ) {
|
||||
if ( mClient != null ) {
|
||||
@@ -64,9 +72,9 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveToCurrentLocation() {
|
||||
public void moveToCenter( MogoLatLng latLng ) {
|
||||
if ( mClient != null ) {
|
||||
mClient.moveToCurrentLocation();
|
||||
mClient.moveToCenter(latLng);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,4 +98,12 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
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;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
|
||||
import com.amap.api.location.AMapLocation;
|
||||
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.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.marker.IMogoMarkerIconViewCreator;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
@@ -81,15 +83,19 @@ public class ObjectUtils {
|
||||
if ( icon == null || icon.isRecycled() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
descriptors.add( BitmapDescriptorFactory.fromBitmap( icon ) );
|
||||
}
|
||||
}
|
||||
|
||||
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo( opt );
|
||||
|
||||
return new MarkerOptions()
|
||||
.position( new LatLng( opt.getLatitude(), opt.getLongitude() ) )
|
||||
.title( opt.getTitle() )
|
||||
.snippet( opt.getSnippet() )
|
||||
.icon( BitmapDescriptorFactory.fromBitmap( opt.getIcon() ) )
|
||||
.icon( descriptor )
|
||||
.anchor( opt.getU(), opt.getV() )
|
||||
.icons( descriptors )
|
||||
.period( opt.getPeriod() )
|
||||
.rotateAngle( opt.getRotate() )
|
||||
@@ -104,6 +110,21 @@ public class ObjectUtils {
|
||||
.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 ) {
|
||||
if ( aLocation == null ) {
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
|
||||
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
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'
|
||||
@@ -56,3 +54,5 @@ dependencies {
|
||||
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'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
|
||||
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
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'
|
||||
@@ -28,5 +26,11 @@ dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
implementation project(':foudations:mogo-utils')
|
||||
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
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();
|
||||
|
||||
/**
|
||||
* 获取比例尺
|
||||
*
|
||||
* @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;
|
||||
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @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 );
|
||||
|
||||
MogoLocation getLastKnowLocation();
|
||||
|
||||
void destroy();
|
||||
}
|
||||
|
||||
@@ -10,5 +10,11 @@ import android.view.View;
|
||||
*/
|
||||
public interface IMogoInfoWindowAdapter {
|
||||
|
||||
/**
|
||||
* 获取infowindow的布局
|
||||
*
|
||||
* @param marker
|
||||
* @return
|
||||
*/
|
||||
View getInfoWindow( IMogoMarker marker );
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.mogo.map.marker;
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -168,7 +167,38 @@ public interface IMogoMarker {
|
||||
*/
|
||||
void setInfoWindowAdapter( IMogoInfoWindowAdapter adapter );
|
||||
|
||||
/**
|
||||
* 自定义 infowindow 样式接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoInfoWindowAdapter getInfoWindowAdapter();
|
||||
|
||||
/**
|
||||
* 自定义marker样式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
void setMarkerIconView( IMogoMarkerIconViewCreator creator );
|
||||
|
||||
/**
|
||||
* 是否被销毁
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
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;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Observable;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -10,7 +12,7 @@ import java.util.ArrayList;
|
||||
* <p>
|
||||
* 地图marker
|
||||
*/
|
||||
public class MogoMarkerOptions {
|
||||
public class MogoMarkerOptions extends Observable {
|
||||
|
||||
private double latitude;
|
||||
private double longitude;
|
||||
@@ -41,7 +43,7 @@ public class MogoMarkerOptions {
|
||||
// Marker覆盖物锚点在水平范围的比例。
|
||||
private float u = 0.5f;
|
||||
// Marker覆盖物锚点垂直范围的比例。
|
||||
private float v = 0.5f;
|
||||
private float v = 1f;
|
||||
|
||||
// 设置Marker覆盖物是否可拖拽。
|
||||
private boolean draggable = false;
|
||||
@@ -53,6 +55,10 @@ public class MogoMarkerOptions {
|
||||
|
||||
// 设置Marker覆盖物 zIndex。
|
||||
private int zIndex = 0;
|
||||
// 自定义样式
|
||||
private View mIconView;
|
||||
// marker 归属模块
|
||||
private String mOwner;
|
||||
|
||||
public MogoMarkerOptions latitude( double latitude ) {
|
||||
this.latitude = latitude;
|
||||
@@ -74,6 +80,12 @@ public class MogoMarkerOptions {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优先使用icon作为marker资源
|
||||
*
|
||||
* @param icon
|
||||
* @return
|
||||
*/
|
||||
public MogoMarkerOptions icon( Bitmap icon ) {
|
||||
this.icon = icon;
|
||||
return this;
|
||||
@@ -144,6 +156,22 @@ public class MogoMarkerOptions {
|
||||
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() {
|
||||
return latitude;
|
||||
}
|
||||
@@ -219,4 +247,12 @@ public class MogoMarkerOptions {
|
||||
public int getzIndex() {
|
||||
return zIndex;
|
||||
}
|
||||
|
||||
public View getIconView() {
|
||||
return mIconView;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return mOwner;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.listener.IMogoMapListenerRegister;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -12,9 +15,10 @@ import java.util.Map;
|
||||
* <p>
|
||||
* 管理地图上的所有marker
|
||||
*/
|
||||
public class MogoMarkersHandler {
|
||||
public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarkerClickListenerRegister {
|
||||
|
||||
private static volatile MogoMarkersHandler sInstance;
|
||||
private IMogoMarkerClickListener mDelegate;
|
||||
|
||||
public static MogoMarkersHandler getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
@@ -86,4 +90,22 @@ public class MogoMarkersHandler {
|
||||
}
|
||||
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;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-26
|
||||
@@ -22,6 +24,13 @@ public interface IMogoMapUIController {
|
||||
*/
|
||||
void changeZoom( boolean zoomIn );
|
||||
|
||||
/**
|
||||
* 修改缩放级别
|
||||
*
|
||||
* @param zoom
|
||||
*/
|
||||
void changeZoom( float zoom );
|
||||
|
||||
/**
|
||||
* 切换2D/3D模式
|
||||
*
|
||||
@@ -32,7 +41,7 @@ public interface IMogoMapUIController {
|
||||
/**
|
||||
* 将地图移动至当前位置
|
||||
*/
|
||||
void moveToCurrentLocation();
|
||||
void moveToCenter( MogoLatLng latLng );
|
||||
|
||||
/**
|
||||
* 显示我的位置
|
||||
@@ -50,4 +59,11 @@ public interface IMogoMapUIController {
|
||||
* 预览全程
|
||||
*/
|
||||
void displayOverview();
|
||||
|
||||
/**
|
||||
* 获取比例尺数据
|
||||
*
|
||||
* @return 当前缩放级别下,地图上1像素点对应的长度,单位米
|
||||
*/
|
||||
float getScalePerPixel();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
|
||||
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
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'
|
||||
@@ -27,7 +25,15 @@ dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
|
||||
implementation project(':foudations:mogo-utils')
|
||||
implementation project(':libraries:mogo-map-api')
|
||||
api project(':libraries:map-amap')
|
||||
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(':libraries:mogo-map-api')
|
||||
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 com.mogo.map.impl.amap.location.ALocationClient;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
|
||||
/**
|
||||
@@ -16,8 +16,8 @@ public class MogoLocationClient implements IMogoLocationClient {
|
||||
|
||||
private static volatile MogoLocationClient sInstance;
|
||||
|
||||
private MogoLocationClient( Context context ) {
|
||||
mDelegate = ALocationClient.getInstance( context );
|
||||
public MogoLocationClient( Context context ) {
|
||||
mDelegate = new ALocationClient( context );
|
||||
}
|
||||
|
||||
public static MogoLocationClient getInstance( Context context ) {
|
||||
@@ -75,4 +75,11 @@ public class MogoLocationClient implements IMogoLocationClient {
|
||||
}
|
||||
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
|
||||
public void changeMapMode( EnumMapUI mode ) {
|
||||
if ( mDelegate != null ) {
|
||||
@@ -57,9 +64,9 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveToCurrentLocation() {
|
||||
public void moveToCenter( MogoLatLng latLng ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.moveToCurrentLocation();
|
||||
mDelegate.moveToCenter( latLng );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,4 +90,12 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
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'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
|
||||
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
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'
|
||||
@@ -27,8 +25,11 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
@@ -11,10 +13,23 @@ public class MogoModulePaths {
|
||||
/**
|
||||
* 地图模块 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'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
|
||||
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
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'
|
||||
@@ -33,15 +31,29 @@ android {
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation project(":foudations:mogo-utils")
|
||||
implementation project(":foudations:mogo-commons")
|
||||
implementation project(':modules:mogo-module-common')
|
||||
implementation project(':modules:mogo-module-map')
|
||||
implementation project(':services:mogo-service-api')
|
||||
implementation project(':services:mogo-service')
|
||||
implementation project(':demo:demo-module-map')
|
||||
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-commons")
|
||||
implementation project(':modules:mogo-module-common')
|
||||
implementation project(':modules:mogo-module-map')
|
||||
implementation project(':services:mogo-service-api')
|
||||
implementation project(':services:mogo-service')
|
||||
implementation project(':demo:demo-module-map')
|
||||
implementation project(':modules:mogo-module-apps')
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
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.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.MogoModulesManager;
|
||||
import com.mogo.module.main.cards.OrientedViewPager;
|
||||
import com.mogo.module.main.cards.VerticalStackTransformer;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.map.IMogoMapService;
|
||||
import com.mogo.service.module.IMogoModuleProvider;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -19,10 +28,19 @@ import java.util.Collection;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MainActivity extends MvpActivity< MainView, MainPresenter > implements MainView {
|
||||
public class MainActivity extends MvpActivity< MainView, MainPresenter > implements MainView,
|
||||
IMogoLocationListener {
|
||||
|
||||
IMogoMapService mMogoMapService;
|
||||
MogoModulesHandler mMogoModuleHandler;
|
||||
private IMogoMapService mMogoMapService;
|
||||
private MogoModulesHandler mMogoModuleHandler;
|
||||
|
||||
private OrientedViewPager mCardsContainer;
|
||||
private CardModulesAdapter mCardModulesAdapter;
|
||||
|
||||
/**
|
||||
* 主模块管控定位,可以向各个模块发送统一定位信息
|
||||
*/
|
||||
private IMogoLocationClient mLocationClient;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -31,30 +49,57 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
|
||||
@Override
|
||||
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 );
|
||||
mMogoMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation();
|
||||
if ( mMogoMapService != null ) {
|
||||
mMogoMapService.registerHostMapListener( mMogoModuleHandler );
|
||||
mMogoMapService.registerHostNaviListener( mMogoModuleHandler );
|
||||
mMogoMapService.getHostListenerRegister().registerHostMapListener( mMogoModuleHandler );
|
||||
mMogoMapService.getHostListenerRegister().registerHostNaviListener( mMogoModuleHandler );
|
||||
mMogoMapService.getHostListenerRegister().registerMarkerClickListener( mMogoModuleHandler );
|
||||
}
|
||||
mMogoModuleHandler.loadMap( R.id.module_main_id_map_fragment_container );
|
||||
|
||||
Collection< IMogoModuleProvider > providers = mMogoModuleHandler.loadCards();
|
||||
for ( IMogoModuleProvider provider : providers ) {
|
||||
if ( provider == null ) {
|
||||
continue;
|
||||
}
|
||||
if ( provider.getType() == IMogoModuleProvider.TYPE_FRAGMENT ) {
|
||||
final Fragment fragment = provider.createFragment( this, null );
|
||||
if ( fragment != null ) {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.add( R.id.module_main_id_fragment_container, fragment )
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
}
|
||||
mMogoModuleHandler.setEnable( providers.iterator().next().getModuleName() );
|
||||
mMogoModuleHandler.loadMap( R.id.module_main_id_map_fragment_container );
|
||||
mMogoModuleHandler.loadAppsList( R.id.module_main_id_fragment_container );
|
||||
|
||||
mLocationClient = mMogoMapService.getSingletonLocationClient( getApplicationContext() );
|
||||
mLocationClient.addLocationListener( this );
|
||||
mLocationClient.start();
|
||||
|
||||
List< IMogoModuleProvider > providers = mMogoModuleHandler.loadCards();
|
||||
mCardModulesAdapter = new CardModulesAdapter( this, providers );
|
||||
mCardsContainer.setOffscreenPageLimit( providers.size() );
|
||||
mCardsContainer.setPageTransformer( true, new VerticalStackTransformer( this ) );
|
||||
mCardsContainer.setAdapter( mCardModulesAdapter );
|
||||
mCardsContainer.setCurrentItem( 0 );
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -62,4 +107,26 @@ public class MainActivity extends MvpActivity< MainView, MainPresenter > impleme
|
||||
protected MainPresenter createPresenter() {
|
||||
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