[2.13.0-arch-opt] reduce unuse logic and remove notice to biz
This commit is contained in:
1
core/function-impl/mogo-core-function-biz/.gitignore
vendored
Normal file
1
core/function-impl/mogo-core-function-biz/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
68
core/function-impl/mogo-core-function-biz/build.gradle
Normal file
68
core/function-impl/mogo-core-function-biz/build.gradle
Normal file
@@ -0,0 +1,68 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-android-extensions'
|
||||
id 'kotlin-kapt'
|
||||
id 'com.alibaba.arouter'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
|
||||
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'
|
||||
//ARouter apt 参数
|
||||
kapt {
|
||||
useBuildCache = false
|
||||
arguments {
|
||||
arg("AROUTER_MODULE_NAME", project.getName())
|
||||
}
|
||||
}
|
||||
|
||||
javaCompileOptions{
|
||||
annotationProcessorOptions{
|
||||
arguments = ["room.schemaLocation":"$projectDir/schemas".toString()]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
|
||||
implementation project(':foudations:mogo-commons')
|
||||
implementation project(':core:mogo-core-data')
|
||||
implementation project(':core:mogo-core-utils')
|
||||
implementation project(':core:mogo-core-network')
|
||||
implementation project(':core:mogo-core-function-call')
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
@@ -0,0 +1,3 @@
|
||||
GROUP=com.mogo.eagle.core.function.impl
|
||||
POM_ARTIFACT_ID=biz
|
||||
VERSION_CODE=1
|
||||
21
core/function-impl/mogo-core-function-biz/proguard-rules.pro
vendored
Normal file
21
core/function-impl/mogo-core-function-biz/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.mogo.eagle.function.biz.push;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.eagle.core.function.api.notice.IMoGoNoticeProvider;
|
||||
import com.mogo.eagle.core.function.api.notice.NoticeNetCallBack;
|
||||
import com.mogo.eagle.function.biz.push.network.NoticeNetWorkManager;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 云公告公告
|
||||
* @since: 10/27/21
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_AI_NOTICE)
|
||||
public class NoticeProvider implements IMoGoNoticeProvider {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFunctionName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
NoticeSocketManager.getInstance().unRegisterSocketMessageListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
NoticeSocketManager.getInstance().registerSocketMessageListener(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void feedBackNoticeTraffic(String infoId, String sn, int accept) {
|
||||
NoticeNetWorkManager.getInstance().sendAccidentAcceptStatus(infoId, sn, accept);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestAccidentInfo(String infoId, String sn, NoticeNetCallBack callBack) {
|
||||
NoticeNetWorkManager.getInstance().requestAccidentInfo(infoId, sn, callBack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.mogo.eagle.function.biz.push;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_NOTICE;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager;
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxBean;
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType;
|
||||
import com.mogo.eagle.core.data.msgbox.NoticeFrCloudMsg;
|
||||
import com.mogo.eagle.core.data.notice.NoticeNormalData;
|
||||
import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData;
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.aicloud.services.socket.IMogoOnMessageListener;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 云公告注册、反注册
|
||||
* @since: 10/27/21
|
||||
*/
|
||||
class NoticeSocketManager {
|
||||
private String TAG = "AINotice";
|
||||
private static NoticeSocketManager mNoticeSocketManager;
|
||||
private Context mContext;
|
||||
|
||||
public static synchronized NoticeSocketManager getInstance() {
|
||||
synchronized (NoticeSocketManager.class) {
|
||||
if (mNoticeSocketManager == null) {
|
||||
mNoticeSocketManager = new NoticeSocketManager();
|
||||
}
|
||||
}
|
||||
return mNoticeSocketManager;
|
||||
}
|
||||
|
||||
public void registerSocketMessageListener(Context context) {
|
||||
mContext = context;
|
||||
MogoAiCloudSocketManager.getInstance(context).
|
||||
registerOnMessageListener(301001, mTrafficNoticeListener);
|
||||
MogoAiCloudSocketManager.getInstance(context).
|
||||
registerOnMessageListener(100, mNormalNoticeListener);
|
||||
}
|
||||
|
||||
public void unRegisterSocketMessageListener() {
|
||||
MogoAiCloudSocketManager.getInstance(mContext).
|
||||
unregisterOnMessageListener(301001, mTrafficNoticeListener);
|
||||
MogoAiCloudSocketManager.getInstance(mContext).
|
||||
unregisterOnMessageListener(100, mNormalNoticeListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通云公告
|
||||
*/
|
||||
private final IMogoOnMessageListener<NoticeNormalData> mNormalNoticeListener = new IMogoOnMessageListener<NoticeNormalData>() {
|
||||
@Override
|
||||
public Class<NoticeNormalData> target() {
|
||||
return NoticeNormalData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(NoticeNormalData obj) {
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_NOTICE + TAG, "100-- 普通公告数据:" + GsonUtil.jsonFromObject(obj));
|
||||
NoticeFrCloudMsg noticeFromCloudMsg = new NoticeFrCloudMsg(obj, null, 0);
|
||||
CallerMsgBoxManager.INSTANCE.saveMsgBox(new MsgBoxBean(MsgBoxType.NOTICE, noticeFromCloudMsg));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 交警类型公告弹窗
|
||||
*/
|
||||
private final IMogoOnMessageListener<NoticeTrafficStylePushData> mTrafficNoticeListener = new IMogoOnMessageListener<NoticeTrafficStylePushData>() {
|
||||
|
||||
@Override
|
||||
public Class<NoticeTrafficStylePushData> target() {
|
||||
return NoticeTrafficStylePushData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(NoticeTrafficStylePushData obj) {
|
||||
if (obj == null) {
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_NOTICE + TAG, "301001-- 交警类型公告数据:" + GsonUtil.jsonFromObject(obj));
|
||||
NoticeFrCloudMsg noticeFromCloudMsg = new NoticeFrCloudMsg(null, obj, 1);
|
||||
CallerMsgBoxManager.INSTANCE.saveMsgBox(new MsgBoxBean(MsgBoxType.NOTICE, noticeFromCloudMsg));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.mogo.eagle.function.biz.push.network;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.data.notice.NoticeNormalDetail;
|
||||
import com.mogo.eagle.core.data.notice.NoticeTrafficStyleInfo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Headers;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 云公告相关的短链请求接口定义
|
||||
* @since: 10/28/21
|
||||
*/
|
||||
public interface NoticeApiService {
|
||||
/**
|
||||
* 获取道路事故详情
|
||||
*
|
||||
* @param requestBody 请求体(infoId 交警任务id)
|
||||
* @return {@link NoticeTrafficStyleInfo}
|
||||
*/
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@POST("/deva/accidentInfoManage/queryMyAccidentHandleInfo/server/v1")
|
||||
Observable<NoticeTrafficStyleInfo> getAccidentInfo(@Body RequestBody requestBody);
|
||||
|
||||
/**
|
||||
* 反馈对交警事故的操作
|
||||
*
|
||||
* @param accidentParameters 请求数据(infoID事故ID;sn;status接受状态 0否 1是)
|
||||
* @return {@link BaseData}
|
||||
*/
|
||||
@GET("/deva/accidentInfoManage/policeUpdateTroubleStatus")
|
||||
Observable<BaseData> sendAcceptStatus(@QueryMap Map<String, String> accidentParameters);
|
||||
|
||||
/**
|
||||
* 获取普通公告详情
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@GET("/deva/pc/pathAndPoi/getAnnouncementByDbId")
|
||||
Observable<NoticeNormalDetail> getNoticeDetail(@QueryMap Map<String, String> param);
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package com.mogo.eagle.function.biz.push.network;
|
||||
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import com.mogo.cloud.network.NetConstants;
|
||||
import com.mogo.cloud.network.RetrofitFactory;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
import com.mogo.eagle.core.data.notice.NoticeNormalDetail;
|
||||
import com.mogo.eagle.core.data.notice.NoticeTrafficStyleInfo;
|
||||
|
||||
import com.mogo.eagle.core.function.api.notice.NoticeNetCallBack;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 云公告网络请求类
|
||||
* @since: 10/28/21
|
||||
*/
|
||||
public class NoticeNetWorkManager {
|
||||
private static volatile NoticeNetWorkManager requestNoticeManager;
|
||||
private final NoticeApiService mNoticeApiService;
|
||||
|
||||
private NoticeNetWorkManager() {
|
||||
mNoticeApiService = RetrofitFactory.INSTANCE.getInstance(NetConstants.DEVA_HOST)
|
||||
.create(NoticeApiService.class);
|
||||
}
|
||||
|
||||
public static NoticeNetWorkManager getInstance() {
|
||||
if (requestNoticeManager == null) {
|
||||
synchronized (NoticeNetWorkManager.class) {
|
||||
if (requestNoticeManager == null) {
|
||||
requestNoticeManager = new NoticeNetWorkManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return requestNoticeManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取事故详细信息
|
||||
*
|
||||
* @param infoId 事故id
|
||||
* @param callBack 回调
|
||||
*/
|
||||
public void requestAccidentInfo(String infoId, String sn,NoticeNetCallBack callBack) {
|
||||
|
||||
NoticeRequest request = new NoticeRequest(infoId);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"),
|
||||
GsonUtil.jsonFromObject(request));
|
||||
mNoticeApiService.getAccidentInfo(requestBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<NoticeTrafficStyleInfo>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull NoticeTrafficStyleInfo noticeTrafficStyleInfo) {
|
||||
if (noticeTrafficStyleInfo.getResult().getAccidentInfo() != null) {
|
||||
callBack.callBackWithResult(noticeTrafficStyleInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 反馈交警是否接受事故任务
|
||||
*
|
||||
* @param infoId 事故id
|
||||
* @param sn
|
||||
* @param status 是否接受 0否 1是
|
||||
*/
|
||||
public void sendAccidentAcceptStatus(String infoId, String sn, int status) {
|
||||
Map<String, String> map = new ArrayMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("infoId", infoId);
|
||||
map.put("status", String.valueOf(status));
|
||||
mNoticeApiService.sendAcceptStatus(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseData>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseData baseData) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取普通公告的详情
|
||||
*
|
||||
* @param dbId
|
||||
*/
|
||||
public void getNoticeDetail(String dbId) {
|
||||
String sn = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("infoId", dbId);
|
||||
mNoticeApiService.getNoticeDetail(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<NoticeNormalDetail>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull NoticeNormalDetail noticeNormalDetail) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mogo.eagle.function.biz.push.network;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 描述
|
||||
* @since: 11/15/21
|
||||
*/
|
||||
public class NoticeRequest {
|
||||
private String infoId;
|
||||
|
||||
public NoticeRequest(String infoId) {
|
||||
this.infoId = infoId;
|
||||
}
|
||||
|
||||
public String getInfoId() {
|
||||
return infoId;
|
||||
}
|
||||
|
||||
public void setInfoId(String infoId) {
|
||||
this.infoId = infoId;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user