[add] 1.添加接口服务类 2.添加网络请求类 3.UI呈现类添加部分赋值内容
This commit is contained in:
@@ -10,7 +10,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
|
||||
import com.mogo.eagle.core.data.notice.NoticeInfo;
|
||||
import com.mogo.eagle.core.data.notice.NoticeTrafficInfo;
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ public class NoticeBannerView extends ConstraintLayout {
|
||||
}
|
||||
|
||||
//数据改变刷新UI
|
||||
public void pushBeanChanged(NoticeInfo info){
|
||||
public void pushBeanChanged(NoticeTrafficInfo info){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,15 +9,20 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.eagle.core.data.notice.NoticeValue;
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @description 事故详情(事故来源等)呈现
|
||||
* @since: 10/26/21
|
||||
*/
|
||||
class NoticeTrafficAdapter extends RecyclerView.Adapter {
|
||||
LayoutInflater mLayoutInflater;
|
||||
private List<NoticeValue> data = new ArrayList();
|
||||
|
||||
public NoticeTrafficAdapter(@NonNull Context context) {
|
||||
mLayoutInflater = LayoutInflater.from(context);
|
||||
@@ -34,7 +39,9 @@ class NoticeTrafficAdapter extends RecyclerView.Adapter {
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
|
||||
NoticeValue value = data.get(position);
|
||||
((TrafficInfoHolder) holder).keyText.setText(value.getKey());
|
||||
((TrafficInfoHolder) holder).valueText.setText(value.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,14 +41,14 @@ public class NoticeProvider implements IMoGoNoticeProvider {
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
NoticeSocketManager.getInstance().unRegisterSocketMessage();
|
||||
NoticeSocketManager.getInstance().unRegisterSocketMessageListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
Log.d(TAG, "init");
|
||||
mContext = context;
|
||||
NoticeSocketManager.getInstance().registerSocketMessage(context);
|
||||
NoticeSocketManager.getInstance().registerSocketMessageListener(context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ class NoticeSocketManager {
|
||||
private String TAG = "AINotice";
|
||||
private static NoticeSocketManager mNoticeSocketManager;
|
||||
private NoticeMessageListener mNoticeMessageListener;
|
||||
private static IMogoServiceApis mMoGoServiceApis;
|
||||
private Context mContext;
|
||||
|
||||
public static synchronized NoticeSocketManager getInstance() {
|
||||
@@ -29,23 +28,17 @@ class NoticeSocketManager {
|
||||
return mNoticeSocketManager;
|
||||
}
|
||||
|
||||
public void registerSocketMessage(Context context) {
|
||||
public void registerSocketMessageListener(Context context) {
|
||||
Log.d(TAG, "registerSocketMessage");
|
||||
mContext = context;
|
||||
mNoticeMessageListener = new NoticeMessageListener();
|
||||
if (mMoGoServiceApis == null) {
|
||||
mMoGoServiceApis = (IMogoServiceApis) ARouter.getInstance().build(com.mogo.eagle.core.data.constants.
|
||||
MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
|
||||
}
|
||||
mMoGoServiceApis.
|
||||
getSocketManagerApi(context).
|
||||
MogoApisHandler.getInstance().getApis().getSocketManagerApi(context).
|
||||
registerOnMessageListener(100, mNoticeMessageListener);
|
||||
}
|
||||
|
||||
public void unRegisterSocketMessage() {
|
||||
public void unRegisterSocketMessageListener() {
|
||||
if (mNoticeMessageListener != null) {
|
||||
mMoGoServiceApis
|
||||
.getSocketManagerApi(mContext).
|
||||
MogoApisHandler.getInstance().getApis().getSocketManagerApi(mContext).
|
||||
unregisterOnMessageListener(100, mNoticeMessageListener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.mogo.eagle.core.function.notice.network;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.FieldMap;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 云公告相关的短链请求接口定义
|
||||
* @since: 10/28/21
|
||||
*/
|
||||
public interface NoticeApiService {
|
||||
/**
|
||||
* 获取道路事故详情
|
||||
*
|
||||
* @param accidentParameters 请求数据(sn;infoId)
|
||||
* @return {@link BaseData}
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/deva/accidentInfoManage/queryMyAccidentHandleInfo/server/v1")
|
||||
Observable<BaseData> getAccidentInfo(@FieldMap Map<String, String> accidentParameters);
|
||||
|
||||
|
||||
/**
|
||||
* 获取道路事故详情
|
||||
*
|
||||
* @param accidentParameters 请求数据(infoID事故ID;sn;status接受状态 0否 1是)
|
||||
* @return {@link BaseData}
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/deva/accidentInfoManage/policeUpdateTroubleStatus")
|
||||
Observable<BaseData> sendAcceptStatus(@FieldMap Map<String, String> accidentParameters);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.mogo.eagle.core.function.notice.network;
|
||||
|
||||
import com.mogo.cloud.network.NetConstants;
|
||||
import com.mogo.cloud.network.RetrofitFactory;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.commons.data.BaseData;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 云公告网络请求类
|
||||
* @since: 10/28/21
|
||||
*/
|
||||
public class NoticeNetWorkManager {
|
||||
private String TAG = "AINotice";
|
||||
private static volatile NoticeNetWorkManager requestNoticeManager;
|
||||
private final NoticeApiService mNoticeApiService;
|
||||
|
||||
private NoticeNetWorkManager() {
|
||||
mNoticeApiService = RetrofitFactory.INSTANCE.getInstance(NetConstants.DEVA_HOST) //todo 涉及云公告
|
||||
.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 sn
|
||||
*/
|
||||
public void requestAccidentInfo(String infoId, String sn) {
|
||||
String snString = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("infoId", infoId);
|
||||
mNoticeApiService.getAccidentInfo(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 infoId 事故id
|
||||
* @param sn
|
||||
* @param status 是否接受 0否 1是
|
||||
*/
|
||||
public void sendAccidentAcceptStatus(String infoId, String sn, String status) {
|
||||
String snString = MoGoAiCloudClient.getInstance().getAiCloudClientConfig().getSn();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
map.put("infoId", infoId);
|
||||
map.put("status", 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() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user