* Launcher application
*/
-public class MogoApplication extends Application {
+public class MogoApplication extends AbsMogoApplication {
@Override
public void onCreate() {
diff --git a/build.gradle b/build.gradle
index 53d9475dce..9d1ce53a72 100644
--- a/build.gradle
+++ b/build.gradle
@@ -18,7 +18,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
-
+ classpath "com.alibaba:arouter-register:1.0.2"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
diff --git a/config.gradle b/config.gradle
index 5d361f9b3d..0fffb1fc4e 100644
--- a/config.gradle
+++ b/config.gradle
@@ -43,11 +43,17 @@ ext {
fresco : 'com.facebook.fresco:fresco:1.1.0',
// 公司服务 - 语音
aiassist : "com.zhidaoauto.common:service:1.0.4",
+ // 公司服务 - 埋点
+ analytics : "com.elegant.analytics:analytics:1.1.19",
// retrofit
retrofit : "com.squareup.retrofit2:retrofit:2.3.0",
retrofitadapter : "com.squareup.retrofit2:adapter-rxjava:2.1.0",
retrofitconvertergson : "com.squareup.retrofit2:converter-gson:2.3.0",
retrofitconverterscalars: "com.squareup.retrofit2:converter-scalars:2.1.0",
+
+ // leakcanary
+ leakcanary : 'com.squareup.leakcanary:leakcanary-android:1.5.4',
+ leakcanarynoop : 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4',
]
}
\ No newline at end of file
diff --git a/demo/demo-module-map/.gitignore b/demo/demo-module-map/.gitignore
new file mode 100644
index 0000000000..796b96d1c4
--- /dev/null
+++ b/demo/demo-module-map/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/demo/demo-module-map/build.gradle b/demo/demo-module-map/build.gradle
new file mode 100644
index 0000000000..0290a16845
--- /dev/null
+++ b/demo/demo-module-map/build.gradle
@@ -0,0 +1,46 @@
+apply plugin: 'com.android.library'
+apply plugin: 'com.alibaba.arouter'
+
+android {
+ compileSdkVersion 29
+ buildToolsVersion "29.0.2"
+
+
+ defaultConfig {
+ minSdkVersion 19
+ targetSdkVersion 29
+ versionCode 1
+ versionName "1.0"
+
+ 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'])
+
+ 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
+}
diff --git a/demo/demo-module-map/consumer-rules.pro b/demo/demo-module-map/consumer-rules.pro
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/demo/demo-module-map/proguard-rules.pro b/demo/demo-module-map/proguard-rules.pro
new file mode 100644
index 0000000000..f1b424510d
--- /dev/null
+++ b/demo/demo-module-map/proguard-rules.pro
@@ -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
diff --git a/demo/demo-module-map/src/main/AndroidManifest.xml b/demo/demo-module-map/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..b4ca7f3c79
--- /dev/null
+++ b/demo/demo-module-map/src/main/AndroidManifest.xml
@@ -0,0 +1,2 @@
+
+ * 描述 + */ + +public class DemoCardViewFragment extends MvpFragment< IView, Presenter< IView > > + implements IView, + IMogoMarkerClickListener, + IMogoModuleLifecycle, + IMogoMapListener, + IMogoPoiSearchListener, + ILocationListener { + + private static final String TAG = "demo.DemoCardViewProvider"; + + private Button mAddMarker; + private Button mAddMarkers; + + private Bitmap mMarkerIcon; + private Bitmap mClickedMarkerIcon; + private TextView mLoc; + + private IMogoMarker mLastClickedMarker; + + private IMogoMapService mMapService; + private IMogoPoiSearch mPoiSearch; + private IMogoLocationClient mLocationClient; + + @Override + protected int getLayoutId() { + return R.layout.demo_module_card_view; + } + + @Override + protected void initViews() { + + mMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( getContext() ); + mPoiSearch = mMapService.getPoiSearch( getContext(), new MogoPoiSearchQuery() ); + mPoiSearch.setPoiSearchListener( this ); + mLocationClient = mMapService.getSingletonLocationClient( getContext() ); + mLocationClient.addLocationListener( this ); + mLocationClient.start( 1_000L ); + + mLoc = findViewById( R.id.demo_module_id_loc ); + + mMarkerIcon = BitmapFactory.decodeResource( getResources(), R.drawable.ic_launcher ); + mClickedMarkerIcon = BitmapFactory.decodeResource( getResources(), R.drawable.ic_launcher_round ); + mAddMarker = findViewById( R.id.demo_module_id_add_marker ); + mAddMarker.setOnClickListener( new View.OnClickListener() { + @Override + public void onClick( View v ) { + IMogoMapService ims = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation(); + MogoMarkerOptions options = new MogoMarkerOptions() + .icon( mMarkerIcon ) + .latitude( 39.974525d ) + .longitude( 116.41733d ); + IMogoMarker marker = ims.addMarker( options ); + marker.setOnMarkerClickListener( DemoCardViewFragment.this ); + } + } ); + mAddMarkers = findViewById( R.id.demo_module_id_add_markers ); + mAddMarkers.setOnClickListener( new View.OnClickListener() { + @Override + public void onClick( View v ) { + IMogoMapService ims = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation(); + + for ( int i = 0; i < 10; i++ ) { + MogoMarkerOptions options = new MogoMarkerOptions() + .icon( mMarkerIcon ) + .latitude( 39.974525d + new Random().nextDouble() ) + .longitude( 116.41733d + new Random().nextDouble() ); + List< IMogoMarker > iMogoMarkers = ims.addMarkers( new ArrayList<>( Arrays.asList( options ) ), true ); + for ( IMogoMarker iMogoMarker : iMogoMarkers ) { + iMogoMarker.setOnMarkerClickListener( DemoCardViewFragment.this ); + } + } + + } + } ); + + } + + @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; + return true; + } + + @NonNull + @Override + protected Presenter createPresenter() { + return new Presenter( this ) { + }; + } + + @Override + public void onPerform() { + TipToast.shortTip( "卡片有效" ); + } + + @Override + public void onDisable() { + TipToast.shortTip( "卡片无效" ); + } + + + @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 ) { + + } + + @Override + public void onPoiItemSearched( MogoPoiItem item, int errorCode ) { + if ( item == null ) { + return; + } + new AlertDialog.Builder( getContext() ) + .setTitle( item.getTitle() ) + .setMessage( + new StringBuilder() + .append( "adCode:" ).append( item.getAdCode() ).append( "\n" ) + .append( "cityCode:" ).append( item.getCityCode() ).append( "\n" ) + .append( "email:" ).append( item.getEmail() ).append( "\n" ) + .append( "tel:" ).append( item.getTel() ).append( "\n" ) + ) + .setNegativeButton( "知道了", new DialogInterface.OnClickListener() { + @Override + public void onClick( DialogInterface dialog, int which ) { + dialog.dismiss(); + } + } ) + .show(); + } + + @Override + public void onLocationChanged( MogoLocation location ) { + Logger.i( TAG, location.toString() ); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + getViewLifecycleOwner().getLifecycle().removeObserver( mPresenter ); + mLocationClient.removeLocationListener( this ); + if ( mLastClickedMarker != null ) { + mLastClickedMarker.destroy(); + mLastClickedMarker = null; + } + mMapService = null; + mPoiSearch = null; + mLocationClient = null; + } +} diff --git a/demo/demo-module-map/src/main/java/com/mogo/demo/module/map/DemoCardViewProvider.java b/demo/demo-module-map/src/main/java/com/mogo/demo/module/map/DemoCardViewProvider.java new file mode 100644 index 0000000000..a9cc98d857 --- /dev/null +++ b/demo/demo-module-map/src/main/java/com/mogo/demo/module/map/DemoCardViewProvider.java @@ -0,0 +1,63 @@ +package com.mogo.demo.module.map; + +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.module.common.MogoModulePaths; +import com.mogo.service.module.IMogoModuleLifecycle; +import com.mogo.service.module.IMogoModuleProvider; + +/** + * @author congtaowang + * @since 2019-12-24 + *
+ * 描述
+ */
+@Route( path = MogoModulePaths.PATH_MODULE_DEMO )
+public class DemoCardViewProvider implements IMogoModuleProvider {
+
+ private DemoCardViewFragment fragment;
+
+ @Override
+ public Fragment createFragment( Context context, Bundle data ) {
+ fragment = new DemoCardViewFragment();
+ fragment.setArguments( data );
+ return fragment;
+ }
+
+ @Override
+ public void init( Context context ) {
+
+ }
+
+ @Override
+ public String getModuleName() {
+ return MogoModulePaths.PATH_MODULE_DEMO;
+ }
+
+ @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;
+ }
+}
diff --git a/demo/demo-module-map/src/main/res/drawable/ic_launcher.png b/demo/demo-module-map/src/main/res/drawable/ic_launcher.png
new file mode 100644
index 0000000000..898f3ed59a
Binary files /dev/null and b/demo/demo-module-map/src/main/res/drawable/ic_launcher.png differ
diff --git a/demo/demo-module-map/src/main/res/drawable/ic_launcher_round.png b/demo/demo-module-map/src/main/res/drawable/ic_launcher_round.png
new file mode 100644
index 0000000000..dae5e08234
Binary files /dev/null and b/demo/demo-module-map/src/main/res/drawable/ic_launcher_round.png differ
diff --git a/demo/demo-module-map/src/main/res/layout/demo_module_card_view.xml b/demo/demo-module-map/src/main/res/layout/demo_module_card_view.xml
new file mode 100644
index 0000000000..e0a6bb02ac
--- /dev/null
+++ b/demo/demo-module-map/src/main/res/layout/demo_module_card_view.xml
@@ -0,0 +1,37 @@
+
+
+ * 埋点 + */ +public class AnalyticsUtils { + + /** + * 埋点 + * + * @param event 事件名称 + * @param properties 事件参数 + */ + public static void track( String event, Map< String, Object > properties ) { + Analytics.getInstance().setCustomParams( ParamUtils.getAnalyticsParameters() ); + Analytics.getInstance().track( event, properties ); + } +} diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/debug/DebugConfig.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/debug/DebugConfig.java new file mode 100644 index 0000000000..543120c5a6 --- /dev/null +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/debug/DebugConfig.java @@ -0,0 +1,20 @@ +package com.mogo.commons.debug; + +/** + * @author congtaowang + * @since 2019-12-23 + *
+ * 各个莫快递调试信息控制接口 + */ +public class DebugConfig { + + private static boolean sDebug = true; + + public static boolean isDebug() { + return sDebug; + } + + public static void setDebug( boolean sDebug ) { + DebugConfig.sDebug = sDebug; + } +} diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/IView.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/IView.java new file mode 100644 index 0000000000..0947bedd03 --- /dev/null +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/IView.java @@ -0,0 +1,14 @@ +package com.mogo.commons.mvp; + +import android.content.Context; + +/** + * @author congtaowang + * @since 2019-12-23 + *
+ * mvp的view接口 + */ +public interface IView { + + Context getContext(); +} diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpActivity.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpActivity.java new file mode 100644 index 0000000000..8dfe19d974 --- /dev/null +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpActivity.java @@ -0,0 +1,65 @@ +package com.mogo.commons.mvp; + +import android.content.Context; +import android.os.Bundle; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +/** + * @author congtaowang + * @since 2019-12-23 + *
+ * mvp 的 activity + */ +public abstract class MvpActivity< V extends IView, P extends Presenter< V > > + extends AppCompatActivity implements IView { + + protected P mPresenter; + + @Override + protected void onCreate( @Nullable Bundle savedInstanceState ) { + super.onCreate( savedInstanceState ); + setContentView( getLayoutId() ); + initViews(); + mPresenter = createPresenter(); + getLifecycle().addObserver( mPresenter ); + } + + /** + * 布局资源 + * + * @return + */ + protected abstract int getLayoutId(); + + /** + * 初始化控件,必须在初始化完成之后才可以实例化presenter,避免 + * presenter 生命周期错乱 + */ + protected abstract void initViews(); + + /** + * 创建 presenter 实例 + * + * @return + */ + @NonNull + protected abstract P createPresenter(); + + @Override + public Context getContext() { + return this; + } + + @Override + protected void onDestroy() { + super.onDestroy(); + getLifecycle().removeObserver( mPresenter ); + if ( mPresenter != null ) { + getLifecycle().removeObserver( mPresenter ); + } + mPresenter = null; + } +} diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpFragment.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpFragment.java new file mode 100644 index 0000000000..e76de3deb2 --- /dev/null +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/MvpFragment.java @@ -0,0 +1,96 @@ +package com.mogo.commons.mvp; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + +/** + * @author congtaowang + * @since 2019-12-23 + *
+ * mvp fragment + */ +public abstract class MvpFragment< V extends IView, P extends Presenter< V > > extends Fragment implements IView { + + private Context mContext; + protected P mPresenter; + private View mRootView; + + @Override + public void onAttach( Context context ) { + super.onAttach( context ); + mContext = context; + } + + @Nullable + @Override + public View onCreateView( @NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState ) { + return inflater.inflate( getLayoutId(), container, false ); + } + + @Override + public void onViewCreated( @NonNull View view, @Nullable Bundle savedInstanceState ) { + super.onViewCreated( view, savedInstanceState ); + mRootView = view; + } + + /** + * 布局资源 + * + * @return + */ + protected abstract int getLayoutId(); + + @Override + public void onActivityCreated( @Nullable Bundle savedInstanceState ) { + super.onActivityCreated( savedInstanceState ); + initViews(); + mPresenter = createPresenter(); + getViewLifecycleOwner().getLifecycle().addObserver( mPresenter ); + } + + /** + * 初始化控件,必须在初始化完成之后才可以实例化presenter,避免 + * presenter 生命周期错乱 + */ + protected abstract void initViews(); + + /** + * 创建 presenter 实例 + * + * @return + */ + @NonNull + protected abstract P createPresenter(); + + @Nullable + protected < T extends View > T findViewById( int id ) { + if ( mRootView != null ) { + return ( T ) mRootView.findViewById( id ); + } + return null; + } + + @Nullable + @Override + public Context getContext() { + return mContext; + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if ( mPresenter != null ) { + getViewLifecycleOwner().getLifecycle().removeObserver( mPresenter ); + } + mPresenter = null; + mRootView = null; + mContext = null; + } +} diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/Presenter.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/Presenter.java new file mode 100644 index 0000000000..a39b549037 --- /dev/null +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/mvp/Presenter.java @@ -0,0 +1,52 @@ +package com.mogo.commons.mvp; + +import androidx.annotation.NonNull; +import androidx.lifecycle.Lifecycle; +import androidx.lifecycle.LifecycleObserver; +import androidx.lifecycle.LifecycleOwner; +import androidx.lifecycle.OnLifecycleEvent; + +/** + * @author congtaowang + * @since 2019-12-23 + *
+ * mvp 的 presenter + */ +public abstract class Presenter< V extends IView > implements LifecycleObserver { + + private V mView; + + public Presenter( V view ) { + this.mView = view; + } + + @OnLifecycleEvent( Lifecycle.Event.ON_CREATE ) + public void onCreate( @NonNull LifecycleOwner owner ) { + } + + @OnLifecycleEvent( Lifecycle.Event.ON_START ) + public void onStart( @NonNull LifecycleOwner owner ) { + } + + @OnLifecycleEvent( Lifecycle.Event.ON_RESUME ) + public void onResume( @NonNull LifecycleOwner owner ) { + } + + @OnLifecycleEvent( Lifecycle.Event.ON_PAUSE ) + public void onPause( @NonNull LifecycleOwner owner ) { + } + + @OnLifecycleEvent( Lifecycle.Event.ON_STOP ) + public void onStop( @NonNull LifecycleOwner owner ) { + } + + @OnLifecycleEvent( Lifecycle.Event.ON_DESTROY ) + public void onDestroy( @NonNull LifecycleOwner owner ) { + } + + @OnLifecycleEvent( Lifecycle.Event.ON_ANY ) + public void onLifecycleChanged( + @NonNull LifecycleOwner owner, + @NonNull Lifecycle.Event event ) { + } +} diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/network/ParamUtils.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/network/ParamUtils.java new file mode 100644 index 0000000000..f4544ed960 --- /dev/null +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/network/ParamUtils.java @@ -0,0 +1,16 @@ +package com.mogo.commons.network; + +import java.util.Map; + +/** + * @author congtaowang + * @since 2019-12-23 + *
+ * 描述
+ */
+public class ParamUtils {
+
+ public static Map< String, Object > getAnalyticsParameters() {
+ return null;
+ }
+}
diff --git a/foudations/mogo-utils/src/main/java/com/mogo/utils/ResourcesHelper.java b/foudations/mogo-utils/src/main/java/com/mogo/utils/ResourcesHelper.java
index c46161df83..8afecd5fb2 100644
--- a/foudations/mogo-utils/src/main/java/com/mogo/utils/ResourcesHelper.java
+++ b/foudations/mogo-utils/src/main/java/com/mogo/utils/ResourcesHelper.java
@@ -10,63 +10,72 @@ import android.util.DisplayMetrics;
public class ResourcesHelper {
- public static Resources getResources( Context context){
+ public static Resources getResources( Context context ) {
return context.getResources();
}
- public static int getColor( Context context, int rid) {
- return getResources(context).getColor(rid);
+ public static int getColor( Context context, int rid ) {
+ return getResources( context ).getColor( rid );
}
- public static ColorStateList getColorStateList( Context context, int rid) {
- return getResources(context).getColorStateList(rid);
+ public static ColorStateList getColorStateList( Context context, int rid ) {
+ return getResources( context ).getColorStateList( rid );
}
- public static String getString( Context context, int rid) {
- return getResources(context).getString(rid);
+ public static String getString( Context context, int rid ) {
+ return getResources( context ).getString( rid );
}
- public static String getString( Context context, int rid, int param1, int param2) {
- return getResources(context).getString(rid, param1, param2);
+ public static String getString( Context context, int rid, int param1, int param2 ) {
+ return getResources( context ).getString( rid, param1, param2 );
}
- public static String getString( Context context, int rid, String str) {
- return getResources(context).getString(rid, str);
+ public static String getString( Context context, int rid, String str ) {
+ return getResources( context ).getString( rid, str );
}
- public static String[] getStringArray( Context context, int rid) {
- return getResources(context).getStringArray(rid);
+ public static String[] getStringArray( Context context, int rid ) {
+ return getResources( context ).getStringArray( rid );
}
- public static Drawable getDrawable( Context context, int rid) {
- return getResources(context).getDrawable(rid);
+ public static Drawable getDrawable( Context context, int rid ) {
+ return getResources( context ).getDrawable( rid );
}
- public static float getDimension( Context context, int rid) {
- return getResources(context).getDimension(rid);
+ public static float getDimension( Context context, int rid ) {
+ return getResources( context ).getDimension( rid );
}
- public static DisplayMetrics getDisplayMetrics( Context context) {
- return getResources(context).getDisplayMetrics();
+ public static DisplayMetrics getDisplayMetrics( Context context ) {
+ return getResources( context ).getDisplayMetrics();
}
- public static int getDisplayMetrics( Context context, int x) {
- return getResources(context).getDimensionPixelSize(x);
+ public static int getDisplayMetrics( Context context, int x ) {
+ return getResources( context ).getDimensionPixelSize( x );
}
- public static int getDimensionPixelSize( Context context, int x) {
- return getResources(context).getDimensionPixelSize(x);
+ public static int getDimensionPixelSize( Context context, int x ) {
+ return getResources( context ).getDimensionPixelSize( x );
}
- public static int getInteger( Context context, int rid) {
- return getResources(context).getInteger(rid);
+ public static int getInteger( Context context, int rid ) {
+ return getResources( context ).getInteger( rid );
}
- public static XmlResourceParser getXml( Context context, int rid) {
- return getResources(context).getXml(rid);
+ public static XmlResourceParser getXml( Context context, int rid ) {
+ return getResources( context ).getXml( rid );
}
- public static Configuration getConfiguration( Context context) {
- return getResources(context).getConfiguration();
+ public static Configuration getConfiguration( Context context ) {
+ return getResources( context ).getConfiguration();
+ }
+
+ public static String getResNameById( Context context, int id ) {
+ try {
+ return context.getResources().getResourceName( id );
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ return String.valueOf( id );
+ }
}
}
diff --git a/foudations/mogo-utils/src/main/java/com/mogo/utils/SoftKeyBoardJobber.java b/foudations/mogo-utils/src/main/java/com/mogo/utils/SoftKeyBoardJobber.java
new file mode 100644
index 0000000000..ee88b09c3d
--- /dev/null
+++ b/foudations/mogo-utils/src/main/java/com/mogo/utils/SoftKeyBoardJobber.java
@@ -0,0 +1,121 @@
+package com.mogo.utils;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Rect;
+import android.os.Build;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewTreeObserver;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+
+public class SoftKeyBoardJobber {
+
+ public static boolean hideIfNecessary( Activity context, MotionEvent ev ) {
+ if ( ev.getAction() == MotionEvent.ACTION_DOWN ) {
+ View v = context.getCurrentFocus();
+ if ( isShouldHideInput( v, ev ) ) {
+ InputMethodManager imm = ( InputMethodManager ) context.getSystemService( Context.INPUT_METHOD_SERVICE );
+ if ( imm != null ) {
+ imm.hideSoftInputFromWindow( v.getWindowToken(), 0 );
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private static boolean isShouldHideInput( View v, MotionEvent event ) {
+ if ( v != null && ( v instanceof EditText ) ) {
+ int[] leftTop = {0, 0};
+ // 获取输入框当前的location位置
+ v.getLocationInWindow( leftTop );
+ int left = leftTop[0];
+ int top = leftTop[1];
+ int bottom = top + v.getHeight();
+ int right = left + v.getWidth();
+ return !( event.getX() > left && event.getX() < right && event.getY() > top && event.getY() < bottom );
+ }
+ return false;
+ }
+
+ public static void hide( Context context, View v ) {
+ InputMethodManager imm = getInputMethodManager( context );
+ if ( imm != null ) {
+ imm.hideSoftInputFromWindow( v.getWindowToken(), 0 );
+ }
+ }
+
+ public static void show( Context context ) {
+ InputMethodManager imm = getInputMethodManager( context );
+ if ( imm != null ) {
+ imm.toggleSoftInput( 0, InputMethodManager.HIDE_NOT_ALWAYS );
+ }
+ }
+
+ private static InputMethodManager imm = null;
+
+ private static InputMethodManager getInputMethodManager( Context context ) {
+ if ( imm == null ) {
+ imm = ( InputMethodManager ) context.getSystemService( Context.INPUT_METHOD_SERVICE );
+ }
+ return imm;
+ }
+
+ public interface OnSoftKeyboardChangeListener {
+ void onSoftKeyBoardChange( int softKeyboardHeight, boolean visible );
+ }
+
+ public static ViewTreeObserver.OnGlobalLayoutListener observeSoftKeyboard( Activity activity, final OnSoftKeyboardChangeListener listener ) {
+ if ( !isAliveActivity( activity ) || listener == null ) {
+ return null;
+ }
+ final View decorView = activity.getWindow().getDecorView();
+ ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
+
+ int previousKeyboardHeight = -1;
+ Rect rect = new Rect();
+ boolean lastVisibleState = false;
+
+ @Override
+ public void onGlobalLayout() {
+ rect.setEmpty();
+ decorView.getWindowVisibleDisplayFrame( rect );
+ int displayHeight = rect.bottom - rect.top;
+ int height = decorView.getHeight() - rect.top;
+ int keyboardHeight = height - displayHeight;
+ if ( previousKeyboardHeight != keyboardHeight ) {
+ boolean hide = ( double ) displayHeight / height > 0.8;
+ if ( hide != lastVisibleState ) {
+ listener.onSoftKeyBoardChange( keyboardHeight, !hide );
+ lastVisibleState = hide;
+ }
+ }
+ previousKeyboardHeight = height;
+ }
+ };
+ decorView.getViewTreeObserver().addOnGlobalLayoutListener( onGlobalLayoutListener );
+ return onGlobalLayoutListener;
+ }
+
+ public static void removeSoftKeyboardObserver( Activity activity, ViewTreeObserver.OnGlobalLayoutListener listener ) {
+ if ( !isAliveActivity( activity ) || listener == null ) {
+ return;
+ }
+ final View decorView = activity.getWindow().getDecorView();
+ if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN ) {
+ decorView.getViewTreeObserver().removeOnGlobalLayoutListener( listener );
+ } else {
+ decorView.getViewTreeObserver().removeGlobalOnLayoutListener( listener );
+ }
+ }
+
+ private static boolean isAliveActivity( Activity activity ) {
+ return activity != null
+ && activity.getWindow() != null
+ && activity.getWindow().getDecorView() != null
+ && activity.getWindow().getDecorView().getViewTreeObserver() != null;
+ }
+
+}
diff --git a/foudations/mogo-utils/src/main/java/com/mogo/utils/SoftKeyboardUtils.java b/foudations/mogo-utils/src/main/java/com/mogo/utils/SoftKeyboardUtils.java
deleted file mode 100644
index ed4cf52ce4..0000000000
--- a/foudations/mogo-utils/src/main/java/com/mogo/utils/SoftKeyboardUtils.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.mogo.utils;
-
-import android.content.Context;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
-
-/**
- * Created by congtaowang on 2018/12/20.
- */
-public class SoftKeyboardUtils {
-
- public static void show( Context context ) {
- try {
- InputMethodManager imm = ( InputMethodManager ) context.getSystemService( Context.INPUT_METHOD_SERVICE );
- if ( imm != null ) {
- imm.toggleSoftInput( 0, InputMethodManager.HIDE_NOT_ALWAYS );
- }
- } catch ( Exception e ) {
- e.printStackTrace();
- }
- }
-
- public static void hidden( Context context, EditText editText ) {
- try {
- InputMethodManager imm = ( InputMethodManager ) context.getSystemService( Context.INPUT_METHOD_SERVICE );
- if ( imm != null ) {
- imm.hideSoftInputFromWindow( editText.getWindowToken(), 0 );
- }
- } catch ( Exception e ) {
- e.printStackTrace();
- }
- }
-}
diff --git a/foudations/mogo-utils/src/main/java/com/mogo/utils/storage/lrucache/CacheUtil.java b/foudations/mogo-utils/src/main/java/com/mogo/utils/storage/lrucache/CacheUtil.java
new file mode 100644
index 0000000000..ca7c761c06
--- /dev/null
+++ b/foudations/mogo-utils/src/main/java/com/mogo/utils/storage/lrucache/CacheUtil.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.mogo.utils.storage.lrucache;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.nio.charset.Charset;
+
+/** Junk drawer of utility methods. */
+final class CacheUtil {
+ static final Charset US_ASCII = Charset.forName("US-ASCII");
+ static final Charset UTF_8 = Charset.forName("UTF-8");
+
+ private CacheUtil() {
+ }
+
+ static String readFully( Reader reader) throws IOException {
+ try {
+ StringWriter writer = new StringWriter();
+ char[] buffer = new char[1024];
+ int count;
+ while ((count = reader.read(buffer)) != -1) {
+ writer.write(buffer, 0, count);
+ }
+ return writer.toString();
+ } finally {
+ reader.close();
+ }
+ }
+
+ /**
+ * Deletes the imageContent of {@code dir}. Throws an IOException if any file
+ * could not be deleted, or if {@code dir} is not a readable directory.
+ */
+ static void deleteContents( File dir) throws IOException {
+ File[] files = dir.listFiles();
+ if (files == null) {
+ throw new IOException("not a readable directory: " + dir);
+ }
+ for ( File file : files) {
+ if (file.isDirectory()) {
+ deleteContents(file);
+ }
+ if (!file.delete()) {
+ throw new IOException("failed to delete file: " + file);
+ }
+ }
+ }
+
+ static void closeQuietly(/*Auto*/Closeable closeable) {
+ if (closeable != null) {
+ try {
+ closeable.close();
+ } catch ( RuntimeException rethrown) {
+ throw rethrown;
+ } catch ( Exception ignored) {
+ }
+ }
+ }
+}
diff --git a/foudations/mogo-utils/src/main/java/com/mogo/utils/storage/lrucache/DiskCacheManager.java b/foudations/mogo-utils/src/main/java/com/mogo/utils/storage/lrucache/DiskCacheManager.java
new file mode 100644
index 0000000000..a37aa56d37
--- /dev/null
+++ b/foudations/mogo-utils/src/main/java/com/mogo/utils/storage/lrucache/DiskCacheManager.java
@@ -0,0 +1,374 @@
+package com.mogo.utils.storage.lrucache;
+
+import android.content.Context;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Serializable;
+
+public class DiskCacheManager {
+
+ private static DiskLruCache mDiskLruCache = null;
+ private DiskLruCache.Editor mEditor = null;
+ private DiskLruCache.Snapshot mSnapshot = null;
+ public static final long CACHE_MAXSIZE = 10 * 1024 * 1024;
+
+ public DiskCacheManager( Context context, String uniqueName) {
+ try {
+ if (mDiskLruCache != null) {
+ mDiskLruCache.close();
+ mDiskLruCache = null;
+ }
+ File cacheFile = getCacheFile(context, uniqueName);
+ mDiskLruCache = DiskLruCache.open(cacheFile, 1, 1, CACHE_MAXSIZE);
+ } catch ( IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 获取缓存的路径 两个路径在卸载程序时都会删除,因此不会在卸载后还保留乱七八糟的缓存
+ * 有SD卡时获取 /sdcard/Android/data/ The cache stores its data in a directory on the filesystem. This
+ * directory must be exclusive to the cache; the cache may delete or overwrite
+ * files from its directory. It is an error for multiple processes to use the
+ * same cache directory at the same time.
+ *
+ * This cache limits the number of bytes that it will store on the
+ * filesystem. When the number of stored bytes exceeds the limit, the cache will
+ * remove entries in the background until the limit is satisfied. The limit is
+ * not strict: the cache may temporarily exceed it while waiting for files to be
+ * deleted. The limit does not include filesystem overhead or the cache
+ * journal so space-sensitive applications should set a conservative limit.
+ *
+ * Clients call {@link #edit} to create or update the values of an entry. An
+ * entry may have only one editor at one time; if a value is not available to be
+ * edited then {@link #edit} will return null.
+ * Clients call {@link #get} to read a snapshot of an entry. The read will
+ * observe the value at the time that {@link #get} was called. Updates and
+ * removals after the call do not impact ongoing reads.
+ *
+ * This class is tolerant of some I/O errors. If files are missing from the
+ * filesystem, the corresponding entries will be dropped from the cache. If
+ * an error occurs while writing a cache value, the edit will fail silently.
+ * Callers should handle other problems by catching {@code IOException} and
+ * responding appropriately.
+ */
+public final class DiskLruCache implements Closeable {
+ static final String JOURNAL_FILE = "journal";
+ static final String JOURNAL_FILE_TEMP = "journal.tmp";
+ static final String JOURNAL_FILE_BACKUP = "journal.bkp";
+ static final String MAGIC = "libcore.io.DiskLruCache";
+ static final String VERSION_1 = "1";
+ static final long ANY_SEQUENCE_NUMBER = -1;
+ static final String STRING_KEY_PATTERN = "[a-z0-9_-]{1,120}";
+ static final Pattern LEGAL_KEY_PATTERN = Pattern.compile(STRING_KEY_PATTERN);
+ private static final String CLEAN = "CLEAN";
+ private static final String DIRTY = "DIRTY";
+ private static final String REMOVE = "REMOVE";
+ private static final String READ = "READ";
+
+ /*
+ * This cache uses a journal file named "journal". A typical journal file
+ * looks like this:
+ * libcore.io.DiskLruCache
+ * 1
+ * 100
+ * 2
+ *
+ * CLEAN 3400330d1dfc7f3f7f4b8d4d803dfcf6 832 21054
+ * DIRTY 335c4c6028171cfddfbaae1a9c313c52
+ * CLEAN 335c4c6028171cfddfbaae1a9c313c52 3934 2342
+ * REMOVE 335c4c6028171cfddfbaae1a9c313c52
+ * DIRTY 1ab96a171faeeee38496d8b330771a7a
+ * CLEAN 1ab96a171faeeee38496d8b330771a7a 1600 234
+ * READ 335c4c6028171cfddfbaae1a9c313c52
+ * READ 3400330d1dfc7f3f7f4b8d4d803dfcf6
+ *
+ * The first five lines of the journal form its header. They are the
+ * constant string "libcore.io.DiskLruCache", the disk cache's version,
+ * the application's version, the value count, and a blank line.
+ *
+ * Each of the subsequent lines in the file is a record of the state of a
+ * cache entry. Each line contains space-separated values: a state, a key,
+ * and optional state-specific values.
+ * o DIRTY lines track that an entry is actively being created or updated.
+ * Every successful DIRTY action should be followed by a CLEAN or REMOVE
+ * action. DIRTY lines without a matching CLEAN or REMOVE indicate that
+ * temporary files may need to be deleted.
+ * o CLEAN lines track a cache entry that has been successfully published
+ * and may be read. A publish line is followed by the lengths of each of
+ * its values.
+ * o READ lines track accesses for LRU.
+ * o REMOVE lines track entries that have been deleted.
+ *
+ * The journal file is appended to as cache operations occur. The journal may
+ * occasionally be compacted by dropping redundant lines. A temporary file named
+ * "journal.tmp" will be used during compaction; that file should be deleted if
+ * it exists when the cache is opened.
+ */
+
+ private final File directory;
+ private final File journalFile;
+ private final File journalFileTmp;
+ private final File journalFileBackup;
+ private final int appVersion;
+ private long maxSize;
+ private final int valueCount;
+ private long size = 0;
+ private Writer journalWriter;
+ private final LinkedHashMap< String, Entry> lruEntries =
+ new LinkedHashMap< String, Entry>(0, 0.75f, true);
+ private int redundantOpCount;
+
+ /**
+ * To differentiate between old and current snapshots, each entry is given
+ * a sequence number each time an edit is committed. A snapshot is stale if
+ * its sequence number is not equal to its entry's sequence number.
+ */
+ private long nextSequenceNumber = 0;
+
+ /** This cache uses a single background thread to evict entries. */
+ final ThreadPoolExecutor executorService =
+ new ThreadPoolExecutor(0, 1, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue< Runnable >());
+ private final Callable< Void > cleanupCallable = new Callable< Void >() {
+ public Void call() throws Exception {
+ synchronized (DiskLruCache.this) {
+ if (journalWriter == null) {
+ return null; // Closed.
+ }
+ trimToSize();
+ if (journalRebuildRequired()) {
+ rebuildJournal();
+ redundantOpCount = 0;
+ }
+ }
+ return null;
+ }
+ };
+
+ private DiskLruCache( File directory, int appVersion, int valueCount, long maxSize) {
+ this.directory = directory;
+ this.appVersion = appVersion;
+ this.journalFile = new File(directory, JOURNAL_FILE);
+ this.journalFileTmp = new File(directory, JOURNAL_FILE_TEMP);
+ this.journalFileBackup = new File(directory, JOURNAL_FILE_BACKUP);
+ this.valueCount = valueCount;
+ this.maxSize = maxSize;
+ }
+
+ /**
+ * Opens the cache in {@code directory}, creating a cache if none exists
+ * there.
+ *
+ * @param directory a writable directory
+ * @param valueCount the number of values per cache entry. Must be positive.
+ * @param maxSize the maximum number of bytes this cache should use to store
+ * @throws IOException if reading or writing the cache directory fails
+ */
+ public static DiskLruCache open( File directory, int appVersion, int valueCount, long maxSize)
+ throws IOException {
+ if (maxSize <= 0) {
+ throw new IllegalArgumentException("maxSize <= 0");
+ }
+ if (valueCount <= 0) {
+ throw new IllegalArgumentException("valueCount <= 0");
+ }
+
+ // If a bkp file exists, use it instead.
+ File backupFile = new File(directory, JOURNAL_FILE_BACKUP);
+ if (backupFile.exists()) {
+ File journalFile = new File(directory, JOURNAL_FILE);
+ // If journal file also exists just delete backup file.
+ if (journalFile.exists()) {
+ backupFile.delete();
+ } else {
+ renameTo(backupFile, journalFile, false);
+ }
+ }
+
+ // Prefer to pick up where we left off.
+ DiskLruCache cache = new DiskLruCache(directory, appVersion, valueCount, maxSize);
+ if (cache.journalFile.exists()) {
+ try {
+ cache.readJournal();
+ cache.processJournal();
+ return cache;
+ } catch ( IOException journalIsCorrupt) {
+ System.out
+ .println("DiskLruCache "
+ + directory
+ + " is corrupt: "
+ + journalIsCorrupt.getMessage()
+ + ", removing");
+ cache.delete();
+ }
+ }
+
+ // Create a new empty cache.
+ directory.mkdirs();
+ cache = new DiskLruCache(directory, appVersion, valueCount, maxSize);
+ cache.rebuildJournal();
+ return cache;
+ }
+
+ private void readJournal() throws IOException {
+ StrictLineReader reader = new StrictLineReader(new FileInputStream(journalFile), CacheUtil.US_ASCII);
+ try {
+ String magic = reader.readLine();
+ String version = reader.readLine();
+ String appVersionString = reader.readLine();
+ String valueCountString = reader.readLine();
+ String blank = reader.readLine();
+ if (!MAGIC.equals(magic)
+ || !VERSION_1.equals(version)
+ || !Integer.toString(appVersion).equals(appVersionString)
+ || !Integer.toString(valueCount).equals(valueCountString)
+ || !"".equals(blank)) {
+ throw new IOException("unexpected journal header: [" + magic + ", " + version + ", "
+ + valueCountString + ", " + blank + "]");
+ }
+
+ int lineCount = 0;
+ while (true) {
+ try {
+ readJournalLine(reader.readLine());
+ lineCount++;
+ } catch ( EOFException endOfJournal) {
+ break;
+ }
+ }
+ redundantOpCount = lineCount - lruEntries.size();
+
+ // If we ended on a truncated line, rebuild the journal before appending to it.
+ if (reader.hasUnterminatedLine()) {
+ rebuildJournal();
+ } else {
+ journalWriter = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(journalFile, true), CacheUtil.US_ASCII));
+ }
+ } finally {
+ CacheUtil.closeQuietly(reader);
+ }
+ }
+
+ private void readJournalLine( String line) throws IOException {
+ int firstSpace = line.indexOf(' ');
+ if (firstSpace == -1) {
+ throw new IOException("unexpected journal line: " + line);
+ }
+
+ int keyBegin = firstSpace + 1;
+ int secondSpace = line.indexOf(' ', keyBegin);
+ final String key;
+ if (secondSpace == -1) {
+ key = line.substring(keyBegin);
+ if (firstSpace == REMOVE.length() && line.startsWith(REMOVE)) {
+ lruEntries.remove(key);
+ return;
+ }
+ } else {
+ key = line.substring(keyBegin, secondSpace);
+ }
+
+ Entry entry = lruEntries.get(key);
+ if (entry == null) {
+ entry = new Entry(key);
+ lruEntries.put(key, entry);
+ }
+
+ if (secondSpace != -1 && firstSpace == CLEAN.length() && line.startsWith(CLEAN)) {
+ String[] parts = line.substring(secondSpace + 1).split(" ");
+ entry.readable = true;
+ entry.currentEditor = null;
+ entry.setLengths(parts);
+ } else if (secondSpace == -1 && firstSpace == DIRTY.length() && line.startsWith(DIRTY)) {
+ entry.currentEditor = new Editor(entry);
+ } else if (secondSpace == -1 && firstSpace == READ.length() && line.startsWith(READ)) {
+ // This work was already done by calling lruEntries.get().
+ } else {
+ throw new IOException("unexpected journal line: " + line);
+ }
+ }
+
+ /**
+ * Computes the initial size and collects garbage as a part of opening the
+ * cache. Dirty entries are assumed to be inconsistent and will be deleted.
+ */
+ private void processJournal() throws IOException {
+ deleteIfExists(journalFileTmp);
+ for ( Iterator This class is used for buffered reading of lines. For purposes of this class, a line ends
+ * with "\n" or "\r\n". End of input is reported by throwing {@code EOFException}. Unterminated
+ * line at end of input is invalid and will be ignored, the caller may use {@code
+ * hasUnterminatedLine()} to detect it after catching the {@code EOFException}.
+ *
+ * This class is intended for reading input that strictly consists of lines, such as line-based
+ * cache entries or cache journal. Unlike the {@link java.io.BufferedReader} which in conjunction
+ * with {@link java.io.InputStreamReader} provides similar functionality, this class uses different
+ * end-of-input reporting and a more restrictive definition of a line.
+ *
+ * This class supports only charsets that encode '\r' and '\n' as a single byte with value 13
+ * and 10, respectively, and the representation of no other character contains these values.
+ * We currently check in constructor that the charset is one of US-ASCII, UTF-8 and ISO-8859-1.
+ * The default charset is US_ASCII.
+ */
+class StrictLineReader implements Closeable {
+ private static final byte CR = (byte) '\r';
+ private static final byte LF = (byte) '\n';
+
+ private final InputStream in;
+ private final Charset charset;
+
+ /*
+ * Buffered data is stored in {@code buf}. As long as no exception occurs, 0 <= pos <= end
+ * and the data in the range [pos, end) is buffered for reading. At end of input, if there is
+ * an unterminated line, we set end == -1, otherwise end == pos. If the underlying
+ * {@code InputStream} throws an {@code IOException}, end may remain as either pos or -1.
+ */
+ private byte[] buf;
+ private int pos;
+ private int end;
+
+ /**
+ * Constructs a new {@code LineReader} with the specified charset and the default capacity.
+ *
+ * @param in the {@code InputStream} to read data from.
+ * @param charset the charset used to decode data. Only US-ASCII, UTF-8 and ISO-8859-1 are
+ * supported.
+ * @throws NullPointerException if {@code in} or {@code charset} is null.
+ * @throws IllegalArgumentException if the specified charset is not supported.
+ */
+ public StrictLineReader( InputStream in, Charset charset) {
+ this(in, 8192, charset);
+ }
+
+ /**
+ * Constructs a new {@code LineReader} with the specified capacity and charset.
+ *
+ * @param in the {@code InputStream} to read data from.
+ * @param capacity the capacity of the buffer.
+ * @param charset the charset used to decode data. Only US-ASCII, UTF-8 and ISO-8859-1 are
+ * supported.
+ * @throws NullPointerException if {@code in} or {@code charset} is null.
+ * @throws IllegalArgumentException if {@code capacity} is negative or zero
+ * or the specified charset is not supported.
+ */
+ public StrictLineReader( InputStream in, int capacity, Charset charset) {
+ if (in == null || charset == null) {
+ throw new NullPointerException();
+ }
+ if (capacity < 0) {
+ throw new IllegalArgumentException("capacity <= 0");
+ }
+ if (!(charset.equals(CacheUtil.US_ASCII))) {
+ throw new IllegalArgumentException("Unsupported encoding");
+ }
+
+ this.in = in;
+ this.charset = charset;
+ buf = new byte[capacity];
+ }
+
+ /**
+ * Closes the reader by closing the underlying {@code InputStream} and
+ * marking this reader as closed.
+ *
+ * @throws IOException for errors when closing the underlying {@code InputStream}.
+ */
+ public void close() throws IOException {
+ synchronized (in) {
+ if (buf != null) {
+ buf = null;
+ in.close();
+ }
+ }
+ }
+
+ /**
+ * Reads the next line. A line ends with {@code "\n"} or {@code "\r\n"},
+ * this end of line marker is not included in the result.
+ *
+ * @return the next line from the input.
+ * @throws IOException for underlying {@code InputStream} errors.
+ * @throws EOFException for the end of source stream.
+ */
+ public String readLine() throws IOException {
+ synchronized (in) {
+ if (buf == null) {
+ throw new IOException("LineReader is closed");
+ }
+
+ // Read more data if we are at the end of the buffered labelList.
+ // Though it's an error to read after an exception, we will let {@code fillBuf()}
+ // throw again if that happens; thus we need to handle end == -1 as well as end == pos.
+ if (pos >= end) {
+ fillBuf();
+ }
+ // Try to find LF in the buffered data and return the line if successful.
+ for (int i = pos; i != end; ++i) {
+ if (buf[i] == LF) {
+ int lineEnd = (i != pos && buf[i - 1] == CR) ? i - 1 : i;
+ String res = new String(buf, pos, lineEnd - pos, charset.name());
+ pos = i + 1;
+ return res;
+ }
+ }
+
+ // Let's anticipate up to 80 characters on top of those already read.
+ ByteArrayOutputStream out = new ByteArrayOutputStream(end - pos + 80) {
+ @Override
+ public String toString() {
+ int length = (count > 0 && buf[count - 1] == CR) ? count - 1 : count;
+ try {
+ return new String(buf, 0, length, charset.name());
+ } catch ( UnsupportedEncodingException e) {
+ throw new AssertionError(e); // Since we control the charset this will never happen.
+ }
+ }
+ };
+
+ while (true) {
+ out.write(buf, pos, end - pos);
+ // Mark unterminated line in case fillBuf throws EOFException or IOException.
+ end = -1;
+ fillBuf();
+ // Try to find LF in the buffered data and return the line if successful.
+ for (int i = pos; i != end; ++i) {
+ if (buf[i] == LF) {
+ if (i != pos) {
+ out.write(buf, pos, i - pos);
+ }
+ pos = i + 1;
+ return out.toString();
+ }
+ }
+ }
+ }
+ }
+
+ public boolean hasUnterminatedLine() {
+ return end == -1;
+ }
+
+ /**
+ * Reads new input data into the buffer. Call only with pos == end or end == -1,
+ * depending on the desired outcome if the function throws.
+ */
+ private void fillBuf() throws IOException {
+ int result = in.read(buf, 0, buf.length);
+ if (result == -1) {
+ throw new EOFException();
+ }
+ pos = 0;
+ end = result;
+ }
+}
+
diff --git a/keystore/car_launcher.jks b/keystore/car_launcher.jks
new file mode 100644
index 0000000000..10da6f41bd
Binary files /dev/null and b/keystore/car_launcher.jks differ
diff --git a/libraries/mogo-map/build.gradle b/libraries/mogo-map/build.gradle
index 545771335c..b8521d144d 100644
--- a/libraries/mogo-map/build.gradle
+++ b/libraries/mogo-map/build.gradle
@@ -21,7 +21,6 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
-
}
dependencies {
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoBaseMapView.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoBaseMapView.java
index 64b4bfee63..ddfd895697 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoBaseMapView.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoBaseMapView.java
@@ -4,6 +4,7 @@ import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;
@@ -41,7 +42,7 @@ public abstract class MogoBaseMapView extends FrameLayout implements ILifeCycle
if ( mMapView != null ) {
final View mapView = mMapView.getMapView();
if ( mapView != null ) {
- addView( mapView );
+ addView( mapView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) );
MogoMap.getInstance().init( context, getMap() );
} else {
Logger.e( TAG, "create MapView instance failed." );
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapMarkerClickHandler.java b/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapMarkerClickHandler.java
new file mode 100644
index 0000000000..bb15e1b351
--- /dev/null
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapMarkerClickHandler.java
@@ -0,0 +1,27 @@
+package com.mogo.map.amap;
+
+import com.amap.api.maps.model.Marker;
+import com.mogo.map.marker.IMogoMarker;
+import com.mogo.map.marker.IMogoMarkerClickListener;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * marker 点击事件处理
+ */
+public class AMapMarkerClickHandler {
+
+ public boolean handleMarkerClicked( Marker marker ) {
+ if ( marker == null ) {
+ return false;
+ }
+ if ( marker.getObject() instanceof IMogoMarker ) {
+ final IMogoMarkerClickListener listener = ( ( IMogoMarker ) marker.getObject() ).getOnMarkerClickListener();
+ if ( listener != null ) {
+ return listener.onMarkerClicked( ( ( IMogoMarker ) marker.getObject() ) );
+ }
+ }
+ return false;
+ }
+}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapNaviViewWrapper.java b/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapNaviViewWrapper.java
index 5dfdcacb11..8c6bb1bb3f 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapNaviViewWrapper.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapNaviViewWrapper.java
@@ -1,11 +1,19 @@
package com.mogo.map.amap;
import android.os.Bundle;
+import android.view.MotionEvent;
import android.view.View;
+import com.amap.api.maps.AMap;
+import com.amap.api.maps.model.Marker;
+import com.amap.api.maps.model.Poi;
import com.amap.api.navi.AMapNaviView;
import com.mogo.map.IMogoMap;
import com.mogo.map.IMogoMapView;
+import com.mogo.map.amap.utils.ObjectUtils;
+import com.mogo.map.listener.MogoMapListenerHandler;
+import com.mogo.map.marker.IMogoMarker;
+import com.mogo.map.marker.IMogoMarkerClickListener;
/**
* @author congtaowang
@@ -13,13 +21,26 @@ import com.mogo.map.IMogoMapView;
*
* 代理高德导航地图
*/
-public class AMapNaviViewWrapper implements IMogoMapView {
+public class AMapNaviViewWrapper implements IMogoMapView,
+ AMap.OnMarkerClickListener,
+ AMap.OnMapLoadedListener,
+ AMap.OnMapTouchListener,
+ AMap.OnPOIClickListener {
private final AMapNaviView mMapView;
private IMogoMap mIMap;
+ private AMapMarkerClickHandler mMarkerClickHandler;
+
public AMapNaviViewWrapper( AMapNaviView mapView ) {
this.mMapView = mapView;
+ mMapView.setOnMarkerClickListener( this );
+ mMarkerClickHandler = new AMapMarkerClickHandler();
+ mMapView.setOnMapLoadedListener( this );
+ mMapView.setOnMapTouchListener( this );
+ if ( mMapView.getMap() != null ) {
+ mMapView.getMap().setOnPOIClickListener( this );
+ }
}
@Override
@@ -75,4 +96,44 @@ public class AMapNaviViewWrapper implements IMogoMapView {
@Override
public void onLowMemory() {
}
+
+
+ /**
+ * 地图marker点击
+ *
+ * @param marker
+ * @return
+ */
+ @Override
+ public boolean onMarkerClick( Marker marker ) {
+ return mMarkerClickHandler.handleMarkerClicked( marker );
+ }
+
+ /**
+ * 地图加载完毕
+ */
+ @Override
+ public void onMapLoaded() {
+ MogoMapListenerHandler.getInstance().onMapLoaded();
+ }
+
+ /**
+ * 地图点击回调
+ *
+ * @param motionEvent
+ */
+ @Override
+ public void onTouch( MotionEvent motionEvent ) {
+ MogoMapListenerHandler.getInstance().onTouch( motionEvent );
+ }
+
+ /**
+ * POI 点击
+ *
+ * @param poi
+ */
+ @Override
+ public void onPOIClick( Poi poi ) {
+ MogoMapListenerHandler.getInstance().onPOIClick( ObjectUtils.fromAMap( poi ) );
+ }
}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapWrapper.java b/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapWrapper.java
index 834b8b58e4..47ac8589f6 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapWrapper.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/amap/AMapWrapper.java
@@ -3,12 +3,14 @@ package com.mogo.map.amap;
import com.amap.api.maps.AMap;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
+import com.amap.api.maps.model.Poi;
import com.mogo.map.IMogoMap;
-import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.IUiSettings;
-import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.amap.marker.AMapMarkerWrapper;
import com.mogo.map.amap.utils.ObjectUtils;
+import com.mogo.map.marker.IMogoMarker;
+import com.mogo.map.marker.MogoMarkerOptions;
+import com.mogo.utils.TipToast;
import java.util.ArrayList;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/marker/AMapMarkerWrapper.java b/libraries/mogo-map/src/main/java/com/mogo/map/amap/marker/AMapMarkerWrapper.java
index b89701ae59..91c5eba06f 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/marker/AMapMarkerWrapper.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/amap/marker/AMapMarkerWrapper.java
@@ -7,7 +7,9 @@ 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.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
+import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.amap.utils.ObjectUtils;
@@ -22,9 +24,14 @@ import java.util.ArrayList;
public class AMapMarkerWrapper implements IMogoMarker {
private Marker mMarker;
+ private Object mObject;
+ private IMogoMarkerClickListener mMogoMarkerClickListener;
public AMapMarkerWrapper( Marker mMarker ) {
this.mMarker = mMarker;
+ if ( mMarker != null ) {
+ mMarker.setObject( this );
+ }
}
@Override
@@ -120,9 +127,12 @@ public class AMapMarkerWrapper implements IMogoMarker {
@Override
public void setObject( Object object ) {
- if ( mMarker != null ) {
- mMarker.setObject( object );
- }
+ mObject = object;
+ }
+
+ @Override
+ public Object getObject() {
+ return mObject;
}
@Override
@@ -139,6 +149,15 @@ public class AMapMarkerWrapper implements IMogoMarker {
}
}
+ @Override
+ public MogoLatLng getPosition() {
+ if ( mMarker != null ) {
+ final LatLng latLng = mMarker.getPosition();
+ return ObjectUtils.fromAMap( latLng );
+ }
+ return null;
+ }
+
@Override
public void setRotateAngle( float rotate ) {
if ( mMarker != null ) {
@@ -187,4 +206,14 @@ public class AMapMarkerWrapper implements IMogoMarker {
mMarker.showInfoWindow();
}
}
+
+ @Override
+ public void setOnMarkerClickListener( IMogoMarkerClickListener listener ) {
+ mMogoMarkerClickListener = listener;
+ }
+
+ @Override
+ public IMogoMarkerClickListener getOnMarkerClickListener() {
+ return mMogoMarkerClickListener;
+ }
}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/GeocodeSearchClient.java b/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/GeocodeSearchClient.java
index 974ae5563d..0e1ee2fc30 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/GeocodeSearchClient.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/GeocodeSearchClient.java
@@ -10,12 +10,12 @@ import com.amap.api.services.geocoder.RegeocodeAddress;
import com.amap.api.services.geocoder.RegeocodeResult;
import com.mogo.map.amap.utils.ObjectUtils;
import com.mogo.map.exception.MogoMapException;
-import com.mogo.map.search.IMogoGeoSearch;
-import com.mogo.map.search.IMogoGeoSearchListener;
-import com.mogo.map.search.MogoGeocodeAddress;
-import com.mogo.map.search.MogoRegeocodeAddress;
-import com.mogo.map.search.query.MogoGeocodeQuery;
-import com.mogo.map.search.query.MogoRegeocodeQuery;
+import com.mogo.map.search.geo.IMogoGeoSearch;
+import com.mogo.map.search.geo.IMogoGeoSearchListener;
+import com.mogo.map.search.geo.MogoGeocodeAddress;
+import com.mogo.map.search.geo.MogoRegeocodeAddress;
+import com.mogo.map.search.geo.query.MogoGeocodeQuery;
+import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
import java.util.ArrayList;
import java.util.List;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/InputtipsSearch.java b/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/InputtipsSearch.java
index 9be69939df..0803a24576 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/InputtipsSearch.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/InputtipsSearch.java
@@ -8,10 +8,10 @@ import com.amap.api.services.help.InputtipsQuery;
import com.amap.api.services.help.Tip;
import com.mogo.map.amap.utils.ObjectUtils;
import com.mogo.map.exception.MogoMapException;
-import com.mogo.map.search.IMogoInputtipsListener;
-import com.mogo.map.search.IMogoInputtipsSearch;
-import com.mogo.map.search.MogoTip;
-import com.mogo.map.search.query.MogoInputtipsQuery;
+import com.mogo.map.search.inputtips.IMogoInputtipsListener;
+import com.mogo.map.search.inputtips.IMogoInputtipsSearch;
+import com.mogo.map.search.inputtips.MogoTip;
+import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
import java.util.ArrayList;
import java.util.List;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/PoiSearchClient.java b/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/PoiSearchClient.java
new file mode 100644
index 0000000000..8549611e57
--- /dev/null
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/amap/search/PoiSearchClient.java
@@ -0,0 +1,122 @@
+package com.mogo.map.amap.search;
+
+import android.content.Context;
+
+import com.amap.api.services.core.AMapException;
+import com.amap.api.services.core.PoiItem;
+import com.amap.api.services.poisearch.PoiResult;
+import com.amap.api.services.poisearch.PoiSearch;
+import com.mogo.map.amap.utils.ObjectUtils;
+import com.mogo.map.exception.MogoMapException;
+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.MogoSearchBound;
+import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
+import com.mogo.utils.logger.Logger;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * poi搜索高德实现
+ *
+ * 错误码对照表:https://lbs.amap.com/api/android-sdk/guide/map-tools/error-code
+ */
+public class PoiSearchClient implements IMogoPoiSearch, PoiSearch.OnPoiSearchListener {
+
+ private static final String TAG = "PoiSearchClient";
+
+ private MogoPoiSearchQuery mQuery;
+ private PoiSearch mClient;
+ private IMogoPoiSearchListener mListener;
+ private MogoSearchBound mBound;
+
+ public PoiSearchClient( Context context, MogoPoiSearchQuery query ) {
+ mQuery = query;
+ mClient = new PoiSearch( context, ObjectUtils.fromMogo( mQuery ) );
+ mClient.setOnPoiSearchListener( this );
+ }
+
+ @Override
+ public void setPoiSearchListener( IMogoPoiSearchListener listener ) {
+ mListener = listener;
+ }
+
+ @Override
+ public void searchPOIAsyn() {
+ if ( mClient != null ) {
+ mClient.searchPOIAsyn();
+ }
+ }
+
+ @Override
+ public MogoPoiResult searchPOI() throws MogoMapException {
+ if ( mClient != null ) {
+ try {
+ PoiResult search = mClient.searchPOI();
+ return ObjectUtils.fromAMap( search );
+ } catch ( AMapException e ) {
+ throw new MogoMapException( e );
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void setQuery( MogoPoiSearchQuery query ) {
+ mQuery = query;
+ if ( mClient != null ) {
+ mClient.setQuery( ObjectUtils.fromMogo( mQuery ) );
+ }
+ }
+
+ @Override
+ public MogoPoiItem searchPOIId( String poiId ) throws MogoMapException {
+ if ( mClient != null ) {
+ try {
+ PoiItem poiItem = mClient.searchPOIId( poiId );
+ return ObjectUtils.fromAMap( poiItem );
+ } catch ( AMapException e ) {
+ throw new MogoMapException( e );
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void searchPOIIdAsyn( String poiId ) {
+ if ( mClient != null ) {
+ mClient.searchPOIIdAsyn( poiId );
+ }
+ }
+
+ @Override
+ public void setBound( MogoSearchBound bound ) {
+ mBound = bound;
+ if ( mClient != null ) {
+ mClient.setBound( ObjectUtils.fromMogo( bound ) );
+ }
+ }
+
+ @Override
+ public void onPoiSearched( PoiResult poiResult, int errorCode ) {
+ if ( errorCode != 1000 ) {
+ Logger.e( TAG, "errorcode is %d", errorCode );
+ }
+ if ( mListener != null ) {
+ mListener.onPoiSearched( ObjectUtils.fromAMap( poiResult ), errorCode );
+ }
+ }
+
+ @Override
+ public void onPoiItemSearched( PoiItem poiItem, int errorCode ) {
+ if ( errorCode != 1000 ) {
+ Logger.e( TAG, "errorcode is %d", errorCode );
+ }
+ if ( mListener != null ) {
+ mListener.onPoiItemSearched( ObjectUtils.fromAMap( poiItem ), errorCode );
+ }
+ }
+}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/amap/utils/ObjectUtils.java b/libraries/mogo-map/src/main/java/com/mogo/map/amap/utils/ObjectUtils.java
index 76222d54f2..7549118272 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/amap/utils/ObjectUtils.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/amap/utils/ObjectUtils.java
@@ -7,6 +7,7 @@ import com.amap.api.maps.model.BitmapDescriptor;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.MarkerOptions;
+import com.amap.api.maps.model.Poi;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.core.PoiItem;
import com.amap.api.services.geocoder.AoiItem;
@@ -24,29 +25,35 @@ import com.amap.api.services.help.Tip;
import com.amap.api.services.poisearch.IndoorData;
import com.amap.api.services.poisearch.Photo;
import com.amap.api.services.poisearch.PoiItemExtension;
+import com.amap.api.services.poisearch.PoiResult;
+import com.amap.api.services.poisearch.PoiSearch;
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.MogoMarkerOptions;
-import com.mogo.map.search.MogoAoiItem;
-import com.mogo.map.search.MogoBusinessArea;
-import com.mogo.map.search.MogoCrossroad;
-import com.mogo.map.search.MogoGeocodeAddress;
-import com.mogo.map.search.MogoGeocodeResult;
-import com.mogo.map.search.MogoIndoorData;
-import com.mogo.map.search.MogoPhoto;
-import com.mogo.map.search.MogoPoiItem;
-import com.mogo.map.search.MogoPoiItemExtension;
-import com.mogo.map.search.MogoRegeocodeAddress;
-import com.mogo.map.search.MogoRegeocodeResult;
-import com.mogo.map.search.MogoRegeocodeRoad;
-import com.mogo.map.search.MogoStreetNumber;
-import com.mogo.map.search.MogoSubPoiItem;
-import com.mogo.map.search.MogoTip;
-import com.mogo.map.search.query.MogoGeocodeQuery;
-import com.mogo.map.search.query.MogoInputtipsQuery;
-import com.mogo.map.search.query.MogoRegeocodeQuery;
+import com.mogo.map.model.MogoPoi;
+import com.mogo.map.search.geo.MogoAoiItem;
+import com.mogo.map.search.geo.MogoBusinessArea;
+import com.mogo.map.search.geo.MogoCrossroad;
+import com.mogo.map.search.geo.MogoGeocodeAddress;
+import com.mogo.map.search.geo.MogoGeocodeResult;
+import com.mogo.map.search.geo.MogoIndoorData;
+import com.mogo.map.search.geo.MogoPhoto;
+import com.mogo.map.search.geo.MogoPoiItem;
+import com.mogo.map.search.geo.MogoPoiItemExtension;
+import com.mogo.map.search.geo.MogoRegeocodeAddress;
+import com.mogo.map.search.geo.MogoRegeocodeResult;
+import com.mogo.map.search.geo.MogoRegeocodeRoad;
+import com.mogo.map.search.geo.MogoStreetNumber;
+import com.mogo.map.search.geo.MogoSubPoiItem;
+import com.mogo.map.search.inputtips.MogoTip;
+import com.mogo.map.search.geo.query.MogoGeocodeQuery;
+import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
+import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
+import com.mogo.map.search.poisearch.MogoPoiResult;
+import com.mogo.map.search.poisearch.MogoSearchBound;
+import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
import java.util.ArrayList;
import java.util.List;
@@ -136,6 +143,13 @@ public class ObjectUtils {
return new LatLonPoint( latLng.lat, latLng.lng );
}
+ public static LatLng fromMogo2( MogoLatLng latLng ) {
+ if ( latLng == null ) {
+ return null;
+ }
+ return new LatLng( latLng.lat, latLng.lng );
+ }
+
public static MogoLatLng fromAMap( LatLonPoint point ) {
if ( point == null ) {
return null;
@@ -143,6 +157,13 @@ public class ObjectUtils {
return new MogoLatLng( point.getLatitude(), point.getLongitude() );
}
+ public static MogoLatLng fromAMap( LatLng point ) {
+ if ( point == null ) {
+ return null;
+ }
+ return new MogoLatLng( point.latitude, point.longitude );
+ }
+
public static GeocodeQuery fromMogo( MogoGeocodeQuery query ) {
if ( query == null ) {
return null;
@@ -463,4 +484,111 @@ public class ObjectUtils {
mogoTip.setTypeCode( tip.getTypeCode() );
return mogoTip;
}
+
+ public static MogoPoi fromAMap( Poi poi ) {
+ if ( poi == null ) {
+ return null;
+ }
+ MogoPoi mogoPoi = new MogoPoi();
+ mogoPoi.setCoordinate( fromAMap( poi.getCoordinate() ) );
+ mogoPoi.setName( poi.getName() );
+ mogoPoi.setPoiId( poi.getPoiId() );
+ return mogoPoi;
+ }
+
+ public static MogoPoiSearchQuery fromAMap( PoiSearch.Query query ) {
+ if ( query == null ) {
+ return null;
+ }
+ MogoPoiSearchQuery mogoPoiSearchQuery = new MogoPoiSearchQuery( query.getQueryString(), query.getCategory(), query.getCity() );
+ mogoPoiSearchQuery.setBuilding( query.getBuilding() );
+ mogoPoiSearchQuery.setCityLimit( query.getCityLimit() );
+ mogoPoiSearchQuery.setDistanceSort( query.isDistanceSort() );
+ mogoPoiSearchQuery.setLocation( fromAMap( query.getLocation() ) );
+ mogoPoiSearchQuery.setPageNum( query.getPageNum() );
+ mogoPoiSearchQuery.setPageSize( query.getPageSize() );
+ return mogoPoiSearchQuery;
+ }
+
+ public static PoiSearch.Query fromMogo( MogoPoiSearchQuery query ) {
+ if ( query == null ) {
+ return null;
+ }
+ PoiSearch.Query psq = new PoiSearch.Query( query.getQuery(), query.getCategory(), query.getCity() );
+ psq.setBuilding( query.getBuilding() );
+ psq.setCityLimit( query.isCityLimit() );
+ psq.setDistanceSort( query.isDistanceSort() );
+ psq.setLocation( fromMogo( query.getLocation() ) );
+ psq.setPageNum( query.getPageNum() );
+ psq.setPageSize( query.getPageSize() );
+ return psq;
+ }
+
+ public static MogoSearchBound fromAMap( PoiSearch.SearchBound bound ) {
+ if ( bound == null ) {
+ return null;
+ }
+ if ( bound.getShape() == PoiSearch.SearchBound.BOUND_SHAPE ) {
+ return new MogoSearchBound( fromAMap( bound.getCenter() ), bound.getRange(), bound.isDistanceSort() );
+ } else if ( bound.getShape() == PoiSearch.SearchBound.POLYGON_SHAPE ) {
+ return new MogoSearchBound( fromAMap( bound.getPolyGonList() ) );
+ } else if ( bound.getShape() == PoiSearch.SearchBound.RECTANGLE_SHAPE ) {
+ return new MogoSearchBound( fromAMap( bound.getLowerLeft() ), fromAMap( bound.getUpperRight() ) );
+ }
+ return null;
+ }
+
+ public static List< MogoLatLng > fromAMap( List< LatLonPoint > latLngs ) {
+ if ( latLngs == null ) {
+ return null;
+ }
+ List< MogoLatLng > result = new ArrayList<>( latLngs.size() );
+ for ( LatLonPoint latLng : latLngs ) {
+ result.add( fromAMap( latLng ) );
+ }
+ return result;
+ }
+
+ public static List< LatLonPoint > fromMogo( List< MogoLatLng > latLngs ) {
+ if ( latLngs == null ) {
+ return null;
+ }
+ List< LatLonPoint > result = new ArrayList<>( latLngs.size() );
+ for ( MogoLatLng latLng : latLngs ) {
+ result.add( fromMogo( latLng ) );
+ }
+ return result;
+ }
+
+
+ public static PoiSearch.SearchBound fromMogo( MogoSearchBound bound ) {
+ if ( bound == null ) {
+ return null;
+ }
+ if ( bound.getShape() == MogoSearchBound.SHAPE_BOUND ) {
+ return new PoiSearch.SearchBound( fromMogo( bound.getCenterPoint() ), bound.getRadiusInMeters(), bound.isDistanceSort() );
+ } else if ( bound.getShape() == MogoSearchBound.SHAPE_POLYGON ) {
+ return new PoiSearch.SearchBound( fromMogo( bound.getPolyGonList() ) );
+ } else if ( bound.getShape() == MogoSearchBound.SHAPE_RECTANGLE ) {
+ return new PoiSearch.SearchBound( fromMogo( bound.getLowerLeft() ), fromMogo( bound.getUpperRight() ) );
+ }
+ return null;
+ }
+
+ public static MogoPoiResult fromAMap( PoiResult result ) {
+ if ( result == null ) {
+ return null;
+ }
+ MogoPoiResult mogoPoiResult = new MogoPoiResult();
+ if ( result.getPois() != null ) {
+ final List< PoiItem > poiItems = result.getPois();
+ final ArrayList< MogoPoiItem > mogoPoiItems = new ArrayList<>( poiItems.size() );
+ for ( PoiItem poiItem : poiItems ) {
+ mogoPoiItems.add( fromAMap( poiItem ) );
+ }
+ mogoPoiResult.setPois( mogoPoiItems );
+ }
+ return mogoPoiResult;
+
+ }
}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/listener/IMogoMapListener.java b/libraries/mogo-map/src/main/java/com/mogo/map/listener/IMogoMapListener.java
new file mode 100644
index 0000000000..ef1975e970
--- /dev/null
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/listener/IMogoMapListener.java
@@ -0,0 +1,33 @@
+package com.mogo.map.listener;
+
+import android.view.MotionEvent;
+
+import com.mogo.map.model.MogoPoi;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-23
+ *
+ * 地图操作回调
+ */
+public interface IMogoMapListener {
+
+ /**
+ * 地图加载完毕
+ */
+ void onMapLoaded();
+
+ /**
+ * 地图点击
+ *
+ * @param motionEvent
+ */
+ void onTouch( MotionEvent motionEvent );
+
+ /**
+ * 地图上的任意poi点击
+ *
+ * @param poi
+ */
+ void onPOIClick( MogoPoi poi );
+}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/listener/IMogoMapListenerRegister.java b/libraries/mogo-map/src/main/java/com/mogo/map/listener/IMogoMapListenerRegister.java
new file mode 100644
index 0000000000..eddec6c6d4
--- /dev/null
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/listener/IMogoMapListenerRegister.java
@@ -0,0 +1,24 @@
+package com.mogo.map.listener;
+
+import com.mogo.map.exception.MogoMapException;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-23
+ *
+ * 地图操作回调
+ */
+public interface IMogoMapListenerRegister {
+
+ /**
+ * 注册地图事件
+ *
+ * @param listener 回调事件
+ */
+ void registerHostMapListener( IMogoMapListener listener );
+
+ /**
+ * 反注册注册地图事件
+ */
+ void unregisterHostMapListener();
+}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/listener/MogoMapListenerHandler.java b/libraries/mogo-map/src/main/java/com/mogo/map/listener/MogoMapListenerHandler.java
new file mode 100644
index 0000000000..942ea96794
--- /dev/null
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/listener/MogoMapListenerHandler.java
@@ -0,0 +1,76 @@
+package com.mogo.map.listener;
+
+import android.view.MotionEvent;
+
+import com.mogo.map.model.MogoPoi;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * 地图监听注册管理
+ */
+public class MogoMapListenerHandler implements IMogoMapListener, IMogoMapListenerRegister {
+
+ private static volatile MogoMapListenerHandler sInstance;
+
+ private MogoMapListenerHandler() {
+ }
+
+ public static MogoMapListenerHandler getInstance() {
+ if ( sInstance == null ) {
+ synchronized ( MogoMapListenerHandler.class ) {
+ if ( sInstance == null ) {
+ sInstance = new MogoMapListenerHandler();
+ }
+ }
+ }
+ return sInstance;
+ }
+
+ public synchronized void release() {
+ sInstance = null;
+ }
+
+ /**
+ * 上层模块代理对象
+ */
+ private IMogoMapListener mDelegateListener = null;
+
+ @Override
+ public void registerHostMapListener( IMogoMapListener listener ) {
+ mDelegateListener = listener;
+ }
+
+ @Override
+ public void unregisterHostMapListener() {
+ mDelegateListener = null;
+ }
+
+ @Override
+ public void onMapLoaded() {
+ if ( mDelegateListener != null ) {
+ synchronized ( mDelegateListener ) {
+ mDelegateListener.onMapLoaded();
+ }
+ }
+ }
+
+ @Override
+ public void onTouch( MotionEvent motionEvent ) {
+ if ( mDelegateListener != null ) {
+ synchronized ( mDelegateListener ) {
+ mDelegateListener.onTouch( motionEvent );
+ }
+ }
+ }
+
+ @Override
+ public void onPOIClick( MogoPoi poi ) {
+ if ( mDelegateListener != null ) {
+ synchronized ( mDelegateListener ) {
+ mDelegateListener.onPOIClick( poi );
+ }
+ }
+ }
+}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoMarker.java b/libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoMarker.java
index b6ba461919..ac19d743b8 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoMarker.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoMarker.java
@@ -2,6 +2,9 @@ package com.mogo.map.marker;
import android.graphics.Bitmap;
+import com.mogo.map.MogoLatLng;
+import com.mogo.map.location.IMogoLocationClient;
+
import java.util.ArrayList;
/**
@@ -80,6 +83,8 @@ public interface IMogoMarker {
void setObject( Object object );
+ Object getObject();
+
/**
* 设置多少帧刷新一次图片资源,Marker动画的间隔时间,值越小动画越快。
*
@@ -87,8 +92,16 @@ public interface IMogoMarker {
*/
void setPeriod( int period );
+ /**
+ * 设置位置
+ *
+ * @param lat
+ * @param lng
+ */
void setPosition( double lat, double lng );
+ MogoLatLng getPosition();
+
/**
* 设置Marker覆盖物图片旋转的角度,从正北开始,逆时针计算。
*
@@ -133,4 +146,18 @@ public interface IMogoMarker {
* 显示 Marker 覆盖物的信息窗口。
*/
void showInfoWindow();
+
+ /**
+ * 设置点击事件
+ *
+ * @param listener
+ */
+ void setOnMarkerClickListener( IMogoMarkerClickListener listener );
+
+ /**
+ * 获取点击事件
+ *
+ * @return
+ */
+ IMogoMarkerClickListener getOnMarkerClickListener();
}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoMarkerClickListener.java b/libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoMarkerClickListener.java
new file mode 100644
index 0000000000..966ca196fa
--- /dev/null
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/marker/IMogoMarkerClickListener.java
@@ -0,0 +1,18 @@
+package com.mogo.map.marker;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-23
+ *
+ * marker 点击事件
+ */
+public interface IMogoMarkerClickListener {
+
+ /**
+ * 事件是否继续往下传递
+ *
+ * @param marker
+ * @return true - 时间已经处理完毕不继续往下传,否则继续往下传
+ */
+ boolean onMarkerClicked( IMogoMarker marker );
+}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/model/MogoPoi.java b/libraries/mogo-map/src/main/java/com/mogo/map/model/MogoPoi.java
new file mode 100644
index 0000000000..c0d287db72
--- /dev/null
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/model/MogoPoi.java
@@ -0,0 +1,76 @@
+package com.mogo.map.model;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import com.mogo.map.MogoLatLng;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * 地图上的poi
+ */
+public class MogoPoi implements Parcelable {
+
+ private String name;
+ private MogoLatLng coordinate;
+ private String poiId;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName( String name ) {
+ this.name = name;
+ }
+
+ public MogoLatLng getCoordinate() {
+ return coordinate;
+ }
+
+ public void setCoordinate( MogoLatLng coordinate ) {
+ this.coordinate = coordinate;
+ }
+
+ public String getPoiId() {
+ return poiId;
+ }
+
+ public void setPoiId( String poiId ) {
+ this.poiId = poiId;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel( Parcel dest, int flags ) {
+ dest.writeString( this.name );
+ dest.writeParcelable( this.coordinate, flags );
+ dest.writeString( this.poiId );
+ }
+
+ public MogoPoi() {
+ }
+
+ protected MogoPoi( Parcel in ) {
+ this.name = in.readString();
+ this.coordinate = in.readParcelable( MogoLatLng.class.getClassLoader() );
+ this.poiId = in.readString();
+ }
+
+ public static final Parcelable.Creator< MogoPoi > CREATOR = new Parcelable.Creator< MogoPoi >() {
+ @Override
+ public MogoPoi createFromParcel( Parcel source ) {
+ return new MogoPoi( source );
+ }
+
+ @Override
+ public MogoPoi[] newArray( int size ) {
+ return new MogoPoi[size];
+ }
+ };
+}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/IMogoGeoSearch.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/IMogoGeoSearch.java
similarity index 88%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/IMogoGeoSearch.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/IMogoGeoSearch.java
index 1a0ec205d3..94d7533dfb 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/IMogoGeoSearch.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/IMogoGeoSearch.java
@@ -1,8 +1,8 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import com.mogo.map.exception.MogoMapException;
-import com.mogo.map.search.query.MogoGeocodeQuery;
-import com.mogo.map.search.query.MogoRegeocodeQuery;
+import com.mogo.map.search.geo.query.MogoGeocodeQuery;
+import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
import java.util.List;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/IMogoGeoSearchListener.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/IMogoGeoSearchListener.java
similarity index 94%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/IMogoGeoSearchListener.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/IMogoGeoSearchListener.java
index ae1689b236..a4145d5d90 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/IMogoGeoSearchListener.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/IMogoGeoSearchListener.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
/**
* @author congtaowang
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoAoiItem.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoAoiItem.java
similarity index 98%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoAoiItem.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoAoiItem.java
index e02c987202..957c920f60 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoAoiItem.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoAoiItem.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoBusinessArea.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoBusinessArea.java
similarity index 97%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoBusinessArea.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoBusinessArea.java
index b3000a053d..5b04b34c93 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoBusinessArea.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoBusinessArea.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoCrossroad.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoCrossroad.java
similarity index 98%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoCrossroad.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoCrossroad.java
index 0fbc560d63..b2899e33a4 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoCrossroad.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoCrossroad.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoGeoSearch.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoGeoSearch.java
similarity index 91%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoGeoSearch.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoGeoSearch.java
index 6d7c509b61..c17c93a799 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoGeoSearch.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoGeoSearch.java
@@ -1,11 +1,11 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import android.content.Context;
import com.mogo.map.amap.search.GeocodeSearchClient;
import com.mogo.map.exception.MogoMapException;
-import com.mogo.map.search.query.MogoGeocodeQuery;
-import com.mogo.map.search.query.MogoRegeocodeQuery;
+import com.mogo.map.search.geo.query.MogoGeocodeQuery;
+import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
import java.util.List;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoGeocodeAddress.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoGeocodeAddress.java
similarity index 98%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoGeocodeAddress.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoGeocodeAddress.java
index 09d8700811..ddeac51edc 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoGeocodeAddress.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoGeocodeAddress.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import com.mogo.map.MogoLatLng;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoGeocodeResult.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoGeocodeResult.java
similarity index 93%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoGeocodeResult.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoGeocodeResult.java
index ecc855c190..5105908e9a 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoGeocodeResult.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoGeocodeResult.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import java.util.ArrayList;
import java.util.List;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoIndoorData.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoIndoorData.java
similarity index 97%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoIndoorData.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoIndoorData.java
index 69ffd1200a..263b5544ab 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoIndoorData.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoIndoorData.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoPhoto.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPhoto.java
similarity index 97%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoPhoto.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPhoto.java
index feffddf23f..ba393665a1 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoPhoto.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPhoto.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoPoiItem.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPoiItem.java
similarity index 99%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoPoiItem.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPoiItem.java
index 22de089a44..b378a59abc 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoPoiItem.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPoiItem.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoPoiItemExtension.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPoiItemExtension.java
similarity index 97%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoPoiItemExtension.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPoiItemExtension.java
index 645b91c6bb..3e19a49f32 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoPoiItemExtension.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoPoiItemExtension.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoRegeocodeAddress.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeAddress.java
similarity index 99%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoRegeocodeAddress.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeAddress.java
index b3d90e6556..a15f7eb132 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoRegeocodeAddress.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeAddress.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoRegeocodeResult.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeResult.java
similarity index 97%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoRegeocodeResult.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeResult.java
index 6fd7141374..d5f83828b4 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoRegeocodeResult.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeResult.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoRegeocodeRoad.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeRoad.java
similarity index 98%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoRegeocodeRoad.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeRoad.java
index d3fb6c2ece..6ec6a29d0b 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoRegeocodeRoad.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoRegeocodeRoad.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoStreetNumber.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoStreetNumber.java
similarity index 98%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoStreetNumber.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoStreetNumber.java
index c12d20fbaf..1d3f953c7c 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoStreetNumber.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoStreetNumber.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoSubPoiItem.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoSubPoiItem.java
similarity index 98%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoSubPoiItem.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoSubPoiItem.java
index f1240ef0ee..b3796963d6 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoSubPoiItem.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/MogoSubPoiItem.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.geo;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/query/MogoGeocodeQuery.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/query/MogoGeocodeQuery.java
similarity index 97%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/query/MogoGeocodeQuery.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/query/MogoGeocodeQuery.java
index 441bd20bad..988533cc5f 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/query/MogoGeocodeQuery.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/query/MogoGeocodeQuery.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search.query;
+package com.mogo.map.search.geo.query;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/query/MogoRegeocodeQuery.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/query/MogoRegeocodeQuery.java
similarity index 98%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/query/MogoRegeocodeQuery.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/geo/query/MogoRegeocodeQuery.java
index cd295d404a..bb4e05a725 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/query/MogoRegeocodeQuery.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/geo/query/MogoRegeocodeQuery.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search.query;
+package com.mogo.map.search.geo.query;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/IMogoInputtipsListener.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsListener.java
similarity index 83%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/IMogoInputtipsListener.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsListener.java
index 1cba147ba2..5386d843a3 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/IMogoInputtipsListener.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsListener.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.inputtips;
import java.util.List;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/IMogoInputtipsSearch.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsSearch.java
similarity index 79%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/IMogoInputtipsSearch.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsSearch.java
index 0d7701e90d..9bde874135 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/IMogoInputtipsSearch.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/IMogoInputtipsSearch.java
@@ -1,7 +1,7 @@
-package com.mogo.map.search;
+package com.mogo.map.search.inputtips;
import com.mogo.map.exception.MogoMapException;
-import com.mogo.map.search.query.MogoInputtipsQuery;
+import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
import java.util.List;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoInputtipsSearch.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/MogoInputtipsSearch.java
similarity index 92%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoInputtipsSearch.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/MogoInputtipsSearch.java
index 483889b905..e13e2d06d0 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoInputtipsSearch.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/MogoInputtipsSearch.java
@@ -1,10 +1,10 @@
-package com.mogo.map.search;
+package com.mogo.map.search.inputtips;
import android.content.Context;
import com.mogo.map.amap.search.InputtipsSearch;
import com.mogo.map.exception.MogoMapException;
-import com.mogo.map.search.query.MogoInputtipsQuery;
+import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
import java.util.List;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoTip.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/MogoTip.java
similarity index 98%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/MogoTip.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/MogoTip.java
index 1f6c631c2a..26aeb8de5d 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/MogoTip.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/MogoTip.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search;
+package com.mogo.map.search.inputtips;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/query/MogoInputtipsQuery.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/query/MogoInputtipsQuery.java
similarity index 95%
rename from libraries/mogo-map/src/main/java/com/mogo/map/search/query/MogoInputtipsQuery.java
rename to libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/query/MogoInputtipsQuery.java
index 7267328d81..16e10de6bc 100644
--- a/libraries/mogo-map/src/main/java/com/mogo/map/search/query/MogoInputtipsQuery.java
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/inputtips/query/MogoInputtipsQuery.java
@@ -1,4 +1,4 @@
-package com.mogo.map.search.query;
+package com.mogo.map.search.inputtips.query;
import com.mogo.map.MogoLatLng;
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearch.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearch.java
new file mode 100644
index 0000000000..6f5e8ac2a8
--- /dev/null
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearch.java
@@ -0,0 +1,57 @@
+package com.mogo.map.search.poisearch;
+
+import com.mogo.map.exception.MogoMapException;
+import com.mogo.map.search.geo.MogoPoiItem;
+import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * poi 搜索
+ */
+public interface IMogoPoiSearch {
+
+ void setPoiSearchListener( IMogoPoiSearchListener listener );
+
+ /**
+ * 异步搜索poi信息
+ */
+ void searchPOIAsyn();
+
+ /**
+ * 同步搜索poi信息
+ *
+ * @return
+ */
+ MogoPoiResult searchPOI() throws MogoMapException;
+
+ /**
+ * 设置查询条件
+ *
+ * @param query
+ */
+ void setQuery( MogoPoiSearchQuery query );
+
+ /**
+ * 根据poiId搜索详情,同步
+ *
+ * @param poiId
+ * @return
+ */
+ MogoPoiItem searchPOIId( String poiId ) throws MogoMapException;
+
+ /**
+ * 根据poiId搜索详情,异步
+ *
+ * @param poiId
+ */
+ void searchPOIIdAsyn( String poiId );
+
+ /**
+ * 周边检索POI
+ *
+ * @param bound
+ */
+ void setBound( MogoSearchBound bound );
+}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearchListener.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearchListener.java
new file mode 100644
index 0000000000..7a8cffa543
--- /dev/null
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/IMogoPoiSearchListener.java
@@ -0,0 +1,22 @@
+package com.mogo.map.search.poisearch;
+
+import com.mogo.map.search.geo.MogoPoiItem;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * poi 检索结果回调
+ */
+public interface IMogoPoiSearchListener {
+
+ /**
+ * 返回POI搜索异步处理的结果。
+ */
+ void onPoiSearched( MogoPoiResult result, int errorCode );
+
+ /**
+ * poi ID 检索结果回调方法
+ */
+ void onPoiItemSearched( MogoPoiItem item, int errorCode );
+}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoPoiResult.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoPoiResult.java
new file mode 100644
index 0000000000..3fbf846c8c
--- /dev/null
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoPoiResult.java
@@ -0,0 +1,24 @@
+package com.mogo.map.search.poisearch;
+
+import com.mogo.map.search.geo.MogoPoiItem;
+
+import java.util.ArrayList;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * poi搜索结果集
+ */
+public class MogoPoiResult {
+
+ private ArrayList< MogoPoiItem > pois;
+
+ public ArrayList< MogoPoiItem > getPois() {
+ return pois;
+ }
+
+ public void setPois( ArrayList< MogoPoiItem > pois ) {
+ this.pois = pois;
+ }
+}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoPoiSearch.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoPoiSearch.java
new file mode 100644
index 0000000000..564c775d5f
--- /dev/null
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoPoiSearch.java
@@ -0,0 +1,74 @@
+package com.mogo.map.search.poisearch;
+
+import android.content.Context;
+
+import com.mogo.map.amap.search.PoiSearchClient;
+import com.mogo.map.exception.MogoMapException;
+import com.mogo.map.search.geo.MogoPoiItem;
+import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * 描述
+ */
+public class MogoPoiSearch implements IMogoPoiSearch {
+
+ private IMogoPoiSearch mDelegate;
+
+ public MogoPoiSearch( Context context, MogoPoiSearchQuery query ) {
+ mDelegate = new PoiSearchClient( context, query );
+ }
+
+ @Override
+ public void setPoiSearchListener( IMogoPoiSearchListener listener ) {
+ if ( mDelegate != null ) {
+ mDelegate.setPoiSearchListener( listener );
+ }
+ }
+
+ @Override
+ public void searchPOIAsyn() {
+ if ( mDelegate != null ) {
+ mDelegate.searchPOIAsyn();
+ }
+ }
+
+ @Override
+ public MogoPoiResult searchPOI() throws MogoMapException {
+ if ( mDelegate != null ) {
+ return mDelegate.searchPOI();
+ }
+ return null;
+ }
+
+ @Override
+ public void setQuery( MogoPoiSearchQuery query ) {
+ if ( mDelegate != null ) {
+ mDelegate.setQuery( query );
+ }
+ }
+
+ @Override
+ public MogoPoiItem searchPOIId( String poiId ) throws MogoMapException {
+ if ( mDelegate != null ) {
+ return mDelegate.searchPOIId( poiId );
+ }
+ return null;
+ }
+
+ @Override
+ public void searchPOIIdAsyn( String poiId ) {
+ if ( mDelegate != null ) {
+ mDelegate.searchPOIIdAsyn( poiId );
+ }
+ }
+
+ @Override
+ public void setBound( MogoSearchBound bound ) {
+ if ( mDelegate != null ) {
+ mDelegate.setBound( bound );
+ }
+ }
+}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoSearchBound.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoSearchBound.java
new file mode 100644
index 0000000000..773ae1b650
--- /dev/null
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/MogoSearchBound.java
@@ -0,0 +1,142 @@
+package com.mogo.map.search.poisearch;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import com.mogo.map.MogoLatLng;
+
+import java.util.List;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * 周边搜索范围
+ */
+public class MogoSearchBound implements Parcelable {
+
+ public static final String SHAPE_BOUND = "Bound";
+ public static final String SHAPE_RECTANGLE = "Rectangle";
+ public static final String SHAPE_POLYGON = "Polygon";
+
+ /**
+ * 中心点
+ */
+ private MogoLatLng centerPoint;
+ /**
+ * 半径:米
+ */
+ private int radiusInMeters;
+
+ /**
+ * 搜索范围的形状
+ */
+ private String shape;
+
+ /**
+ * 按距离排序
+ */
+ private boolean isDistanceSort;
+
+ /**
+ * 左下角
+ */
+ private MogoLatLng lowerLeft;
+ /**
+ * 右上角
+ */
+ private MogoLatLng upperRight;
+
+ /**
+ * 范围搜索地点列表
+ */
+ private List< MogoLatLng > polyGonList;
+
+ public MogoSearchBound( MogoLatLng centerPoint, int radiusInMeters ) {
+ this( centerPoint, radiusInMeters, true );
+ }
+
+ public MogoSearchBound( MogoLatLng centerPoint, int radiusInMeters, boolean isDistanceSort ) {
+ this.centerPoint = centerPoint;
+ this.radiusInMeters = radiusInMeters;
+ this.isDistanceSort = isDistanceSort;
+ this.shape = SHAPE_BOUND;
+ }
+
+ public MogoSearchBound( MogoLatLng lowerLeft, MogoLatLng upperRight ) {
+ this.lowerLeft = lowerLeft;
+ this.upperRight = upperRight;
+ this.shape = SHAPE_RECTANGLE;
+ }
+
+ public MogoSearchBound( List< MogoLatLng > polyGonList ) {
+ this.polyGonList = polyGonList;
+ this.shape = SHAPE_POLYGON;
+ }
+
+ public MogoLatLng getCenterPoint() {
+ return centerPoint;
+ }
+
+ public int getRadiusInMeters() {
+ return radiusInMeters;
+ }
+
+ public String getShape() {
+ return shape;
+ }
+
+ public boolean isDistanceSort() {
+ return isDistanceSort;
+ }
+
+ public MogoLatLng getLowerLeft() {
+ return lowerLeft;
+ }
+
+ public MogoLatLng getUpperRight() {
+ return upperRight;
+ }
+
+ public List< MogoLatLng > getPolyGonList() {
+ return polyGonList;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel( Parcel dest, int flags ) {
+ dest.writeParcelable( this.centerPoint, flags );
+ dest.writeInt( this.radiusInMeters );
+ dest.writeString( this.shape );
+ dest.writeByte( this.isDistanceSort ? ( byte ) 1 : ( byte ) 0 );
+ dest.writeParcelable( this.lowerLeft, flags );
+ dest.writeParcelable( this.upperRight, flags );
+ dest.writeTypedList( this.polyGonList );
+ }
+
+ protected MogoSearchBound( Parcel in ) {
+ this.centerPoint = in.readParcelable( MogoLatLng.class.getClassLoader() );
+ this.radiusInMeters = in.readInt();
+ this.shape = in.readString();
+ this.isDistanceSort = in.readByte() != 0;
+ this.lowerLeft = in.readParcelable( MogoLatLng.class.getClassLoader() );
+ this.upperRight = in.readParcelable( MogoLatLng.class.getClassLoader() );
+ this.polyGonList = in.createTypedArrayList( MogoLatLng.CREATOR );
+ }
+
+ public static final Parcelable.Creator< MogoSearchBound > CREATOR = new Parcelable.Creator< MogoSearchBound >() {
+ @Override
+ public MogoSearchBound createFromParcel( Parcel source ) {
+ return new MogoSearchBound( source );
+ }
+
+ @Override
+ public MogoSearchBound[] newArray( int size ) {
+ return new MogoSearchBound[size];
+ }
+ };
+}
diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/query/MogoPoiSearchQuery.java b/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/query/MogoPoiSearchQuery.java
new file mode 100644
index 0000000000..27076edba2
--- /dev/null
+++ b/libraries/mogo-map/src/main/java/com/mogo/map/search/poisearch/query/MogoPoiSearchQuery.java
@@ -0,0 +1,159 @@
+package com.mogo.map.search.poisearch.query;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import com.mogo.map.MogoLatLng;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * poi 搜索查询条件
+ */
+public class MogoPoiSearchQuery implements Parcelable {
+
+ private String query;
+ private String category;
+ private String city;
+ private String building;
+ private int pageNum;
+ private int pageSize;
+ private boolean isCityLimit;
+ private boolean isSubPois;
+ private boolean isDistanceSort;
+ private MogoLatLng location;
+
+ /**
+ * @param query 查询字符串,多个关键字用“|”分割
+ * @param category 类型的组合,比如定义如下组合:餐馆|电影院|景点
+ */
+ public MogoPoiSearchQuery( String query, String category ) {
+ this.query = query;
+ this.category = category;
+ this.city = null;
+ }
+
+ /**
+ * @param query 查询字符串,多个关键字用“|”分割
+ * @param category 类型的组合,比如定义如下组合:餐馆|电影院|景点
+ */
+ public MogoPoiSearchQuery( String query, String category, String city ) {
+ this.query = query;
+ this.category = category;
+ this.city = city;
+ }
+
+ public String getBuilding() {
+ return building;
+ }
+
+ public void setBuilding( String building ) {
+ this.building = building;
+ }
+
+ public String getQuery() {
+ return query;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public int getPageNum() {
+ return pageNum;
+ }
+
+ public void setPageNum( int pageNum ) {
+ this.pageNum = pageNum;
+ }
+
+ public int getPageSize() {
+ return pageSize;
+ }
+
+ public void setPageSize( int pageSize ) {
+ this.pageSize = pageSize;
+ }
+
+ public boolean isCityLimit() {
+ return isCityLimit;
+ }
+
+ public void setCityLimit( boolean cityLimit ) {
+ isCityLimit = cityLimit;
+ }
+
+ public boolean isSubPois() {
+ return isSubPois;
+ }
+
+ public void setSubPois( boolean subPois ) {
+ isSubPois = subPois;
+ }
+
+ public boolean isDistanceSort() {
+ return isDistanceSort;
+ }
+
+ public void setDistanceSort( boolean distanceSort ) {
+ isDistanceSort = distanceSort;
+ }
+
+ public MogoLatLng getLocation() {
+ return location;
+ }
+
+ public void setLocation( MogoLatLng location ) {
+ this.location = location;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel( Parcel dest, int flags ) {
+ dest.writeString( this.building );
+ dest.writeString( this.category );
+ dest.writeString( this.city );
+ dest.writeInt( this.pageNum );
+ dest.writeInt( this.pageSize );
+ dest.writeByte( this.isCityLimit ? ( byte ) 1 : ( byte ) 0 );
+ dest.writeByte( this.isSubPois ? ( byte ) 1 : ( byte ) 0 );
+ dest.writeByte( this.isDistanceSort ? ( byte ) 1 : ( byte ) 0 );
+ dest.writeParcelable( this.location, flags );
+ }
+
+ public MogoPoiSearchQuery() {
+ }
+
+ protected MogoPoiSearchQuery( Parcel in ) {
+ this.building = in.readString();
+ this.category = in.readString();
+ this.city = in.readString();
+ this.pageNum = in.readInt();
+ this.pageSize = in.readInt();
+ this.isCityLimit = in.readByte() != 0;
+ this.isSubPois = in.readByte() != 0;
+ this.isDistanceSort = in.readByte() != 0;
+ this.location = in.readParcelable( MogoLatLng.class.getClassLoader() );
+ }
+
+ public static final Parcelable.Creator< MogoPoiSearchQuery > CREATOR = new Parcelable.Creator< MogoPoiSearchQuery >() {
+ @Override
+ public MogoPoiSearchQuery createFromParcel( Parcel source ) {
+ return new MogoPoiSearchQuery( source );
+ }
+
+ @Override
+ public MogoPoiSearchQuery[] newArray( int size ) {
+ return new MogoPoiSearchQuery[size];
+ }
+ };
+}
diff --git a/modules/mogo-module-common/.gitignore b/modules/mogo-module-common/.gitignore
new file mode 100644
index 0000000000..796b96d1c4
--- /dev/null
+++ b/modules/mogo-module-common/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/modules/mogo-module-common/build.gradle b/modules/mogo-module-common/build.gradle
new file mode 100644
index 0000000000..8eefb60bdb
--- /dev/null
+++ b/modules/mogo-module-common/build.gradle
@@ -0,0 +1,34 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 29
+ buildToolsVersion "29.0.2"
+
+
+ defaultConfig {
+ minSdkVersion 19
+ targetSdkVersion 29
+ versionCode 1
+ versionName "1.0"
+
+ 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 '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'
+}
diff --git a/modules/mogo-module-common/consumer-rules.pro b/modules/mogo-module-common/consumer-rules.pro
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/modules/mogo-module-common/proguard-rules.pro b/modules/mogo-module-common/proguard-rules.pro
new file mode 100644
index 0000000000..f1b424510d
--- /dev/null
+++ b/modules/mogo-module-common/proguard-rules.pro
@@ -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
diff --git a/modules/mogo-module-common/src/androidTest/java/com/mogo/module/common/ExampleInstrumentedTest.java b/modules/mogo-module-common/src/androidTest/java/com/mogo/module/common/ExampleInstrumentedTest.java
new file mode 100644
index 0000000000..6480075289
--- /dev/null
+++ b/modules/mogo-module-common/src/androidTest/java/com/mogo/module/common/ExampleInstrumentedTest.java
@@ -0,0 +1,27 @@
+package com.mogo.module.common;
+
+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 Testing documentation
+ */
+@RunWith( AndroidJUnit4.class )
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+
+ assertEquals( "com.mogo.module.common.test", appContext.getPackageName() );
+ }
+}
diff --git a/modules/mogo-module-common/src/main/AndroidManifest.xml b/modules/mogo-module-common/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..d2c8bb29e1
--- /dev/null
+++ b/modules/mogo-module-common/src/main/AndroidManifest.xml
@@ -0,0 +1,2 @@
+
+ * 模块路由路径
+ */
+public class MogoModulePaths {
+
+ /**
+ * 地图模块 fragment 路径
+ */
+ public static final String PATH_MODULE_MAP = "/module/map";
+
+ /**
+ * 测试模块
+ */
+ public static final String PATH_MODULE_DEMO = "/demo/module/demo";
+}
diff --git a/modules/mogo-module-common/src/main/res/values/strings.xml b/modules/mogo-module-common/src/main/res/values/strings.xml
new file mode 100644
index 0000000000..c449f01758
--- /dev/null
+++ b/modules/mogo-module-common/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ * 描述
+ */
+public class MainActivity extends MvpActivity< MainView, MainPresenter > implements MainView {
+
+ IMogoMapService ims;
+ MogoModulesHandler handler;
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.module_main_activity_main;
+ }
+
+ @Override
+ protected void initViews() {
+
+ handler = new MogoModulesManager( this );
+ ims = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation();
+ if ( ims != null ) {
+ ims.registerHostMapListener( handler );
+ }
+ handler.loadMap( R.id.module_main_id_fragment_container );
+
+ Collection< IMogoModuleProvider > providers = handler.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();
+ }
+ }
+ }
+ handler.setEnable( providers.iterator().next().getModuleName() );
+ }
+
+ @NonNull
+ @Override
+ protected MainPresenter createPresenter() {
+ return new MainPresenter( this );
+ }
+}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainPresenter.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainPresenter.java
new file mode 100644
index 0000000000..2117dc53c7
--- /dev/null
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainPresenter.java
@@ -0,0 +1,16 @@
+package com.mogo.module.main;
+
+import com.mogo.commons.mvp.Presenter;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-23
+ *
+ * 描述
+ */
+public class MainPresenter extends Presenter< MainView > {
+
+ public MainPresenter( MainView view ) {
+ super( view );
+ }
+}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainView.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainView.java
new file mode 100644
index 0000000000..1bec469b31
--- /dev/null
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainView.java
@@ -0,0 +1,12 @@
+package com.mogo.module.main;
+
+import com.mogo.commons.mvp.IView;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-23
+ *
+ * 主页 view 接口
+ */
+public interface MainView extends IView {
+}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesHandler.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesHandler.java
new file mode 100644
index 0000000000..f8a6de5414
--- /dev/null
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesHandler.java
@@ -0,0 +1,50 @@
+package com.mogo.module.main.cards;
+
+import com.mogo.map.listener.IMogoMapListener;
+import com.mogo.service.module.IMogoModuleProvider;
+
+import java.util.Collection;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * 卡片管理
+ */
+public interface MogoModulesHandler extends IMogoMapListener {
+
+ /**
+ * 加载卡片
+ *
+ * @return
+ */
+ Collection< IMogoModuleProvider > loadCards();
+
+ /**
+ * 加载小智语音
+ *
+ * @param containerId 容器id
+ */
+ void loadAIAssist( int containerId );
+
+ /**
+ * 加载天气
+ *
+ * @param containerId 容器id
+ */
+ void loadWeather( int containerId );
+
+ /**
+ * 加载地图
+ *
+ * @param containerId 容器id
+ */
+ void loadMap( int containerId );
+
+ /**
+ * 设置某一个module可用
+ *
+ * @param module
+ */
+ void setEnable( String module );
+}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java
new file mode 100644
index 0000000000..0b3d7a57e3
--- /dev/null
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/cards/MogoModulesManager.java
@@ -0,0 +1,138 @@
+package com.mogo.module.main.cards;
+
+import android.content.Context;
+import android.text.TextUtils;
+import android.view.MotionEvent;
+
+import androidx.fragment.app.Fragment;
+
+import com.alibaba.android.arouter.launcher.ARouter;
+import com.mogo.map.listener.IMogoMapListener;
+import com.mogo.map.model.MogoPoi;
+import com.mogo.module.common.MogoModulePaths;
+import com.mogo.module.main.MainActivity;
+import com.mogo.service.module.IMogoModuleProvider;
+import com.mogo.utils.ResourcesHelper;
+import com.mogo.utils.logger.Logger;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * 卡片加载
+ */
+public class MogoModulesManager implements MogoModulesHandler, IMogoMapListener {
+
+ private static final String TAG = "MogoModulesManager";
+
+ private MainActivity mActivity;
+ private final Map< String, IMogoModuleProvider > mCardProviders = new HashMap<>();
+ private IMogoModuleProvider mMapProvider;
+ private String mEnableModuleName = null;
+
+ public MogoModulesManager( MainActivity activity ) {
+ if ( activity == null ) {
+ throw new NullPointerException( "activity can't be null." );
+ }
+ this.mActivity = activity;
+ }
+
+ private Context getContext() {
+ return mActivity;
+ }
+
+ private Context getApplicationContext() {
+ return mActivity.getApplicationContext();
+ }
+
+ @Override
+ public Collection< IMogoModuleProvider > loadCards() {
+ IMogoModuleProvider demo = load( MogoModulePaths.PATH_MODULE_DEMO );
+ mCardProviders.put( demo.getModuleName(), demo );
+ return mCardProviders.values();
+ }
+
+ @Override
+ public void loadAIAssist( int containerId ) {
+
+ }
+
+ @Override
+ public void loadWeather( int containerId ) {
+
+ }
+
+ @Override
+ public void loadMap( int containerId ) {
+ mMapProvider = load( MogoModulePaths.PATH_MODULE_MAP );
+ addFragment( mMapProvider, containerId );
+ }
+
+ private IMogoModuleProvider load( String path ) {
+ return ( IMogoModuleProvider ) ARouter.getInstance().build( path ).navigation( getContext() );
+ }
+
+ private void addFragment( IMogoModuleProvider provider, int containerId ) {
+ if ( provider == null ) {
+ Logger.e( TAG, "add fragment fail cause provider == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
+ return;
+ }
+ final Fragment fragment = provider.createFragment( getContext(), null );
+ if ( fragment == null ) {
+ Logger.e( TAG, "add fragment fail cause fragment == null, container is %s", ResourcesHelper.getResNameById( getApplicationContext(), containerId ) );
+ return;
+ }
+ mActivity.getSupportFragmentManager().beginTransaction()
+ .add( containerId, fragment, provider.getModuleName() )
+ .commitAllowingStateLoss();
+ }
+
+ @Override
+ public void setEnable( String module ) {
+ mEnableModuleName = module;
+ final Set< Map.Entry< String, IMogoModuleProvider > > entries = mCardProviders.entrySet();
+ if ( !entries.isEmpty() ) {
+ for ( Map.Entry< String, IMogoModuleProvider > entry : entries ) {
+ final String key = entry.getKey();
+ final IMogoModuleProvider provider = entry.getValue();
+ if ( TextUtils.equals( key, module ) ) {
+ provider.getCardLifecycle().onPerform();
+ } else {
+ provider.getCardLifecycle().onDisable();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onMapLoaded() {
+ if ( mEnableModuleName != null ) {
+ if ( mCardProviders.get( mEnableModuleName ) != null ) {
+ mCardProviders.get( mEnableModuleName ).getMapListener().onMapLoaded();
+ }
+ }
+ }
+
+ @Override
+ public void onTouch( MotionEvent motionEvent ) {
+ if ( mEnableModuleName != null ) {
+ if ( mCardProviders.get( mEnableModuleName ) != null ) {
+ mCardProviders.get( mEnableModuleName ).getMapListener().onTouch( motionEvent );
+ }
+ }
+ }
+
+ @Override
+ public void onPOIClick( MogoPoi poi ) {
+ if ( mEnableModuleName != null ) {
+ if ( mCardProviders.get( mEnableModuleName ) != null ) {
+ mCardProviders.get( mEnableModuleName ).getMapListener().onPOIClick( poi );
+ }
+ }
+ }
+}
diff --git a/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml b/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml
new file mode 100644
index 0000000000..f6668124ea
--- /dev/null
+++ b/modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml
@@ -0,0 +1,11 @@
+
+
+ * 地图图层,地图操作都在这个图层完成
+ */
+public class MapFragment extends MvpFragment< MapView, MapPresenter > implements MapView {
+
+ private MogoMapView mMogoMapView;
+ private IMogoMap mMogoMap;
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.module_map_fragment_map;
+ }
+
+ @Override
+ protected void initViews() {
+ mMogoMapView = findViewById( R.id.module_map_id_map );
+ mMogoMap = mMogoMapView.getMap();
+ }
+
+ @NonNull
+ @Override
+ protected MapPresenter createPresenter() {
+ return new MapPresenter( this );
+ }
+
+ @Override
+ public void onActivityCreated( @Nullable Bundle savedInstanceState ) {
+ super.onActivityCreated( savedInstanceState );
+ if ( mMogoMapView != null ) {
+ mMogoMapView.onCreate( savedInstanceState );
+ }
+ initMapView();
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ if ( mMogoMapView != null ) {
+ mMogoMapView.onPause();
+ }
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ if ( mMogoMapView != null ) {
+ mMogoMapView.onResume();
+ }
+ }
+
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
+ if ( mMogoMapView != null ) {
+ mMogoMapView.onDestroy();
+ }
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ if ( mMogoMapView != null ) {
+ mMogoMapView.onLowMemory();
+ }
+ }
+
+ private void initMapView() {
+ if ( mMogoMap != null ) {
+ IUiSettings settings = mMogoMap.getUiSettings();
+ if ( settings != null ) {
+ settings.setCompassEnabled( false );
+ settings.setLogoEnable( false );
+ settings.setMyLocationButtonEnabled( false );
+ settings.setRotateGesturesEnabled( false );
+ settings.setZoomControlsEnabled( false );
+ settings.setScaleControlsEnabled( false );
+ }
+ }
+
+ }
+}
diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragmentProvider.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragmentProvider.java
new file mode 100644
index 0000000000..eedb42b6b5
--- /dev/null
+++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapFragmentProvider.java
@@ -0,0 +1,65 @@
+package com.mogo.module.map;
+
+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.module.common.MogoModulePaths;
+import com.mogo.service.module.IMogoModuleLifecycle;
+import com.mogo.service.module.IMogoModuleProvider;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * 描述
+ */
+@Route( path = MogoModulePaths.PATH_MODULE_MAP )
+public class MapFragmentProvider implements IMogoModuleProvider {
+
+ private MapFragment mMapFragment;
+
+ @Override
+ public Fragment createFragment( Context context, Bundle data ) {
+ mMapFragment = new MapFragment();
+ mMapFragment.setArguments( data );
+ return mMapFragment;
+ }
+
+ @NonNull
+ @Override
+ public String getModuleName() {
+ return MogoModulePaths.PATH_MODULE_MAP;
+ }
+
+ @Override
+ public void init( Context context ) {
+
+ }
+
+ @Override
+ public int getType() {
+ return IMogoModuleProvider.TYPE_FRAGMENT;
+ }
+
+
+ @Override
+ public View createView( Context context ) {
+ return null;
+ }
+
+ @Override
+ public IMogoModuleLifecycle getCardLifecycle() {
+ return null;
+ }
+
+ @Override
+ public IMogoMapListener getMapListener() {
+ return null;
+ }
+}
diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java
new file mode 100644
index 0000000000..55c045ca9f
--- /dev/null
+++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapPresenter.java
@@ -0,0 +1,18 @@
+package com.mogo.module.map;
+
+import com.mogo.commons.mvp.Presenter;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-23
+ *
+ * 描述
+ */
+public class MapPresenter extends Presenter< MapView > {
+
+ public MapPresenter( MapView view ) {
+ super( view );
+ }
+
+
+}
diff --git a/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapView.java b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapView.java
new file mode 100644
index 0000000000..52acc523c2
--- /dev/null
+++ b/modules/mogo-module-map/src/main/java/com/mogo/module/map/MapView.java
@@ -0,0 +1,12 @@
+package com.mogo.module.map;
+
+import com.mogo.commons.mvp.IView;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-23
+ *
+ * 地图view
+ */
+public interface MapView extends IView {
+}
diff --git a/modules/mogo-module-map/src/main/res/layout/module_map_fragment_map.xml b/modules/mogo-module-map/src/main/res/layout/module_map_fragment_map.xml
new file mode 100644
index 0000000000..696bce61e8
--- /dev/null
+++ b/modules/mogo-module-map/src/main/res/layout/module_map_fragment_map.xml
@@ -0,0 +1,10 @@
+
+
* Arouter.getInstance().path("").navigate()
*/
+@Keep
public class MogoServicePaths {
/**
* 地图服务接口路径
*/
- public static final String PATH_MAP_SERVICE = "/mogo/services/map";
+ @Keep
+ public static final String PATH_SERVICES_MAP = "/services/map";
/**
* 图片接口
*/
- public static final String PATH_IMAGE_LOADER = "/mogo/utils/imageloader";
+ @Keep
+ public static final String PATH_UTILS_IMAGE_LOADER = "/utils/imageloader";
+
+ /**
+ * 埋点接口
+ */
+ @Keep
+ public static final String PATH_UTILS_ANALYTICS = "/utils/analytics";
+
+
}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/analytics/IMogoAnalytics.java b/services/mogo-service-api/src/main/java/com/mogo/service/analytics/IMogoAnalytics.java
new file mode 100644
index 0000000000..13100732d7
--- /dev/null
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/analytics/IMogoAnalytics.java
@@ -0,0 +1,26 @@
+package com.mogo.service.analytics;
+
+import androidx.annotation.Keep;
+
+import com.alibaba.android.arouter.facade.template.IProvider;
+
+import java.util.Map;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-23
+ *
+ * 描述
+ */
+@Keep
+public interface IMogoAnalytics extends IProvider {
+
+ /**
+ * 埋点
+ *
+ * @param event 事件名称
+ * @param properties 埋点参数
+ */
+ @Keep
+ void track( String event, Map< String, Object > properties );
+}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/imageloader/IMogoImageLoaderListener.java b/services/mogo-service-api/src/main/java/com/mogo/service/imageloader/IMogoImageLoaderListener.java
index 7a5bab5de9..4424ae0c62 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/imageloader/IMogoImageLoaderListener.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/imageloader/IMogoImageLoaderListener.java
@@ -2,19 +2,24 @@ package com.mogo.service.imageloader;
import android.graphics.Bitmap;
+import androidx.annotation.Keep;
+
/**
* @author congtaowang
* @since 2019-12-23
*
* 图片下载接口
*/
+@Keep
public interface IMogoImageLoaderListener {
+ @Keep
void onStart();
-// void onProcess( int completedSize, int totalSize );
-
+ // void onProcess( int completedSize, int totalSize );
+ @Keep
void onCompleted( Bitmap bitmap );
+ @Keep
void onFailure( Exception e );
}
\ No newline at end of file
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/imageloader/IMogoImageloader.java b/services/mogo-service-api/src/main/java/com/mogo/service/imageloader/IMogoImageloader.java
index e03f59686c..ed4b0b81e5 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/imageloader/IMogoImageloader.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/imageloader/IMogoImageloader.java
@@ -2,6 +2,8 @@ package com.mogo.service.imageloader;
import android.content.Context;
+import androidx.annotation.Keep;
+
import com.alibaba.android.arouter.facade.template.IProvider;
/**
@@ -10,19 +12,27 @@ import com.alibaba.android.arouter.facade.template.IProvider;
*
* 图片接口
*/
+@Keep
public interface IMogoImageloader extends IProvider {
+ @Keep
void init( Context context );
+ @Keep
void displayImage( String url, MogoImageView imageView );
+ @Keep
void displayImage( String url, MogoImageView imageView, int width, int height );
+ @Keep
void displayImage( String url, MogoImageView imageView, int width, int height, final IMogoImageLoaderListener listener );
+ @Keep
void displayImage( String url, MogoImageView imageView, final IMogoImageLoaderListener listener );
+ @Keep
void downloadImage( Context context, String url, IMogoImageLoaderListener listener );
+ @Keep
void destroy();
}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/imageloader/MogoImageView.java b/services/mogo-service-api/src/main/java/com/mogo/service/imageloader/MogoImageView.java
index 1719b7e803..18612539a7 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/imageloader/MogoImageView.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/imageloader/MogoImageView.java
@@ -7,6 +7,7 @@ import android.graphics.Matrix;
import android.util.AttributeSet;
import androidx.annotation.DrawableRes;
+import androidx.annotation.Keep;
import com.facebook.drawee.view.GenericDraweeView;
import com.mogo.service.R;
@@ -17,6 +18,7 @@ import com.mogo.service.R;
*
* 封装 facebook GenericDraweeView,实现占位图、失败占位图、形状、边框、模糊等效果
*/
+@Keep
public class MogoImageView extends GenericDraweeView {
private int mPlaceHolder;
@@ -48,19 +50,19 @@ public class MogoImageView extends GenericDraweeView {
public MogoImageView( Context context, AttributeSet attrs, int theme ) {
super( context, attrs, theme );
TypedArray arrays = context.obtainStyledAttributes( attrs, R.styleable.MogoImageView );
- mPlaceHolder = arrays.getResourceId( R.styleable.MogoImageView_placeHolder, 0 );
- mFailureHolder = arrays.getResourceId( R.styleable.MogoImageView_failureHolder, 0 );
- mOverlayImageId = arrays.getResourceId( R.styleable.MogoImageView_overlayImageId, 0 );
- mShape = arrays.getInt( R.styleable.MogoImageView_shape, SHAPE_NORMAL );
- mRadius = arrays.getDimensionPixelSize( R.styleable.MogoImageView_radius, 0 );
- mTopLeftRadius = arrays.getDimensionPixelSize( R.styleable.MogoImageView_topLeftRadius, 0 );
- mTopRightRadius = arrays.getDimensionPixelSize( R.styleable.MogoImageView_topRightRadius, 0 );
- mBottomLeftRadius = arrays.getDimensionPixelSize( R.styleable.MogoImageView_bottomLeftRadius, 0 );
- mBottomRightRadius = arrays.getDimensionPixelSize( R.styleable.MogoImageView_bottomRightRadius, 0 );
- mBorderWidth = arrays.getDimensionPixelSize( R.styleable.MogoImageView_shapeBorderWidth, 0 );
- mBorderColor = arrays.getColor( R.styleable.MogoImageView_borderColor, Color.WHITE );
- mIsBlur = arrays.getBoolean( R.styleable.MogoImageView_isBlur, false );
- mBlurRadius = arrays.getInt( R.styleable.MogoImageView_blurRadius, 25 );
+ mPlaceHolder = arrays.getResourceId( R.styleable.MogoImageView_miv_placeHolder, 0 );
+ mFailureHolder = arrays.getResourceId( R.styleable.MogoImageView_miv_failureHolder, 0 );
+ mOverlayImageId = arrays.getResourceId( R.styleable.MogoImageView_miv_overlayImageId, 0 );
+ mShape = arrays.getInt( R.styleable.MogoImageView_miv_shape, SHAPE_NORMAL );
+ mRadius = arrays.getDimensionPixelSize( R.styleable.MogoImageView_miv_radius, 0 );
+ mTopLeftRadius = arrays.getDimensionPixelSize( R.styleable.MogoImageView_miv_topLeftRadius, 0 );
+ mTopRightRadius = arrays.getDimensionPixelSize( R.styleable.MogoImageView_miv_topRightRadius, 0 );
+ mBottomLeftRadius = arrays.getDimensionPixelSize( R.styleable.MogoImageView_miv_bottomLeftRadius, 0 );
+ mBottomRightRadius = arrays.getDimensionPixelSize( R.styleable.MogoImageView_miv_bottomRightRadius, 0 );
+ mBorderWidth = arrays.getDimensionPixelSize( R.styleable.MogoImageView_miv_shapeBorderWidth, 0 );
+ mBorderColor = arrays.getColor( R.styleable.MogoImageView_miv_borderColor, Color.WHITE );
+ mIsBlur = arrays.getBoolean( R.styleable.MogoImageView_miv_isBlur, false );
+ mBlurRadius = arrays.getInt( R.styleable.MogoImageView_miv_blurRadius, 25 );
arrays.recycle();
}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/map/IMogoMapService.java b/services/mogo-service-api/src/main/java/com/mogo/service/map/IMogoMapService.java
index 6334ef265a..2634b4e76e 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/map/IMogoMapService.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/map/IMogoMapService.java
@@ -3,12 +3,17 @@ package com.mogo.service.map;
import android.content.Context;
import com.alibaba.android.arouter.facade.template.IProvider;
+import com.mogo.map.listener.IMogoMapListener;
+import com.mogo.map.listener.IMogoMapListenerRegister;
import com.mogo.map.location.IMogoLocationClient;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
-import com.mogo.map.search.IMogoGeoSearch;
-import com.mogo.map.search.IMogoInputtipsSearch;
-import com.mogo.map.search.query.MogoInputtipsQuery;
+import com.mogo.map.search.geo.IMogoGeoSearch;
+import com.mogo.map.search.inputtips.IMogoInputtipsSearch;
+import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
+import com.mogo.map.search.poisearch.IMogoPoiSearch;
+import com.mogo.map.search.poisearch.MogoPoiSearch;
+import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
import java.util.ArrayList;
import java.util.List;
@@ -19,7 +24,7 @@ import java.util.List;
*
* 地图对外地接口
*/
-public interface IMogoMapService extends IProvider {
+public interface IMogoMapService extends IProvider, IMogoMapListenerRegister {
/**
* 获取定位服务实例
@@ -61,4 +66,25 @@ public interface IMogoMapService extends IProvider {
* @return
*/
IMogoGeoSearch getGeoSearch( Context context );
+
+ /**
+ * 注册地图事件
+ *
+ * @param listener 回调事件
+ */
+ void registerHostMapListener( IMogoMapListener listener );
+
+ /**
+ * 反注册注册地图事件
+ */
+ void unregisterHostMapListener();
+
+ /**
+ * poi搜索服务
+ *
+ * @param context
+ * @param query
+ * @return
+ */
+ IMogoPoiSearch getPoiSearch( Context context, MogoPoiSearchQuery query );
}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleLifecycle.java b/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleLifecycle.java
new file mode 100644
index 0000000000..66abf375ac
--- /dev/null
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleLifecycle.java
@@ -0,0 +1,20 @@
+package com.mogo.service.module;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-23
+ *
+ * 卡片生命周期
+ */
+public interface IMogoModuleLifecycle {
+
+ /**
+ * 卡片在最前面,可操作地图
+ */
+ void onPerform();
+
+ /**
+ * 卡片不可用,任何卡片的操作都会被launcher忽略
+ */
+ void onDisable();
+}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleProvider.java b/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleProvider.java
new file mode 100644
index 0000000000..f3157cb801
--- /dev/null
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/module/IMogoModuleProvider.java
@@ -0,0 +1,78 @@
+package com.mogo.service.module;
+
+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.template.IProvider;
+import com.mogo.map.listener.IMogoMapListener;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-24
+ *
+ * 模块 UI 接口
+ */
+public interface IMogoModuleProvider extends IProvider {
+
+ /**
+ * fragment 提供者
+ */
+ int TYPE_FRAGMENT = 1;
+
+ /**
+ * view 提供者
+ */
+ int TYPE_VIEW = 2;
+
+ /**
+ * 创建卡片
+ *
+ * @param context
+ * @return
+ */
+ Fragment createFragment( Context context, Bundle data );
+
+ /**
+ * 创建view
+ *
+ * @param context
+ * @return
+ */
+ View createView( Context context );
+
+ /**
+ * 唯一标识
+ *
+ * @return
+ */
+ @NonNull
+ String getModuleName();
+
+ /**
+ * 生命周期控制方法
+ *
+ * @return
+ */
+ IMogoModuleLifecycle getCardLifecycle();
+
+ /**
+ * 地图监听对象
+ *
+ * @return
+ */
+ IMogoMapListener getMapListener();
+
+ /**
+ * 是哪种类型的提供者
+ *
+ * {@link #TYPE_FRAGMENT}
+ * {@link #TYPE_VIEW}
+ *
+ * @return
+ */
+ int getType();
+}
diff --git a/services/mogo-service-api/src/main/res/values/attrs.xml b/services/mogo-service-api/src/main/res/values/attrs.xml
index febf72ba74..950c076b15 100644
--- a/services/mogo-service-api/src/main/res/values/attrs.xml
+++ b/services/mogo-service-api/src/main/res/values/attrs.xml
@@ -1,22 +1,22 @@
+ * 描述
+ */
+@Route( path = MogoServicePaths.PATH_UTILS_ANALYTICS )
+public class MogoAnalytics implements IMogoAnalytics {
+
+ private IMogoAnalytics mDelegate;
+
+ @Override
+ public void init( Context context ) {
+ mDelegate = MogoAnalyticsImpl.getInstance();
+ }
+
+ @Override
+ public void track( String event, Map< String, Object > properties ) {
+ if ( mDelegate != null ) {
+ mDelegate.track( event, properties );
+ }
+ }
+}
diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/analytics/impl/MogoAnalyticsImpl.java b/services/mogo-service/src/main/java/com/mogo/service/impl/analytics/impl/MogoAnalyticsImpl.java
new file mode 100644
index 0000000000..de04fc09a5
--- /dev/null
+++ b/services/mogo-service/src/main/java/com/mogo/service/impl/analytics/impl/MogoAnalyticsImpl.java
@@ -0,0 +1,47 @@
+package com.mogo.service.impl.analytics.impl;
+
+import android.content.Context;
+
+import com.mogo.commons.analytics.AnalyticsUtils;
+import com.mogo.service.analytics.IMogoAnalytics;
+
+import java.util.Map;
+
+/**
+ * @author congtaowang
+ * @since 2019-12-23
+ *
+ * 公司埋点库实现
+ */
+public class MogoAnalyticsImpl implements IMogoAnalytics {
+
+ private static volatile MogoAnalyticsImpl sInstance;
+
+ private MogoAnalyticsImpl() {
+ }
+
+ public static MogoAnalyticsImpl getInstance() {
+ if ( sInstance == null ) {
+ synchronized ( MogoAnalyticsImpl.class ) {
+ if ( sInstance == null ) {
+ sInstance = new MogoAnalyticsImpl();
+ }
+ }
+ }
+ return sInstance;
+ }
+
+ public synchronized void release() {
+ sInstance = null;
+ }
+
+ @Override
+ public void init( Context context ) {
+
+ }
+
+ @Override
+ public void track( String event, Map< String, Object > properties ) {
+ AnalyticsUtils.track( event, properties );
+ }
+}
diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/imageloader/MogoImageLoader.java b/services/mogo-service/src/main/java/com/mogo/service/impl/imageloader/MogoImageLoader.java
index 798306bd7d..8d2b505648 100644
--- a/services/mogo-service/src/main/java/com/mogo/service/impl/imageloader/MogoImageLoader.java
+++ b/services/mogo-service/src/main/java/com/mogo/service/impl/imageloader/MogoImageLoader.java
@@ -15,7 +15,7 @@ import com.mogo.service.impl.imageloader.glide.GlideImageLoader;
*
* 实现图片接口
*/
-@Route( path = MogoServicePaths.PATH_IMAGE_LOADER )
+@Route( path = MogoServicePaths.PATH_UTILS_IMAGE_LOADER )
public class MogoImageLoader implements IMogoImageloader {
private IMogoImageloader mDelegate;
diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/imageloader/glide/GlideImageLoader.java b/services/mogo-service/src/main/java/com/mogo/service/impl/imageloader/glide/GlideImageLoader.java
index a6a17fb32c..2d577f3dc0 100644
--- a/services/mogo-service/src/main/java/com/mogo/service/impl/imageloader/glide/GlideImageLoader.java
+++ b/services/mogo-service/src/main/java/com/mogo/service/impl/imageloader/glide/GlideImageLoader.java
@@ -27,7 +27,6 @@ import com.mogo.utils.glide.GlideApp;
*
* 实现图片接口
*/
-@Route( path = MogoServicePaths.PATH_IMAGE_LOADER )
public class GlideImageLoader implements IMogoImageloader {
private static volatile GlideImageLoader sInstance;
diff --git a/services/mogo-service/src/main/java/com/mogo/service/impl/map/MogoMapService.java b/services/mogo-service/src/main/java/com/mogo/service/impl/map/MogoMapService.java
index e1ab65de28..577aeb5428 100644
--- a/services/mogo-service/src/main/java/com/mogo/service/impl/map/MogoMapService.java
+++ b/services/mogo-service/src/main/java/com/mogo/service/impl/map/MogoMapService.java
@@ -4,15 +4,20 @@ import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.MogoMap;
+import com.mogo.map.listener.MogoMapListenerHandler;
import com.mogo.map.location.IMogoLocationClient;
import com.mogo.map.location.MogoLocationClient;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
-import com.mogo.map.search.IMogoGeoSearch;
-import com.mogo.map.search.IMogoInputtipsSearch;
-import com.mogo.map.search.MogoGeoSearch;
-import com.mogo.map.search.MogoInputtipsSearch;
-import com.mogo.map.search.query.MogoInputtipsQuery;
+import com.mogo.map.search.geo.IMogoGeoSearch;
+import com.mogo.map.search.inputtips.IMogoInputtipsSearch;
+import com.mogo.map.search.geo.MogoGeoSearch;
+import com.mogo.map.search.inputtips.MogoInputtipsSearch;
+import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
+import com.mogo.map.listener.IMogoMapListener;
+import com.mogo.map.search.poisearch.IMogoPoiSearch;
+import com.mogo.map.search.poisearch.MogoPoiSearch;
+import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
import com.mogo.service.map.IMogoMapService;
import com.mogo.service.MogoServicePaths;
@@ -25,7 +30,7 @@ import java.util.List;
*
* 地图对外地接口
*/
-@Route( path = MogoServicePaths.PATH_MAP_SERVICE )
+@Route( path = MogoServicePaths.PATH_SERVICES_MAP )
public class MogoMapService implements IMogoMapService {
@Override
@@ -61,6 +66,21 @@ public class MogoMapService implements IMogoMapService {
return new MogoGeoSearch( context );
}
+ @Override
+ public void registerHostMapListener( IMogoMapListener listener ) {
+ MogoMapListenerHandler.getInstance().registerHostMapListener( listener );
+ }
+
+ @Override
+ public void unregisterHostMapListener() {
+ MogoMapListenerHandler.getInstance().unregisterHostMapListener();
+ }
+
+ @Override
+ public IMogoPoiSearch getPoiSearch( Context context, MogoPoiSearchQuery query ) {
+ return new MogoPoiSearch( context, query );
+ }
+
@Override
public void init( Context context ) {
diff --git a/settings.gradle b/settings.gradle
index e1990b3af7..374dce85ee 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -5,3 +5,7 @@ include ':services:mogo-service-api'
include ':services:mogo-service'
include ':libraries:mogo-map'
include ':foudations:mogo-commons'
+include ':modules:mogo-module-map'
+include ':modules:mogo-module-common'
+include ':modules:mogo-module-main'
+include ':demo:demo-module-map'
+ *
+ * Every {@link #edit} call must be matched by a call to {@link Editor#commit}
+ * or {@link Editor#abort}. Committing is atomic: a read observes the full set
+ * of values as they were before or after the commit, but never a mix of values.
+ *
+ *