添加探路api接口实现

This commit is contained in:
tongchenfei
2020-08-10 14:39:15 +08:00
parent ee53d50cdb
commit ec50a12a6c
23 changed files with 207 additions and 23 deletions

1
.idea/gradle.xml generated
View File

@@ -21,6 +21,7 @@
<option value="$PROJECT_DIR$/libraries/map-autonavi" />
<option value="$PROJECT_DIR$/libraries/mogo-map" />
<option value="$PROJECT_DIR$/libraries/mogo-map-api" />
<option value="$PROJECT_DIR$/libraries/mogo-tanlu-api" />
<option value="$PROJECT_DIR$/libraries/tanlulib" />
<option value="$PROJECT_DIR$/main-extensions" />
<option value="$PROJECT_DIR$/main-extensions/mogo-module-main-independent" />

View File

@@ -274,6 +274,8 @@ dependencies {
implementation rootProject.ext.dependencies.moduletanlu, {
exclude group: 'com.mogo.module', module: 'module-share'
}
implementation rootProject.ext.dependencies.moduletanluapi
} else {
launcherImplementation project(':main-extensions:mogo-module-main-launcher')
independentImplementation project(':main-extensions:mogo-module-main-independent')
@@ -288,6 +290,7 @@ dependencies {
implementation project(':modules:mogo-module-tanlu'), {
exclude group: 'com.mogo.module', module: 'module-share'
}
implementation project(':libraries:mogo-tanlu-api')
}
apply from: "./functions/baseservices.gradle"

View File

@@ -30,6 +30,7 @@ import com.mogo.utils.logger.LogLevel;
import com.mogo.utils.logger.Logger;
import com.zhidao.boot.persistent.lib.PersistentManager;
import com.zhidao.mogo.module.left.panel.LeftPanelConst;
import com.zhidao.mogo.tanlu.api.TanluApiConst;
/**
* @author congtaowang
@@ -63,6 +64,8 @@ public class MogoApplication extends AbsMogoApplication {
if(DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_BYD){
MogoModulePaths.addModule( new MogoModule( CallChatConstant.PROVIDER, CallChatConstant.MODULE_NAME ) );
}
MogoModulePaths.addModule(new MogoModule(TanluApiConst.MODULE_PATH,
TanluApiConst.MODULE_NAME));
MogoModulePaths.addModule( new MogoModule( TanluConstants.TAG, TanluConstants.MODEL_NAME ) );
MogoModulePaths.addModule( new MogoModule( MogoServicePaths.PATH_SHARE, "ShareControl" ) );

View File

@@ -82,6 +82,7 @@ targetSdkVersion : 22,
// modules
moduletanlu : "com.mogo.module:module-tanlu:${MOGO_MODULE_TANLU_VERSION}",
moduletanluapi : "com.mogo.module:module-tanlu-api:${MOGO_TANLU_API_VERSION}",
moduleshare : "com.mogo.module:module-share:${MOGO_MODULE_SHARE_VERSION}",
mogocommons : "com.mogo.commons:mogo-commons:${MOGO_COMMONS_VERSION}",
mogoutils : "com.mogo.commons:mogo-utils:${MOGO_UTILS_VERSION}",

View File

@@ -82,6 +82,8 @@ MOGO_MODULE_PUSH_NOOP_VERSION=1.1.5.6
MOGO_MODULE_AD_CARD_VERSION=1.0.1
# 探路上报和分享模块
TANLULIB_VERSION=1.3.1.24
MOGO_TANLU_API_VERSION = 1.0.0-SNAPSHOT
MOGO_MODULE_EVENT_PANEL_VERSION = 1.0.0-SNAPSHOT
MOGO_MODULE_EVENT_PANEL_NOOP_VERSION = 1.0.0-SNAPSHOT
#左侧面板模块

1
libraries/mogo-tanlu-api/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,52 @@
apply plugin: 'com.android.library'
apply plugin: 'com.alibaba.arouter'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
// buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode Integer.valueOf(VERSION_CODE)
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
javaCompileOptions {
annotationProcessorOptions {
arguments = [AROUTER_MODULE_NAME: project.getName()]
}
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
if (Boolean.valueOf(RELEASE)) {
compileOnly rootProject.ext.dependencies.modulecommon
implementation rootProject.ext.dependencies.tanluupload
} else {
compileOnly project(':modules:mogo-module-common')
implementation project(':libraries:tanlulib')
}
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.module
POM_ARTIFACT_ID=module-tanlu-api
VERSION_CODE=1

View 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

View File

@@ -0,0 +1,26 @@
package com.zhidao.mogo.tanlu.api;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.zhidao.mogo.tanlu.api.test", appContext.getPackageName());
}
}

View File

@@ -0,0 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zhidao.mogo.tanlu.api">
/
</manifest>

View File

@@ -0,0 +1,45 @@
package com.zhidao.mogo.tanlu.api;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.service.tanlu.IMogoTanluProvider;
import com.mogo.utils.logger.Logger;
import com.zhidao.roadcondition.service.MainService;
import static com.zhidao.mogo.tanlu.api.TanluApiConst.MODULE_NAME;
import static com.zhidao.mogo.tanlu.api.TanluApiConst.MODULE_PATH;
/**
* 探路api
*
* @author tongchenfei
*/
@Route(path = MODULE_PATH)
public class MogoTanluApiProvider implements IMogoTanluProvider {
private Context context;
/**
* 上传情报
*
* @param type 情报类型
*/
@Override
public void uploadRoadCondition(String type) {
Logger.d(MODULE_NAME, "uploadRoadCondition: " + type);
MainService.Companion.launchService(context, type);
}
/**
* 开启探路业务服务
*/
@Override
public void startTanluService() {
Logger.d(MODULE_NAME, "startTanluService");
MainService.Companion.launchService(context, "0");
}
@Override
public void init(Context context) {
this.context = context;
}
}

View File

@@ -0,0 +1,10 @@
package com.zhidao.mogo.tanlu.api;
/**
* 探路api相关常量
* @author tongchenfei
*/
public class TanluApiConst {
public static final String MODULE_NAME = "MogoTanluApi";
public static final String MODULE_PATH = "/tanlulib/api";
}

View File

@@ -0,0 +1,17 @@
package com.zhidao.mogo.tanlu.api;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

View File

@@ -51,7 +51,6 @@ dependencies {
api rootProject.ext.dependencies.moduleapps
api rootProject.ext.dependencies.moduleextensions
api rootProject.ext.dependencies.mogomoduleback
implementation rootProject.ext.dependencies.tanluupload
} else {
api project(":foudations:mogo-utils")
api project(":foudations:mogo-commons")
@@ -63,7 +62,6 @@ dependencies {
api project(':modules:mogo-module-apps')
api project(':modules:mogo-module-extensions')
api project(':modules:mogo-module-back')
implementation project(':libraries:tanlulib')
}
}

View File

@@ -4,22 +4,12 @@ import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
import com.alibaba.android.arouter.launcher.ARouter;
import com.mogo.commons.mvp.Presenter;
import com.mogo.module.main.constants.MainConstants;
import com.mogo.module.main.livedata.CardSwitchLiveData;
import com.mogo.service.MogoServicePaths;
import com.mogo.service.analytics.IMogoAnalytics;
import com.mogo.service.module.IMogoModuleProvider;
import com.zhidao.roadcondition.service.MainService;
import java.util.HashMap;
import java.util.Map;
/**
* @author congtaowang

View File

@@ -18,7 +18,6 @@ import com.mogo.service.IMogoServiceApis;
import com.mogo.service.MogoServicePaths;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
import com.zhidao.roadcondition.service.MainService;
public
/**
@@ -82,7 +81,7 @@ class MogoMainService extends Service implements IMogoLocationListener {
private void startTanluService() {
UiThreadHandler.postDelayed(() -> {
Logger.d(TAG, "startTanluService ---------- ");
MainService.Companion.launchService(getApplicationContext(), "0");
mServiceApis.getTanluApi().startTanluService();
}, 58_000L
);
}

View File

@@ -23,12 +23,13 @@ object UploadHelper {
AIAssist.getInstance(context).speakTTSVoice("感谢分享,正在上传")
}
Logger.d("UploadHelper", "upload ----> $type")
val intent = Intent()
intent.action = "com.zhidao.share.roadcondition.action"
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
intent.putExtra("type", type)
context.sendBroadcast(intent)
ServiceApisManager.serviceApis.tanluApi.uploadRoadCondition(type)
// val intent = Intent()
// intent.action = "com.zhidao.share.roadcondition.action"
// intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
// intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
// intent.putExtra("type", type)
// context.sendBroadcast(intent)
}
}
}

View File

@@ -234,8 +234,8 @@ public class MogoServicePaths {
public static final String PATH_LOG_LIB = "/loglib/api";
/**
* 探路相关
* 探路api
*/
@Deprecated
public static final String PATH_TANLU = "/tanlu/ui";
public static final String PATH_TANLU_API = "/tanlulib/api";
}

View File

@@ -51,4 +51,9 @@ public interface IMogoTanluProvider extends IProvider {
* @param type 情报类型
*/
void uploadRoadCondition(String type);
/**
* 开启探路业务服务
*/
void startTanluService();
}

View File

@@ -209,7 +209,7 @@ public class MogoServiceApis implements IMogoServiceApis {
@Override
public IMogoTanluProvider getTanluApi() {
return getApiInstance(IMogoTanluProvider.class, MogoServicePaths.PATH_TANLU);
return getApiInstance(IMogoTanluProvider.class, MogoServicePaths.PATH_TANLU_API);
}
private static < T extends IProvider > T getApiInstance(Class< T > clazz, String path ) {

View File

@@ -1,3 +1,4 @@
include ':libraries:mogo-tanlu-api'
include ':foudations:mogo-base-services-apk'
include ':foudations:mogo-base-services-sdk'
include ':modules:mogo-module-splash-noop'