增加room模块
This commit is contained in:
118
config.gradle
118
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"
|
||||
|
||||
]
|
||||
}
|
||||
1
modules/mogo-module-navi/.gitignore
vendored
Normal file
1
modules/mogo-module-navi/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
42
modules/mogo-module-navi/build.gradle
Normal file
42
modules/mogo-module-navi/build.gradle
Normal file
@@ -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
|
||||
}
|
||||
0
modules/mogo-module-navi/consumer-rules.pro
Normal file
0
modules/mogo-module-navi/consumer-rules.pro
Normal file
21
modules/mogo-module-navi/proguard-rules.pro
vendored
Normal file
21
modules/mogo-module-navi/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
2
modules/mogo-module-navi/src/main/AndroidManifest.xml
Normal file
2
modules/mogo-module-navi/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.module.navi" />
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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<Long> insert(POIInfo... poiInfos);
|
||||
|
||||
/**
|
||||
* 获取地址列表
|
||||
* @return
|
||||
*/
|
||||
@Query("SELECT * from poiinfo")
|
||||
Flowable<List<POIInfo>> load();
|
||||
}
|
||||
3
modules/mogo-module-navi/src/main/res/values/strings.xml
Normal file
3
modules/mogo-module-navi/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">mogo-module-navi</string>
|
||||
</resources>
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user