add get navi infor
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.mogo.module.tanlu.callback;
|
||||
|
||||
import com.mogo.module.tanlu.model.NaviResult;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 导航沿途数据
|
||||
* @since 2020-01-09
|
||||
*/
|
||||
public interface NaviCallback {
|
||||
void onSuccess(NaviResult data);
|
||||
void onFail(String message, int code);
|
||||
}
|
||||
@@ -59,6 +59,7 @@ import com.mogo.module.share.ShareControl;
|
||||
import com.mogo.module.share.constant.ShareConstants;
|
||||
import com.mogo.module.tanlu.R;
|
||||
import com.mogo.module.tanlu.callback.AlongTheWayCallback;
|
||||
import com.mogo.module.tanlu.callback.NaviCallback;
|
||||
import com.mogo.module.tanlu.callback.RoadLineCallback;
|
||||
import com.mogo.module.tanlu.callback.UploadShareCallback;
|
||||
import com.mogo.module.tanlu.callback.VoiceSearchCallback;
|
||||
@@ -67,6 +68,7 @@ import com.mogo.module.tanlu.model.Center;
|
||||
import com.mogo.module.tanlu.model.Information;
|
||||
import com.mogo.module.tanlu.model.InformationAndLiveCarResult;
|
||||
import com.mogo.module.tanlu.model.Items;
|
||||
import com.mogo.module.tanlu.model.NaviResult;
|
||||
import com.mogo.module.tanlu.model.PathLineResult;
|
||||
import com.mogo.module.tanlu.model.TanluModelData;
|
||||
import com.mogo.module.tanlu.model.VoiceSearchResult;
|
||||
@@ -335,9 +337,10 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartNavi() { //开始导航,这期先不做
|
||||
// initModelData();
|
||||
// getNavigationLineData();
|
||||
public void onStartNavi() { //开始导航
|
||||
Log.d(TAG, "onStartNavi -------> ");
|
||||
initModelData();
|
||||
getNavigationData();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -954,23 +957,64 @@ public class TanluCardViewFragment extends MvpFragment<IView, Presenter<IView>>
|
||||
/**
|
||||
* 导航路线数据事件 TODO
|
||||
*/
|
||||
public void getNavigationLineData() {
|
||||
Double lat = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLatitude();
|
||||
Double lon = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLongitude();
|
||||
Logger.e(TAG, "getNavigationLineData lon = " + lon + ">>>>> lat= " + lat);
|
||||
mTanluModelData.getNavigationLineData(lon, lat, new AlongTheWayCallback() {
|
||||
public void getNavigationData() {
|
||||
// Double lat = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLatitude();
|
||||
// Double lon = TanluServiceHandler.getLocationClient().getLastKnowLocation().getLongitude();
|
||||
// Logger.e(TAG, "getNavigationLine lon = " + lon + ">>>>> lat= " + lat);
|
||||
// mTanluModelData.getNavigationLineData(lon, lat, new AlongTheWayCallback() {
|
||||
// @Override
|
||||
// public void onSuccess(InformationAndLiveCarResult data) {
|
||||
// //不做任何处理,直接出发推送,重新请求接口,划线
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFail(String message, int code) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
|
||||
mTanluModelData.getNaviInformation(new NaviCallback() {
|
||||
@Override
|
||||
public void onSuccess(InformationAndLiveCarResult data) {
|
||||
Logger.d(TAG, "getNavigationLineData onSuccess ");
|
||||
//不做任何处理,直接出发推送,重新请求接口,划线
|
||||
public void onSuccess(NaviResult data) {
|
||||
Log.d(TAG, "getNavigationData onSuccess ----->");
|
||||
List<Information> informationList = data.getResult().getInformations();
|
||||
//清除探路之前的数据
|
||||
mMarkerManager.removeMarkers(TanluConstants.MODEL_NAME);
|
||||
|
||||
//打点
|
||||
ArrayList<MogoMarkerOptions> optionList = new ArrayList<>();
|
||||
for (int i = 0; i < informationList.size(); i++) {
|
||||
//根据type确定添加的图片
|
||||
String trafficType = informationList.get(i).trafficInfoType;
|
||||
if (trafficType.equals("traffic_jam")) { //拥堵
|
||||
multiMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.tanlu_marker_block_up);
|
||||
} else if (trafficType.equals("car_checking")) { //查车
|
||||
multiMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.tanlu_marker_traffic_check);
|
||||
} else if (trafficType.equals("0")) {
|
||||
multiMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.tanlu_marker_block_up);
|
||||
} else if (trafficType.equals("traffic_control")) {
|
||||
multiMarkerIcon = BitmapFactory.decodeResource(getResources(), R.drawable.tanlu_marker_road_closure);
|
||||
}
|
||||
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.icon(multiMarkerIcon)
|
||||
.latitude(informationList.get(i).lat)
|
||||
.owner(TanluConstants.MODEL_NAME)
|
||||
.longitude(informationList.get(i).lon);
|
||||
|
||||
optionList.add(options);
|
||||
Log.d(TAG, "lat =" + informationList.get(i).lat + ">>>lon =" + informationList.get(i).lon);
|
||||
}
|
||||
Logger.d(TAG, "getNavigationData optionList.size() = " + optionList.size());
|
||||
mMarkerManager.addMarkers(TanluConstants.MODEL_NAME, optionList, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String message, int code) {
|
||||
Logger.e(TAG, "getNavigationLineData onFail message = " + message + ">>>code= " + code);
|
||||
|
||||
Log.d(TAG, "getNavigationData message = " + message + ">>>code =" + code);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ public class Information extends BaseData implements Parcelable {
|
||||
public int distance;
|
||||
public String nickName;
|
||||
public String headImgUrl;
|
||||
public String phone;
|
||||
public String trafficInfoType;
|
||||
|
||||
|
||||
@@ -43,6 +44,7 @@ public class Information extends BaseData implements Parcelable {
|
||||
dest.writeInt(this.distance);
|
||||
dest.writeString(this.nickName);
|
||||
dest.writeString(this.headImgUrl);
|
||||
dest.writeString(this.phone);
|
||||
dest.writeString(this.trafficInfoType);
|
||||
}
|
||||
|
||||
@@ -60,6 +62,7 @@ public class Information extends BaseData implements Parcelable {
|
||||
this.distance = in.readInt();
|
||||
this.nickName = in.readString();
|
||||
this.headImgUrl = in.readString();
|
||||
this.phone = in.readString();
|
||||
this.trafficInfoType = in.readString();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mogo.module.tanlu.model;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 导航沿途数据
|
||||
* @since 2020-02-03
|
||||
*/
|
||||
public class NaviResult extends BaseData {
|
||||
|
||||
private Result result;
|
||||
|
||||
public Result getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(Result result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public static class Result {
|
||||
private List<Information> informations;
|
||||
|
||||
public List<Information> getInformations() {
|
||||
return informations;
|
||||
}
|
||||
|
||||
public void setInformations(List<Information> informations) {
|
||||
this.informations = informations;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mogo.module.tanlu.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since 2020-02-03
|
||||
*/
|
||||
public class NaviRoadRequest {
|
||||
public List<Double> coordinates;
|
||||
public int limit;
|
||||
|
||||
public NaviRoadRequest(List<Double> coordinates, int limit) {
|
||||
this.coordinates = coordinates;
|
||||
this.limit = limit;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import com.mogo.commons.network.ParamsProvider;
|
||||
import com.mogo.commons.network.SubscribeImpl;
|
||||
import com.mogo.commons.network.Utils;
|
||||
import com.mogo.module.tanlu.callback.AlongTheWayCallback;
|
||||
import com.mogo.module.tanlu.callback.NaviCallback;
|
||||
import com.mogo.module.tanlu.callback.RoadLineCallback;
|
||||
import com.mogo.module.tanlu.callback.UploadShareCallback;
|
||||
import com.mogo.module.tanlu.callback.VoiceSearchCallback;
|
||||
@@ -175,7 +176,7 @@ public class TanluModelData {
|
||||
|
||||
|
||||
/**
|
||||
* 导航路线数据事件
|
||||
* 导航路线数据事件 TODO
|
||||
*/
|
||||
public void getNavigationLineData(Double lon, Double lat, final AlongTheWayCallback callback) {
|
||||
Gson gson = new Gson();
|
||||
@@ -221,7 +222,9 @@ public class TanluModelData {
|
||||
}
|
||||
|
||||
|
||||
//获取Location,如果没有location数据为空,则使用首次或者上次定位点,并且更新SP,需要抽取公共方法
|
||||
/**
|
||||
* 获取Location,如果没有location数据为空,则使用首次或者上次定位点,并且更新SP,需要抽取公共方法
|
||||
*/
|
||||
public NaviLatLngInfo getNaviInfo(Double lon, Double lat) {
|
||||
String naviInfo = SharedPrefsMgr.getInstance(mContext).getString(TanluConstants.NAVI_INFO);
|
||||
Log.d(TAG, " getNaviInfo naviInfo =" + naviInfo);
|
||||
@@ -283,5 +286,42 @@ public class TanluModelData {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导航沿途情报 TODO
|
||||
*/
|
||||
public void getNaviInformation(final NaviCallback callback) {
|
||||
Gson gson = new Gson();
|
||||
|
||||
final Map<String, Object> params = new ParamsProvider.Builder(mContext)
|
||||
.append("sn", Utils.getSn())
|
||||
// .append("data", uploadShareStr)
|
||||
.build();
|
||||
|
||||
mTanluApiService.getNaviInformation(params)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SubscribeImpl<NaviResult>(RequestOptions.create(mContext)) {
|
||||
@Override
|
||||
public void onSuccess(NaviResult o) {
|
||||
super.onSuccess(o);
|
||||
callback.onSuccess(o);
|
||||
Logger.d(TAG, "getNaviInformation onSuccess ------>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String message, int code) {
|
||||
super.onError(message, code);
|
||||
callback.onFail(message, code);
|
||||
Logger.e(TAG, "getNaviInformation onError message= " + message + ">>code =" + code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
super.onError(e);
|
||||
e.printStackTrace();
|
||||
Logger.d(TAG, "getNaviInformation onError ------> e= " + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.module.tanlu.net;
|
||||
|
||||
import com.mogo.commons.data.BaseData;
|
||||
import com.mogo.module.tanlu.model.InformationAndLiveCarResult;
|
||||
import com.mogo.module.tanlu.model.NaviResult;
|
||||
import com.mogo.module.tanlu.model.PathLineResult;
|
||||
import com.mogo.module.tanlu.model.VoiceSearchResult;
|
||||
|
||||
@@ -55,4 +56,12 @@ public interface TanluApiService {
|
||||
@POST("deva/car/poi/no/addNovelty/v1")
|
||||
Observable<BaseData> uploadCheckTrafficInfor(@FieldMap Map<String, Object> infoBody);
|
||||
|
||||
/**
|
||||
* 导航沿途情报
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("deva/car/search/no/searchInforationByCoordinates/v1")
|
||||
Observable<NaviResult> getNaviInformation(@FieldMap Map<String, Object> infoBody);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user