From 8340fff2f50eb631c45a35febe0ef444d8cf1aae Mon Sep 17 00:00:00 2001 From: zhangyuanzhen Date: Tue, 31 Dec 2019 16:19:49 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0room=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.gradle | 118 ++++++++++-------- modules/mogo-module-navi/.gitignore | 1 + modules/mogo-module-navi/build.gradle | 42 +++++++ modules/mogo-module-navi/consumer-rules.pro | 0 modules/mogo-module-navi/proguard-rules.pro | 21 ++++ .../src/main/AndroidManifest.xml | 2 + .../module/navi/database/AppDataBase.java | 33 +++++ .../module/navi/database/bean/POIInfo.java | 64 ++++++++++ .../mogo/module/navi/database/dao/POIDao.java | 32 +++++ .../src/main/res/values/strings.xml | 3 + settings.gradle | 1 + 11 files changed, 262 insertions(+), 55 deletions(-) create mode 100644 modules/mogo-module-navi/.gitignore create mode 100644 modules/mogo-module-navi/build.gradle create mode 100644 modules/mogo-module-navi/consumer-rules.pro create mode 100644 modules/mogo-module-navi/proguard-rules.pro create mode 100644 modules/mogo-module-navi/src/main/AndroidManifest.xml create mode 100644 modules/mogo-module-navi/src/main/java/com/mogo/module/navi/database/AppDataBase.java create mode 100644 modules/mogo-module-navi/src/main/java/com/mogo/module/navi/database/bean/POIInfo.java create mode 100644 modules/mogo-module-navi/src/main/java/com/mogo/module/navi/database/dao/POIDao.java create mode 100644 modules/mogo-module-navi/src/main/res/values/strings.xml diff --git a/config.gradle b/config.gradle index a1ee099928..1282f4dd36 100644 --- a/config.gradle +++ b/config.gradle @@ -1,60 +1,68 @@ ext { - android = [ - applicationId : "com.mogo.launcher", - compileSdkVersion: 29, - buildToolsVersion: "29.0.2", - minSdkVersion : 19, - targetSdkVersion : 22, - versionCode : 1, - versionName : "1.0.0", - ] + android = [ + applicationId: "com.mogo.launcher", + compileSdkVersion: 29, + buildToolsVersion: "29.0.2", + minSdkVersion: 19, + targetSdkVersion: 22, + versionCode: 1, + versionName: "1.0.0", + ] - dependencies = [ - // androidx - androidxappcompat : "androidx.appcompat:appcompat:1.0.2", - androidxconstraintlayout: "androidx.constraintlayout:constraintlayout:1.1.3", - androidxmultidex : "androidx.multidex:multidex:2.0.1", - // 测试 - junit : "junit:junit:4.12", - androidxjunit : "androidx.test.ext:junit:1.1.0", - androidxespressocore : "androidx.test.espresso:espresso-core:3.1.1", - // 地图 - amapnavi3dmap : "com.amap.api:navi-3dmap:latest.integration", - amapsearch : "com.amap.api:search:latest.integration", - amaplocation : "com.amap.api:location:latest.integration", - // json 转换 - gson : "com.google.code.gson:gson:2.8.4", - // 内存泄漏检测 - debugleakcanary : "com.squareup.leakcanary:leakcanary-android:1.6.1", - releaseleakcanary : "com.squareup.leakcanary:leakcanary-android-no-op:1.6.1", - testleakcanary : "com.squareup.leakcanary:leakcanary-android-no-op:1.6.1", - //rxJava - rxjava : "io.reactivex.rxjava2:rxjava:2.2.2", - rxandroid : "io.reactivex.rxjava2:rxandroid:2.1.0", - // arouter - arouter : "com.alibaba:arouter-api:1.5.0", - aroutercompiler : "com.alibaba:arouter-compiler:1.2.2", - // glide - glide : 'com.github.bumptech.glide:glide:4.8.0', - glideokhttp3 : 'com.github.bumptech.glide:okhttp3-integration:4.8.0', - glideanno : 'com.github.bumptech.glide:annotations:4.8.0', - glidecompiler : 'com.github.bumptech.glide:compiler:4.8.0', - supportannos : "com.android.support:support-annotations:28.0.0", - // fresco - fresco : 'com.facebook.fresco:fresco:1.1.0', - // 公司服务 - 语音 - aiassist : "com.zhidaoauto.common:service:1.0.4", - // 公司服务 - 埋点 - analytics : "com.elegant.analytics:analytics:1.1.19", + dependencies = [ + // androidx + androidxappcompat: "androidx.appcompat:appcompat:1.0.2", + androidxconstraintlayout: "androidx.constraintlayout:constraintlayout:1.1.3", + androidxmultidex: "androidx.multidex:multidex:2.0.1", + // 测试 + junit: "junit:junit:4.12", + androidxjunit: "androidx.test.ext:junit:1.1.0", + androidxespressocore: "androidx.test.espresso:espresso-core:3.1.1", + // 地图 + amapnavi3dmap: "com.amap.api:navi-3dmap:latest.integration", + amapsearch: "com.amap.api:search:latest.integration", + amaplocation: "com.amap.api:location:latest.integration", + // json 转换 + gson: "com.google.code.gson:gson:2.8.4", + // 内存泄漏检测 + debugleakcanary: "com.squareup.leakcanary:leakcanary-android:1.6.1", + releaseleakcanary: "com.squareup.leakcanary:leakcanary-android-no-op:1.6.1", + testleakcanary: "com.squareup.leakcanary:leakcanary-android-no-op:1.6.1", + //rxJava + rxjava: "io.reactivex.rxjava2:rxjava:2.2.2", + rxandroid: "io.reactivex.rxjava2:rxandroid:2.1.0", + // arouter + arouter: "com.alibaba:arouter-api:1.5.0", + aroutercompiler: "com.alibaba:arouter-compiler:1.2.2", + // glide + glide: 'com.github.bumptech.glide:glide:4.8.0', + glideokhttp3: 'com.github.bumptech.glide:okhttp3-integration:4.8.0', + glideanno: 'com.github.bumptech.glide:annotations:4.8.0', + glidecompiler: 'com.github.bumptech.glide:compiler:4.8.0', + supportannos: "com.android.support:support-annotations:28.0.0", + // fresco + 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", + // 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', - ] + // leakcanary + leakcanary: 'com.squareup.leakcanary:leakcanary-android:1.5.4', + leakcanarynoop: 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4', + + // add for room + room: "android.arch.persistence.room:runtime:1.1.1", + roomAnnotationProcessor: 'android.arch.persistence.room:compiler:1.1.1', + + // rxjava2 with room + roomRxjava: "android.arch.persistence.room:rxjava2:1.1.1" + + ] } \ No newline at end of file diff --git a/modules/mogo-module-navi/.gitignore b/modules/mogo-module-navi/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/modules/mogo-module-navi/.gitignore @@ -0,0 +1 @@ +/build diff --git a/modules/mogo-module-navi/build.gradle b/modules/mogo-module-navi/build.gradle new file mode 100644 index 0000000000..71c043611c --- /dev/null +++ b/modules/mogo-module-navi/build.gradle @@ -0,0 +1,42 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion rootProject.ext.android.compileSdkVersion + buildToolsVersion rootProject.ext.android.buildToolsVersion + + defaultConfig { + minSdkVersion rootProject.ext.android.minSdkVersion + targetSdkVersion rootProject.ext.android.targetSdkVersion + 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 project(":libraries:mogo-map") + implementation project(":libraries:mogo-map-api") + implementation project(":foudations:mogo-utils") + api project(":foudations:mogo-commons") + api project(':services:mogo-service-api') + implementation project(':modules:mogo-module-common') + implementation project(':modules:mogo-module-map') + implementation rootProject.ext.dependencies.androidxappcompat + implementation rootProject.ext.dependencies.androidxconstraintlayout + implementation rootProject.ext.dependencies.arouter + implementation rootProject.ext.dependencies.room + implementation rootProject.ext.dependencies.roomAnnotationProcessor + implementation rootProject.ext.dependencies.roomRxjava + annotationProcessor rootProject.ext.dependencies.aroutercompiler +} diff --git a/modules/mogo-module-navi/consumer-rules.pro b/modules/mogo-module-navi/consumer-rules.pro new file mode 100644 index 0000000000..e69de29bb2 diff --git a/modules/mogo-module-navi/proguard-rules.pro b/modules/mogo-module-navi/proguard-rules.pro new file mode 100644 index 0000000000..f1b424510d --- /dev/null +++ b/modules/mogo-module-navi/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-navi/src/main/AndroidManifest.xml b/modules/mogo-module-navi/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..26aa7c5a9f --- /dev/null +++ b/modules/mogo-module-navi/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + diff --git a/modules/mogo-module-navi/src/main/java/com/mogo/module/navi/database/AppDataBase.java b/modules/mogo-module-navi/src/main/java/com/mogo/module/navi/database/AppDataBase.java new file mode 100644 index 0000000000..911a337086 --- /dev/null +++ b/modules/mogo-module-navi/src/main/java/com/mogo/module/navi/database/AppDataBase.java @@ -0,0 +1,33 @@ +package com.mogo.module.navi.database; + +import android.content.Context; +import androidx.room.Database; +import androidx.room.Room; +import androidx.room.RoomDatabase; +import com.mogo.module.navi.database.bean.POIInfo; +import com.mogo.module.navi.database.dao.POIDao; + +/** + * @author zyz + * 2019-08-15. + */ + +@Database(entities = { POIInfo.class}, version = 1) +public abstract class AppDataBase extends RoomDatabase { + public abstract POIDao poiDao(); + + private static volatile AppDataBase INSTANCE; + + public static AppDataBase getDatabase(Context context){ + if (INSTANCE == null) { + synchronized (AppDataBase.class) { + if (INSTANCE == null) { + INSTANCE = Room.databaseBuilder(context.getApplicationContext(), + AppDataBase.class, "android_room_dev.db").build(); + } + } + } + return INSTANCE; + } + +} diff --git a/modules/mogo-module-navi/src/main/java/com/mogo/module/navi/database/bean/POIInfo.java b/modules/mogo-module-navi/src/main/java/com/mogo/module/navi/database/bean/POIInfo.java new file mode 100644 index 0000000000..21e963e2f2 --- /dev/null +++ b/modules/mogo-module-navi/src/main/java/com/mogo/module/navi/database/bean/POIInfo.java @@ -0,0 +1,64 @@ +package com.mogo.module.navi.database.bean; + +import androidx.room.Entity; +import androidx.room.PrimaryKey; +import org.jetbrains.annotations.NotNull; + +/** + * @author zyz + * 2019-08-15. + */ +@Entity +public class POIInfo { + @PrimaryKey + @NotNull + public String pId; + private String name; + private String address; + private double lat; + private double lot; + + + public POIInfo(String pId, String name, String address, double lat, double lot) { + this.pId = pId; + this.name = name; + this.address = address; + this.lat = lat; + this.lot = lot; + } + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public double getLat() { + return lat; + } + + public void setLat(double lat) { + this.lat = lat; + } + + public double getLot() { + return lot; + } + + public void setLot(double lot) { + this.lot = lot; + } + + +} diff --git a/modules/mogo-module-navi/src/main/java/com/mogo/module/navi/database/dao/POIDao.java b/modules/mogo-module-navi/src/main/java/com/mogo/module/navi/database/dao/POIDao.java new file mode 100644 index 0000000000..729bf7bf4d --- /dev/null +++ b/modules/mogo-module-navi/src/main/java/com/mogo/module/navi/database/dao/POIDao.java @@ -0,0 +1,32 @@ +package com.mogo.module.navi.database.dao; + +import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.OnConflictStrategy; +import androidx.room.Query; +import com.mogo.module.navi.database.bean.POIInfo; +import io.reactivex.Flowable; +import java.util.List; + +/** + * @author zyz + * 2019-08-15. + */ +@Dao +public interface POIDao { + + /** + * 插入地址信息 + * @param poiInfos GEO信息 + * @return + */ + @Insert(onConflict = OnConflictStrategy.REPLACE) + List insert(POIInfo... poiInfos); + + /** + * 获取地址列表 + * @return + */ + @Query("SELECT * from poiinfo") + Flowable> load(); +} diff --git a/modules/mogo-module-navi/src/main/res/values/strings.xml b/modules/mogo-module-navi/src/main/res/values/strings.xml new file mode 100644 index 0000000000..d6991f8270 --- /dev/null +++ b/modules/mogo-module-navi/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + mogo-module-navi + diff --git a/settings.gradle b/settings.gradle index a95ecf51ee..aab1abb27e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,6 +8,7 @@ include ':foudations:mogo-commons' include ':modules:mogo-module-map' include ':modules:mogo-module-common' include ':modules:mogo-module-main' +include ':modules:mogo-module-navi' include ':demo:demo-module-map' include ':libraries:map-amap' //include ':libraries:map-baidu' From 5762b771e303a5f5205212748b08b9ad3a1f97d3 Mon Sep 17 00:00:00 2001 From: zhangyuanzhen Date: Tue, 31 Dec 2019 19:25:48 +0800 Subject: [PATCH 2/3] add recyclerview --- config.gradle | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/config.gradle b/config.gradle index 0bffaa2dd2..8c53bc3057 100644 --- a/config.gradle +++ b/config.gradle @@ -14,6 +14,8 @@ ext { androidxappcompat : "androidx.appcompat:appcompat:1.0.2", androidxconstraintlayout: "androidx.constraintlayout:constraintlayout:1.1.3", androidxmultidex : "androidx.multidex:multidex:2.0.1", + androidxviewpager2 : "androidx.viewpager2:viewpager2:1.0.0", + androidxrecyclerview : "androidx.recyclerview:recyclerview:1.1.0", // 测试 junit : "junit:junit:4.12", androidxjunit : "androidx.test.ext:junit:1.1.0", @@ -54,15 +56,15 @@ ext { 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', + leakcanary : 'com.squareup.leakcanary:leakcanary-android:1.5.4', + leakcanarynoop : 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4', // add for room - room: "android.arch.persistence.room:runtime:1.1.1", - roomAnnotationProcessor: 'android.arch.persistence.room:compiler:1.1.1', + room : "android.arch.persistence.room:runtime:1.1.1", + roomAnnotationProcessor : 'android.arch.persistence.room:compiler:1.1.1', // rxjava2 with room - roomRxjava: "android.arch.persistence.room:rxjava2:1.1.1", + roomRxjava : "android.arch.persistence.room:rxjava2:1.1.1", // leakcanary From 50d7c8bf2f7c32aebe1320bbf212671a3949d56d Mon Sep 17 00:00:00 2001 From: lixiaopeng Date: Thu, 2 Jan 2020 12:05:11 +0800 Subject: [PATCH 3/3] opt --- .idea/misc.xml | 2 +- app/build.gradle | 2 + .../com/mogo/launcher/MogoApplication.java | 2 + config.gradle | 1 + demo/tanlu-module/.gitignore | 1 + demo/tanlu-module/build.gradle | 53 +++ demo/tanlu-module/consumer-rules.pro | 0 demo/tanlu-module/gradle.properties | 3 + demo/tanlu-module/proguard-rules.pro | 21 + .../zhidao/tanlu/ExampleInstrumentedTest.java | 27 ++ .../tanlu-module/src/main/AndroidManifest.xml | 2 + .../zhidao/tanlu/TanluCardViewFragment.java | 365 ++++++++++++++++++ .../zhidao/tanlu/TanluCardViewProvider.java | 79 ++++ .../java/com/zhidao/tanlu/TanluConstants.java | 12 + .../zhidao/tanlu/TanluInfoWindowAdapter.java | 131 +++++++ .../com/zhidao/tanlu/TanluServiceHandler.java | 70 ++++ .../res/layout/tanlu_module_bubble_marker.xml | 23 ++ .../res/layout/tanlu_module_card_view.xml | 157 ++++++++ .../res/layout/tanlu_module_info_window.xml | 46 +++ .../layout/tanlu_module_poi_info_window.xml | 27 ++ .../src/main/res/values/colors.xml | 18 + .../src/main/res/values/strings.xml | 3 + .../com/zhidao/tanlu/ExampleUnitTest.java | 17 + gradle.properties | 1 + modules/mogo-module-navi/build.gradle | 10 +- .../module/navi/database/AppDataBase.java | 2 +- .../module/navi/database/bean/POIInfo.java | 1 + settings.gradle | 1 + upload.sh | 3 +- 29 files changed, 1076 insertions(+), 4 deletions(-) create mode 100644 demo/tanlu-module/.gitignore create mode 100644 demo/tanlu-module/build.gradle create mode 100644 demo/tanlu-module/consumer-rules.pro create mode 100644 demo/tanlu-module/gradle.properties create mode 100644 demo/tanlu-module/proguard-rules.pro create mode 100644 demo/tanlu-module/src/androidTest/java/com/zhidao/tanlu/ExampleInstrumentedTest.java create mode 100644 demo/tanlu-module/src/main/AndroidManifest.xml create mode 100644 demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluCardViewFragment.java create mode 100644 demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluCardViewProvider.java create mode 100644 demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluConstants.java create mode 100644 demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluInfoWindowAdapter.java create mode 100644 demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluServiceHandler.java create mode 100644 demo/tanlu-module/src/main/res/layout/tanlu_module_bubble_marker.xml create mode 100644 demo/tanlu-module/src/main/res/layout/tanlu_module_card_view.xml create mode 100644 demo/tanlu-module/src/main/res/layout/tanlu_module_info_window.xml create mode 100644 demo/tanlu-module/src/main/res/layout/tanlu_module_poi_info_window.xml create mode 100644 demo/tanlu-module/src/main/res/values/colors.xml create mode 100644 demo/tanlu-module/src/main/res/values/strings.xml create mode 100644 demo/tanlu-module/src/test/java/com/zhidao/tanlu/ExampleUnitTest.java diff --git a/.idea/misc.xml b/.idea/misc.xml index 8a8f75bfe2..703e5d4b89 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,7 +5,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index afb298b173..055b05b947 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -61,11 +61,13 @@ dependencies { implementation rootProject.ext.dependencies.moduledemo implementation rootProject.ext.dependencies.moduledemo2 implementation rootProject.ext.dependencies.modulecommon + implementation rootProject.ext.dependencies.tanlu } else { implementation project(':modules:mogo-module-main') implementation project(':foudations:mogo-commons') implementation project(':modules:mogo-module-common') implementation project(':demo:demo-module-map') implementation project(':demo:demo-module-map2') + implementation project(':demo:tanlu-module') } } diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index 2754e27346..01784418b0 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -8,6 +8,7 @@ import com.mogo.commons.AbsMogoApplication; import com.mogo.demo.module.map.DemoConstants; import com.mogo.demo.module.map2.Demo2Constants; import com.mogo.module.common.MogoModulePaths; +import com.zhidao.tanlu.TanluConstants; /** * @author congtaowang @@ -28,5 +29,6 @@ public class MogoApplication extends AbsMogoApplication { MultiDex.install( base ); MogoModulePaths.addModule( DemoConstants.TAG ); MogoModulePaths.addModule( Demo2Constants.TAG ); + MogoModulePaths.addModule( TanluConstants.TAG ); } } diff --git a/config.gradle b/config.gradle index 8c53bc3057..dcf0fd8157 100644 --- a/config.gradle +++ b/config.gradle @@ -78,6 +78,7 @@ ext { // modules moduledemo : "com.mogo.module:module-demo:${DEMO_MODULE_MAP_VERSION}", moduledemo2 : "com.mogo.module:module-demo2:${DEMO_MODULE_MAP2_VERSION}", + tanlu : "com.mogo.module:tanlu-module:${MOGO_MODULE_TANLU_VERSION}", mogocommons : "com.mogo.commons:mogo-commons:${MOGO_COMMONS_VERSION}", mogoutils : "com.mogo.commons:mogo-utils:${MOGO_UTILS_VERSION}", mapamap : "com.mogo.map:map-amap:${MAP_AMAP_VERSION}", diff --git a/demo/tanlu-module/.gitignore b/demo/tanlu-module/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/demo/tanlu-module/.gitignore @@ -0,0 +1 @@ +/build diff --git a/demo/tanlu-module/build.gradle b/demo/tanlu-module/build.gradle new file mode 100644 index 0000000000..568e7ff94e --- /dev/null +++ b/demo/tanlu-module/build.gradle @@ -0,0 +1,53 @@ +apply plugin: 'com.android.library' +apply plugin: 'com.alibaba.arouter' + +android { + compileSdkVersion rootProject.ext.android.compileSdkVersion + buildToolsVersion rootProject.ext.android.buildToolsVersion + defaultConfig { + minSdkVersion rootProject.ext.android.minSdkVersion + targetSdkVersion rootProject.ext.android.targetSdkVersion + versionCode Integer.valueOf(VERSION_CODE) + versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION") + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles 'consumer-rules.pro' + + javaCompileOptions { + annotationProcessorOptions { + arguments = [AROUTER_MODULE_NAME: project.getName()] + } + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + + if (Boolean.valueOf(RELEASE)) { + implementation rootProject.ext.dependencies.mogomap + implementation rootProject.ext.dependencies.mogoutils + implementation rootProject.ext.dependencies.mogocommons + implementation rootProject.ext.dependencies.mogoserviceapi + implementation rootProject.ext.dependencies.modulecommon + } else { + implementation project(":libraries:mogo-map") + implementation project(":foudations:mogo-utils") + api project(":foudations:mogo-commons") + implementation project(':services:mogo-service-api') + implementation project(':modules:mogo-module-common') + } + implementation rootProject.ext.dependencies.androidxappcompat + implementation rootProject.ext.dependencies.androidxconstraintlayout + implementation rootProject.ext.dependencies.arouter + annotationProcessor rootProject.ext.dependencies.aroutercompiler +} +apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() + diff --git a/demo/tanlu-module/consumer-rules.pro b/demo/tanlu-module/consumer-rules.pro new file mode 100644 index 0000000000..e69de29bb2 diff --git a/demo/tanlu-module/gradle.properties b/demo/tanlu-module/gradle.properties new file mode 100644 index 0000000000..3b59b15369 --- /dev/null +++ b/demo/tanlu-module/gradle.properties @@ -0,0 +1,3 @@ +GROUP=com.mogo.module +POM_ARTIFACT_ID=module-tanlu +VERSION_CODE=1 diff --git a/demo/tanlu-module/proguard-rules.pro b/demo/tanlu-module/proguard-rules.pro new file mode 100644 index 0000000000..f1b424510d --- /dev/null +++ b/demo/tanlu-module/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/tanlu-module/src/androidTest/java/com/zhidao/tanlu/ExampleInstrumentedTest.java b/demo/tanlu-module/src/androidTest/java/com/zhidao/tanlu/ExampleInstrumentedTest.java new file mode 100644 index 0000000000..51d57e90b8 --- /dev/null +++ b/demo/tanlu-module/src/androidTest/java/com/zhidao/tanlu/ExampleInstrumentedTest.java @@ -0,0 +1,27 @@ +package com.zhidao.tanlu; + +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.zhidao.tanlu.test", appContext.getPackageName()); + } +} diff --git a/demo/tanlu-module/src/main/AndroidManifest.xml b/demo/tanlu-module/src/main/AndroidManifest.xml new file mode 100644 index 0000000000..c50e289745 --- /dev/null +++ b/demo/tanlu-module/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + diff --git a/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluCardViewFragment.java b/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluCardViewFragment.java new file mode 100644 index 0000000000..1133efc9a9 --- /dev/null +++ b/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluCardViewFragment.java @@ -0,0 +1,365 @@ +package com.zhidao.tanlu; + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.os.Bundle; +import android.view.MotionEvent; +import android.view.View; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.mogo.commons.mvp.IView; +import com.mogo.commons.mvp.MvpFragment; +import com.mogo.commons.mvp.Presenter; +import com.mogo.map.MogoLatLng; +import com.mogo.map.listener.IMogoMapListener; +import com.mogo.map.location.IMogoLocationListener; +import com.mogo.map.location.MogoLocation; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.map.marker.IMogoMarkerClickListener; +import com.mogo.map.marker.MogoMarkerOptions; +import com.mogo.map.model.MogoPoi; +import com.mogo.map.search.geo.MogoPoiItem; +import com.mogo.map.search.poisearch.IMogoPoiSearchListener; +import com.mogo.map.search.poisearch.MogoPoiResult; +import com.mogo.map.uicontroller.EnumMapUI; +import com.mogo.service.module.IMogoModuleLifecycle; +import com.mogo.utils.TipToast; +import com.mogo.utils.logger.Logger; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * @author lixiaopeng + * @description + * @since 2020-01-02 + */ +public class TanluCardViewFragment extends MvpFragment> + implements IView, + IMogoMarkerClickListener, + IMogoModuleLifecycle, + IMogoMapListener, + IMogoPoiSearchListener, + IMogoLocationListener { + + private static final String TAG = "TanluCardViewFragment"; + + private Button mAddMarker; + private Button mAddMarkers; + + private Bitmap mMarkerIcon; + private Bitmap mClickedMarkerIcon; + private TextView mLocInfo; + private TextView mLoc; + private Button m2D3D; + private CheckBox mNaviMode; + + private IMogoMarker mLastClickedMarker; + private TanluInfoWindowAdapter mDemoInfoWindowAdapter; + private MogoLocation mLocation; + + private int position = -1; + + @Override + protected int getLayoutId() { + return R.layout.tanlu_module_card_view; + } + + @Override + protected void initViews() { + position = getArguments().getInt("position"); + + mNaviMode = findViewById(R.id.demo_module_id_navi_mode); + + TanluServiceHandler.getPoiSearch().setPoiSearchListener(this); + mLocation = TanluServiceHandler.getLocationClient().getLastKnowLocation(); + + m2D3D = findViewById(R.id.demo_module_id_2d3d); + + mLocInfo = findViewById(R.id.demo_module_id_loc_info); + mLoc = findViewById(R.id.demo_module_id_loc); + mLoc.setOnClickListener( + new View.OnClickListener() { + @Override + public void onClick(View v) { + TanluServiceHandler.getLocationClient().start(4_000L); + } + } + ); + + mDemoInfoWindowAdapter = new TanluInfoWindowAdapter(getContext(), TanluServiceHandler.getNavi(), TanluServiceHandler.getImageloader()); + + mMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_search_poi_location); + mClickedMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_search_choice_point); + mAddMarker = findViewById(R.id.demo_module_id_add_marker); + mAddMarker.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + MogoMarkerOptions options = new MogoMarkerOptions() + .icon(mMarkerIcon) + .latitude(39.974525d) + .owner(TanluConstants.TAG) + .longitude(116.41733d); + IMogoMarker marker = TanluServiceHandler.getMarkerManager().addMarker(TanluConstants.TAG, options); + marker.setInfoWindowAdapter(mDemoInfoWindowAdapter); + marker.setOnMarkerClickListener(TanluCardViewFragment.this); + } + }); + mAddMarkers = findViewById(R.id.demo_module_id_add_markers); + mAddMarkers.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + ArrayList optionsList = new ArrayList<>(); + for (int i = 0; i < 10; i++) { + MogoMarkerOptions options = new MogoMarkerOptions() + .owner(TanluConstants.TAG) + .latitude(39.974525d + new Random().nextDouble()) + .longitude(116.41733d + new Random().nextDouble()); + if (i % 2 == 0) { + options.icon(mMarkerIcon); + } else { + options.icon(mDemoInfoWindowAdapter.getMarkerView(options)); + } + optionsList.add(options); + } + List iMogoMarkers = TanluServiceHandler.getMarkerManager().addMarkers(TanluConstants.TAG, optionsList, true); + for (IMogoMarker iMogoMarker : iMogoMarkers) { + iMogoMarker.setInfoWindowAdapter(mDemoInfoWindowAdapter); + iMogoMarker.setOnMarkerClickListener(TanluCardViewFragment.this); + } + } + }); + + findViewById(R.id.demo_module_id_clear).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + TanluServiceHandler.getMarkerManager().removeMarkers(TanluConstants.TAG); + } + }); + + m2D3D.setOnClickListener(new View.OnClickListener() { + private EnumMapUI ui = EnumMapUI.NorthUP_2D; + + @Override + public void onClick(View v) { + TanluServiceHandler.getMapUIController().changeMapMode(ui = ui.next()); + m2D3D.setText(ui.toString()); + } + }); + + findViewById(R.id.demo_module_id_current).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + TanluServiceHandler.getMapUIController().moveToCenter(new MogoLatLng(mLocation.getLatitude(), mLocation.getLongitude())); + } + }); + + findViewById(R.id.demo_module_id_start_navi).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + TanluServiceHandler.getNavi().startNavi(!mNaviMode.isChecked()); + } + }); + + findViewById(R.id.demo_module_id_stop_navi).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + TanluServiceHandler.getNavi().stopNavi(); + } + }); + + findViewById(R.id.demo_module_id_traffic).setOnClickListener(new View.OnClickListener() { + + private boolean enable = true; + + @Override + public void onClick(View v) { + TanluServiceHandler.getMapUIController().setTrafficEnabled(enable = !enable); + } + }); + + findViewById(R.id.demo_module_id_zoom_in).setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + TanluServiceHandler.getMapUIController().changeZoom(true); + } + }); + + findViewById(R.id.demo_module_id_zoom_out).setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + TanluServiceHandler.getMapUIController().changeZoom(false); + } + }); + + findViewById(R.id.demo_module_id_day_light).setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + TanluServiceHandler.getMapUIController().changeMapMode(EnumMapUI.Type_Light); + } + }); + + findViewById(R.id.demo_module_id_day_night).setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + TanluServiceHandler.getMapUIController().changeMapMode(EnumMapUI.Type_Night); + } + }); + + findViewById(R.id.demo_module_id_display_overlay).setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + TanluServiceHandler.getMapUIController().displayOverview(); + } + }); + + findViewById(R.id.demo_module_id_reverse_lock).setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + TanluServiceHandler.getMapUIController().recoverLockMode(); + } + }); + + TanluServiceHandler.getLocationClient().addLocationListener(new IMogoLocationListener() { + @Override + public void onLocationChanged(MogoLocation location) { + mLocation = location; + Logger.d(TAG, "demo模块定位,定位间隔4s"); + } + }); + } + + @Override + public void onActivityCreated(@Nullable Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + getViewLifecycleOwner().getLifecycle().addObserver(mPresenter); + } + + @Override + public boolean onMarkerClicked(IMogoMarker marker) { +// if ( mLastClickedMarker != null ) { +// mLastClickedMarker.setIcon( this.mMarkerIcon ); +// } +// marker.setIcon( mClickedMarkerIcon ); +// mLastClickedMarker = marker; + +// marker.showInfoWindow(); + return true; + } + + @NonNull + @Override + protected Presenter createPresenter() { + return new Presenter(this) { + }; + } + + @Override + public void onPerform() { + Logger.d(TAG, "卡片2有效"); + } + + @Override + public void onDisable() { + Logger.d(TAG, "卡片2无效"); + } + + + @Override + public void onMapLoaded() { + Logger.d(TAG, "地图加载事件"); + } + + @Override + public void onTouch(MotionEvent motionEvent) { +// Logger.d( TAG, "地图触摸事件" ); + } + + @Override + public void onPOIClick(MogoPoi poi) { + if (poi != null) { + TipToast.shortTip(poi.getName()); + } + TanluServiceHandler.getPoiSearch().searchPOIIdAsyn(poi.getPoiId()); + } + + @Override + public void onPoiSearched(MogoPoiResult result, int errorCode) { + + } + + private IMogoMarker mPoiMarker; + + @Override + public void onPoiItemSearched(MogoPoiItem item, int errorCode) { + if (item == null) { + return; + } + if (mPoiMarker != null) { + mPoiMarker.destroy(); + } + mPoiMarker = TanluServiceHandler.getMarkerManager().addMarker(TanluConstants.TAG, new MogoMarkerOptions() + .longitude(item.getPoint().lng) + .latitude(item.getPoint().lat) + .icon(mMarkerIcon)); + if (mPoiMarker != null) { + mPoiMarker.setInfoWindowAdapter(mDemoInfoWindowAdapter); + mPoiMarker.setObject(item); + mPoiMarker.showInfoWindow(); + } + } + + @Override + public void onLocationChanged(MogoLocation location) { + mLocation = location; + Logger.i(TAG, "接受到的地图模块定位信息"); + if (mLocInfo != null) { + if (location.getErrCode() == 0) { + mLocInfo.setText("当前位置:" + location.getAddress()); + } else { + mLocInfo.setText(location.getErrInfo()); + } + } + } + + @Override + public void onMapClick(MogoLatLng latLng) { + + } + + @Override + public void onLockMap(boolean isLock) { + + } + + @Override + public void onMapModeChanged(EnumMapUI ui) { + Logger.d(TAG, ui.name()); + } + + @Override + public void onDestroyView() { + Logger.w(TAG, "onDestroyView position=" + position); + super.onDestroyView(); + getViewLifecycleOwner().getLifecycle().removeObserver(mPresenter); + TanluServiceHandler.getLocationClient().removeLocationListener(this); + if (mLastClickedMarker != null) { + mLastClickedMarker.destroy(); + mLastClickedMarker = null; + } + } + +} diff --git a/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluCardViewProvider.java b/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluCardViewProvider.java new file mode 100644 index 0000000000..90f6ed286a --- /dev/null +++ b/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluCardViewProvider.java @@ -0,0 +1,79 @@ +package com.zhidao.tanlu; + +import android.content.Context; +import android.os.Bundle; +import android.view.View; + +import androidx.fragment.app.Fragment; + +import com.alibaba.android.arouter.facade.annotation.Route; +import com.mogo.map.listener.IMogoMapListener; +import com.mogo.map.location.IMogoLocationListener; +import com.mogo.map.navi.IMogoNaviListener; +import com.mogo.service.module.IMogoModuleLifecycle; +import com.mogo.service.module.IMogoModuleProvider; +import com.mogo.utils.logger.Logger; + +/** + * @author congtaowang + * @since 2019-12-24 + *

+ * 描述 + */ +@Route( path = TanluConstants.TAG ) +public class TanluCardViewProvider implements IMogoModuleProvider { + + private static final String TAG = "TanluCardViewProvider"; + + private TanluCardViewFragment fragment; + + @Override + public Fragment createFragment( Context context, Bundle data ) { + fragment = new TanluCardViewFragment(); + fragment.setArguments( data ); + Logger.i( TAG, "createFragment" ); + return fragment; + } + + @Override + public void init( Context context ) { + TanluServiceHandler.init( context ); + } + + @Override + public String getModuleName() { + return TanluConstants.TAG; + } + + @Override + public IMogoModuleLifecycle getCardLifecycle() { + return fragment; + } + + @Override + public View createView( Context context ) { + // don't + return null; + } + + @Override + public IMogoMapListener getMapListener() { + return fragment; + } + + @Override + public int getType() { + return IMogoModuleProvider.TYPE_FRAGMENT; + } + + @Override + public IMogoNaviListener getNaviListener() { + return null; + } + + @Override + public IMogoLocationListener getLocationListener() { + return fragment; + } + +} diff --git a/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluConstants.java b/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluConstants.java new file mode 100644 index 0000000000..089a565812 --- /dev/null +++ b/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluConstants.java @@ -0,0 +1,12 @@ +package com.zhidao.tanlu; + +/** + * @author congtaowang + * @since 2019-12-24 + *

+ * 描述 + */ +public class TanluConstants { + + public static final String TAG = "/tanlu/ui"; +} diff --git a/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluInfoWindowAdapter.java b/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluInfoWindowAdapter.java new file mode 100644 index 0000000000..7d4fae8fb5 --- /dev/null +++ b/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluInfoWindowAdapter.java @@ -0,0 +1,131 @@ +package com.zhidao.tanlu; + +import android.content.Context; +import android.graphics.Bitmap; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; + +import com.mogo.map.marker.IMogoInfoWindowAdapter; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.map.marker.MogoMarkerOptions; +import com.mogo.map.navi.IMogoNavi; +import com.mogo.map.navi.MogoNaviConfig; +import com.mogo.map.search.geo.MogoPoiItem; +import com.mogo.service.imageloader.IMogoImageLoaderListener; +import com.mogo.service.imageloader.IMogoImageloader; +import com.mogo.service.imageloader.MogoImageView; +import com.mogo.utils.WindowUtils; +import com.mogo.utils.logger.Logger; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * @author congtaowang + * @since 2019-12-24 + *

+ * 描述 + */ +public class TanluInfoWindowAdapter implements IMogoInfoWindowAdapter { + + private static final String TAG = "DemoInfoWindowAdapter"; + + private Context mContext; + private IMogoNavi mNavi; + private IMogoImageloader mImageloader; + + public TanluInfoWindowAdapter(Context mContext, IMogoNavi mNavi, IMogoImageloader iMogoImageloader ) { + this.mContext = mContext; + this.mNavi = mNavi; + this.mImageloader = iMogoImageloader; + } + + @Override + public View getInfoWindow( IMogoMarker marker ) { + if ( marker.getObject() instanceof MogoPoiItem ) { + View view = LayoutInflater.from( mContext ).inflate( R.layout.tanlu_module_poi_info_window, null ); + renderPoiVew( view, marker, ( ( MogoPoiItem ) marker.getObject() ) ); + return view; + } else { + View view = LayoutInflater.from( mContext ).inflate( R.layout.tanlu_module_info_window, null ); + renderView( view, marker ); + return view; + } + + } + + private void renderView( View view, final IMogoMarker marker ) { + final TextView time = view.findViewById( R.id.demo_module_id_iw_time ); + Button refresh = view.findViewById( R.id.demo_module_id_iw_refresh ); + time.setText( new SimpleDateFormat( "yyyyMMdd HHMMSS" ).format( new Date() ) ); + refresh.setOnClickListener( new View.OnClickListener() { + @Override + public void onClick( View v ) { + marker.showInfoWindow(); + } + } ); + Button navi2 = view.findViewById( R.id.demo_module_id_iw_navito ); + navi2.setOnClickListener( new View.OnClickListener() { + @Override + public void onClick( View v ) { + if ( mNavi != null ) { + mNavi.naviTo( marker.getPosition(), new MogoNaviConfig() ); + } + } + } ); + Button stopNavi = view.findViewById( R.id.demo_module_id_iw_navi_stop ); + stopNavi.setOnClickListener( new View.OnClickListener() { + @Override + public void onClick( View v ) { + if ( mNavi != null ) { + mNavi.stopNavi(); + } + } + } ); + } + + private void renderPoiVew( View view, final IMogoMarker marker, MogoPoiItem item ) { + final TextView time = view.findViewById( R.id.demo_module_id_iw_poi_title ); + time.setText( item.getTitle() ); + Button navi2 = view.findViewById( R.id.demo_module_id_iw_poi_navito ); + navi2.setOnClickListener( new View.OnClickListener() { + @Override + public void onClick( View v ) { + if ( mNavi != null ) { + mNavi.naviTo( marker.getPosition(), new MogoNaviConfig() ); + } + marker.hideInfoWindow(); + marker.remove(); + } + } ); + } + + public View getMarkerView( final MogoMarkerOptions options ) { + final View view = LayoutInflater.from( mContext ).inflate( R.layout.tanlu_module_bubble_marker, null ); + final MogoImageView icon = view.findViewById( R.id.icon ); + mImageloader.displayImage( "http://imgnews.gmw.cn/attachement/jpg/site2/20191229/00d86176ed0b1f71f4580f.jpg", icon, WindowUtils.dip2px( mContext, 50 ), WindowUtils.dip2px( mContext, 50 ), + new IMogoImageLoaderListener() { + @Override + public void onStart() { + + } + + @Override + public void onCompleted( Bitmap bitmap ) { + // 刷新图标 + Logger.d( TAG, "loaded." ); + options.icon( view ); + options.notifyObservers(); + } + + @Override + public void onFailure( Exception e ) { + + } + } ); + return view; + } +} + diff --git a/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluServiceHandler.java b/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluServiceHandler.java new file mode 100644 index 0000000000..b47e0f9fba --- /dev/null +++ b/demo/tanlu-module/src/main/java/com/zhidao/tanlu/TanluServiceHandler.java @@ -0,0 +1,70 @@ +package com.zhidao.tanlu; + +import android.content.Context; + +import com.alibaba.android.arouter.launcher.ARouter; +import com.mogo.map.location.IMogoLocationClient; +import com.mogo.map.marker.IMogoMarkerManager; +import com.mogo.map.navi.IMogoNavi; +import com.mogo.map.search.poisearch.IMogoPoiSearch; +import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery; +import com.mogo.map.uicontroller.IMogoMapUIController; +import com.mogo.service.MogoServicePaths; +import com.mogo.service.imageloader.IMogoImageloader; +import com.mogo.service.map.IMogoMapService; + +/** + * @author congtaowang + * @since 2019-12-30 + *

+ * 持有服务接口实例 + */ +public class TanluServiceHandler { + + private static IMogoMapService mMapService; + private static IMogoPoiSearch mPoiSearch; + private static IMogoLocationClient mLocationClient; + private static IMogoMarkerManager mMarkerManager; + private static IMogoNavi mNavi; + private static IMogoMapUIController mMapUIController; + private static IMogoImageloader mImageloader; + + public static void init( Context context ) { + mMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( context ); + mMapService = ( IMogoMapService ) ARouter.getInstance().build( MogoServicePaths.PATH_SERVICES_MAP ).navigation( context ); + mImageloader = ( IMogoImageloader ) ARouter.getInstance().build( MogoServicePaths.PATH_UTILS_IMAGE_LOADER ).navigation( context ); + mPoiSearch = mMapService.getPoiSearch( context, new MogoPoiSearchQuery() ); + mLocationClient = mMapService.getLocationClient( context ); + mMarkerManager = mMapService.getMarkerManager( context ); + mNavi = mMapService.getNavi( context ); + mMapUIController = mMapService.getMapUIController(); + } + + public static IMogoMapService getMapService() { + return mMapService; + } + + public static IMogoPoiSearch getPoiSearch() { + return mPoiSearch; + } + + public static IMogoLocationClient getLocationClient() { + return mLocationClient; + } + + public static IMogoMarkerManager getMarkerManager() { + return mMarkerManager; + } + + public static IMogoNavi getNavi() { + return mNavi; + } + + public static IMogoMapUIController getMapUIController() { + return mMapUIController; + } + + public static IMogoImageloader getImageloader() { + return mImageloader; + } +} diff --git a/demo/tanlu-module/src/main/res/layout/tanlu_module_bubble_marker.xml b/demo/tanlu-module/src/main/res/layout/tanlu_module_bubble_marker.xml new file mode 100644 index 0000000000..a062cf73d1 --- /dev/null +++ b/demo/tanlu-module/src/main/res/layout/tanlu_module_bubble_marker.xml @@ -0,0 +1,23 @@ + + + + + + + \ No newline at end of file diff --git a/demo/tanlu-module/src/main/res/layout/tanlu_module_card_view.xml b/demo/tanlu-module/src/main/res/layout/tanlu_module_card_view.xml new file mode 100644 index 0000000000..34723f1bc6 --- /dev/null +++ b/demo/tanlu-module/src/main/res/layout/tanlu_module_card_view.xml @@ -0,0 +1,157 @@ + + + + + + + +