busStationList) {
+ if (getActivity() == null) {
+ return;
+ }
+ getActivity().runOnUiThread(() -> {
+ if (busStationList == null) {
+ // todo 获取小巴数据失败
+ } else {
+ // todo 渲染小巴路线数据
+ stationList.clear();
+ stationList.addAll(busStationList);
+ for (int i = 0; i < stationList.size(); i++) {
+ OchBusStation station = stationList.get(i);
+ if (station.getIsCurrentSite() == OchBusPresenter.STATION_STATUS_LEAVING) {
+ tvNotice.setText("正在从 " + i + "站驶向" + (i + 1) + "站");
+ btnExecute.setVisibility(View.GONE);
+ break;
+ } else if (station.getIsCurrentSite() == OchBusPresenter.STATION_STATUS_STOPED) {
+ tvNotice.setText("车辆正停在" + i + "站");
+ btnExecute.setVisibility(View.VISIBLE);
+ if (i == stationList.size() - 1) {
+ btnExecute.setText("单程结束");
+ }else if(i == 0){
+ btnExecute.setText("准备出发");
+ }else{
+ btnExecute.setText("乘客已上车,准备出发");
+ }
+ break;
+ }
+ }
+ }
+ });
+ }
+
+ public void hideOchBus() {
+ groupOchBus.setVisibility(View.GONE);
+ }
+
+ private void queryStationListIfNecessary() {
+ if (stationList == null || stationList.isEmpty()) {
+ mPresenter.queryBusRoutes();
+ }
+ }
+}
diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/net/IOchBusApiService.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/net/IOchBusApiService.java
new file mode 100644
index 0000000000..4924a6bde8
--- /dev/null
+++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/net/IOchBusApiService.java
@@ -0,0 +1,41 @@
+package com.mogo.och.bus.net;
+
+import com.mogo.commons.data.BaseData;
+import com.mogo.och.bus.bean.OchBusRoutesResponse;
+
+import io.reactivex.Observable;
+import okhttp3.RequestBody;
+import retrofit2.http.Body;
+import retrofit2.http.Headers;
+import retrofit2.http.POST;
+
+/**
+ * 小巴车相关接口
+ *
+ * @author tongchenfei
+ */
+public interface IOchBusApiService {
+
+ /**
+ * 根据车机坐标获取所在区域全部站点信息
+ *
+ * wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=48970072
+ *
+ * @param requestBody 请求参数
+ * @return 接口返回数据
+ */
+ @Headers({"Content-Type:application/json;charset=UTF-8"})
+ @POST("/yycp-onlinecar-hailing/onlineCarHailing/site/querySiteByCoordinate/v1")
+ Observable querySiteByCoordinate(@Body RequestBody requestBody);
+
+
+ /**
+ * 公交车驶离车站时,通知服务端
+ * @param requestBody 请求参数 {"sn":"","siteId":"车站id"}
+ * @return 无返回值
+ */
+ @Headers({"Content-Type:application/json;charset=UTF-8"})
+ @POST("/yycp-onlinecar-hailing/onlineCarHailing/site/siteCrashCheck/v1")
+ Observable leaveStation(@Body RequestBody requestBody);
+
+}
diff --git a/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java
new file mode 100644
index 0000000000..e39bf77784
--- /dev/null
+++ b/OCH/mogo-och-bus/src/main/java/com/mogo/och/bus/presenter/OchBusPresenter.java
@@ -0,0 +1,188 @@
+package com.mogo.och.bus.presenter;
+
+import com.mogo.commons.data.BaseData;
+import com.mogo.commons.mvp.Presenter;
+import com.mogo.commons.network.SubscribeImpl;
+import com.mogo.commons.network.Utils;
+import com.mogo.map.location.MogoLocation;
+import com.mogo.module.common.MogoApisHandler;
+import com.mogo.module.common.constants.HostConst;
+import com.mogo.och.bus.bean.OchBusLeaveStationRequest;
+import com.mogo.och.bus.bean.OchBusRoutesRequest;
+import com.mogo.och.bus.bean.OchBusRoutesResponse;
+import com.mogo.och.bus.bean.OchBusStation;
+import com.mogo.och.bus.fragment.OchBusFragment;
+import com.mogo.och.bus.net.IOchBusApiService;
+import com.mogo.service.adas.IMogoAdasOCHCallback;
+import com.mogo.service.adas.RemoteControlAutoPilotParameters;
+import com.mogo.service.adas.entity.AdasOCHData;
+import com.mogo.utils.logger.Logger;
+import com.mogo.utils.network.RequestOptions;
+import com.mogo.utils.network.utils.GsonUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.schedulers.Schedulers;
+import okhttp3.MediaType;
+import okhttp3.RequestBody;
+
+/**
+ * 网约车小巴
+ *
+ * @author tongchenfei
+ */
+public class OchBusPresenter extends Presenter implements IMogoAdasOCHCallback {
+ private static final String TAG = "OchBusPresenter";
+ private static final int VEHICAL_TYPE = 10;
+
+ public static final int STATION_STATUS_IDLE = 0;
+ public static final int STATION_STATUS_STOPED = 1;
+ public static final int STATION_STATUS_LEAVING = 2;
+ public static final int STATION_STATUS_ARRIVING = 3;
+
+ public OchBusPresenter(OchBusFragment view) {
+ super(view);
+ MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasOCHCallback(this);
+ }
+
+ private final List stationList = new ArrayList<>();
+
+ private int currentStationIndex = 0;
+
+ public void queryBusRoutes() {
+ double lat = 0;
+ double lon = 0;
+ MogoLocation lastLocation = MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient(getContext()).getLastKnowLocation();
+ if (lastLocation != null) {
+ lat = lastLocation.getLatitude();
+ lon = lastLocation.getLongitude();
+ }
+ OchBusRoutesRequest request = new OchBusRoutesRequest(Utils.getSn(),lat, lon);
+ RequestBody requestBody = RequestBody.create(MediaType.get("application/json"), GsonUtil.jsonFromObject(request));
+ MogoApisHandler.getInstance().getApis().getNetworkApi()
+ .create(IOchBusApiService.class, HostConst.OCH_DOMAIN)
+ .querySiteByCoordinate(requestBody)
+ .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new SubscribeImpl(RequestOptions.create(getContext())) {
+
+ @Override
+ public void onSuccess(OchBusRoutesResponse o) {
+ super.onSuccess(o);
+ Logger.d(TAG, "获取到小巴路线数据: " + o);
+ if (mView != null && o.getResult() != null && o.getResult().getSite() != null) {
+ stationList.clear();
+ stationList.addAll(o.getResult().getSite());
+ refreshCurrentStation();
+ mView.refreshBusStations(stationList);
+ }
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ super.onError(e);
+ Logger.e(TAG, e, "获取小巴路线图失败");
+ if (mView != null) {
+ mView.refreshBusStations(null);
+ }
+ }
+
+ @Override
+ public void onError(String message, int code) {
+ super.onError(message, code);
+ Logger.e(TAG, "获取小巴路线失败 code: " + code + " msg: " + message);
+ if (mView != null) {
+ mView.refreshBusStations(null);
+ }
+ }
+ });
+ }
+
+ public void getStationListFromSocket(List stations) {
+ // 接收长连接消息好像没啥用
+// stationList.clear();
+// stationList.addAll(stations);
+// refreshCurrentStation();
+// if (mView != null) {
+// mView.refreshBusStationsInUiThread(stationList);
+// }
+ }
+
+ public void autoDriveToNextStation() {
+ if (currentStationIndex >= stationList.size() - 1) {
+ // 当前站是最后一站,结束当前行程
+ travelOver();
+ return;
+ }
+ OchBusStation currentStation = stationList.get(currentStationIndex);
+ OchBusStation nextStation = stationList.get(currentStationIndex + 1);
+ currentStation.setIsCurrentSite(STATION_STATUS_LEAVING);
+ nextStation.setIsCurrentSite(STATION_STATUS_ARRIVING);
+ RemoteControlAutoPilotParameters parameters = new RemoteControlAutoPilotParameters();
+ parameters.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat(currentStation.getLat(), currentStation.getLon());
+ parameters.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat(nextStation.getLat(), nextStation.getLon());
+ parameters.vehicleType = VEHICAL_TYPE;
+ MogoApisHandler.getInstance().getApis().getAdasControllerApi().aiCloudToAdasData(parameters);
+
+ RequestBody request = RequestBody.create(MediaType.get("application/json"), GsonUtil.jsonFromObject(new OchBusLeaveStationRequest(Utils.getSn(), currentStation.getSiteId())));
+ MogoApisHandler.getInstance().getApis().getNetworkApi()
+ .create(IOchBusApiService.class, HostConst.OCH_DOMAIN)
+ .leaveStation(request).subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new SubscribeImpl(RequestOptions.create(getContext())) {
+ @Override
+ public void onError(String message, int code) {
+ super.onError(message, code);
+ Logger.d(TAG, "leave station error: " + message);
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ super.onError(e);
+ Logger.e(TAG,e,"leave station exception");
+ }
+ });
+
+
+ if (mView != null) {
+ mView.refreshBusStations(stationList);
+ }
+ }
+
+ private void refreshCurrentStation() {
+ currentStationIndex = 0;
+ for (OchBusStation station : stationList) {
+ // 如果数据表发生更新,获取当前所在车站
+ if (station.getIsCurrentSite() == STATION_STATUS_STOPED || station.getIsCurrentSite() == STATION_STATUS_LEAVING) {
+ // 处于停靠或驶离时,是当前车站
+ break;
+ }
+ currentStationIndex++;
+ }
+ }
+
+ @Override
+ public void onArriveAt(AdasOCHData data) {
+ // 当前站改为IDLE,下一站改为STATION_STATUS_STOPED,currentStationIndex增加1
+ stationList.get(currentStationIndex++).setIsCurrentSite(STATION_STATUS_IDLE);
+ stationList.get(currentStationIndex).setIsCurrentSite(STATION_STATUS_STOPED);
+ if (mView != null) {
+ mView.refreshBusStations(stationList);
+ }
+ }
+
+ private void travelOver(){
+ if (currentStationIndex >= stationList.size()) {
+ Logger.e(TAG, "index out of station list");
+ return;
+ }
+ // 始发站改为Stoped,其他站改为Idle
+ stationList.get(currentStationIndex).setIsCurrentSite(STATION_STATUS_IDLE);
+ currentStationIndex = 0;
+ stationList.get(currentStationIndex).setIsCurrentSite(STATION_STATUS_STOPED);
+ if (mView != null) {
+ mView.refreshBusStations(stationList);
+ }
+ }
+}
diff --git a/OCH/mogo-och-bus/src/main/res/layout/fragment_och_bus.xml b/OCH/mogo-och-bus/src/main/res/layout/fragment_och_bus.xml
new file mode 100644
index 0000000000..7bc5f71ee0
--- /dev/null
+++ b/OCH/mogo-och-bus/src/main/res/layout/fragment_och_bus.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/foudations/httpdns-base/src/main/java/com/mogo/httpdns/IMogoHttpDns.java b/foudations/httpdns-base/src/main/java/com/mogo/httpdns/IMogoHttpDns.java
index 653a033f26..57ed0e65fc 100644
--- a/foudations/httpdns-base/src/main/java/com/mogo/httpdns/IMogoHttpDns.java
+++ b/foudations/httpdns-base/src/main/java/com/mogo/httpdns/IMogoHttpDns.java
@@ -66,6 +66,16 @@ public interface IMogoHttpDns extends IProvider {
@Keep
void getHttpDnsIp(String host, int type, boolean useCache, IHttpDnsCallback callback);
+ /**
+ * 同步进行dns解析,无需回调
+ * @param host
+ * @param type
+ * @param useCache
+ *
+ * @return ip:port
+ */
+ String syncGetHttpDns(String host, int type, boolean useCache);
+
// /**
// * 监听 ttl 回调
// *
diff --git a/foudations/httpdns-mogo/src/main/java/com/mogo/httpdns/mogo/MogoHttpDns.java b/foudations/httpdns-mogo/src/main/java/com/mogo/httpdns/mogo/MogoHttpDns.java
index 50f532fed1..7cb4fcf508 100644
--- a/foudations/httpdns-mogo/src/main/java/com/mogo/httpdns/mogo/MogoHttpDns.java
+++ b/foudations/httpdns-mogo/src/main/java/com/mogo/httpdns/mogo/MogoHttpDns.java
@@ -49,6 +49,22 @@ public class MogoHttpDns implements IMogoHttpDns, HttpDns, OnAddressChangedListe
return httpDnsHelper.getHttpDnsCachedAddress(type, host);
}
+ @Override
+ public String syncGetHttpDns(String host, int type, boolean useCache) {
+ Logger.d("MogoHttpDns", "getHttpDnsIp host: " + host + " type: " + type);
+ Map map = httpDnsHelper.getAllAddress();
+ if (useCache) {
+ String address = httpDnsHelper.getHttpDnsCachedAddress(type, host);
+ if (address != null) {
+ return address;
+ } else {
+ return httpDnsHelper.getHttpDnsAddress(type, host);
+ }
+ } else {
+ return httpDnsHelper.getHttpDnsAddress(type, host);
+ }
+ }
+
@Override
public void getHttpDnsIp(String host, int type, boolean useCache, IHttpDnsCallback callback) {
Logger.d("MogoHttpDns", "getHttpDnsIp host: " + host + " type: " + type);
@@ -96,7 +112,7 @@ public class MogoHttpDns implements IMogoHttpDns, HttpDns, OnAddressChangedListe
public HttpDnsSimpleLocation getCurrentLocation() {
HttpSimpleLocation simpleLocation = locationChanged.getLocation();
if (simpleLocation != null) {
- return new HttpDnsSimpleLocation("0734", simpleLocation.getLat(), simpleLocation.getLon());
+ return new HttpDnsSimpleLocation("010", simpleLocation.getLat(), simpleLocation.getLon());
}
return null;
}
diff --git a/foudations/httpdns-noop/src/main/java/com/mogo/httpdns/noop/HttpDnsNoop.java b/foudations/httpdns-noop/src/main/java/com/mogo/httpdns/noop/HttpDnsNoop.java
index 5cd0e7df49..04944cd4a5 100644
--- a/foudations/httpdns-noop/src/main/java/com/mogo/httpdns/noop/HttpDnsNoop.java
+++ b/foudations/httpdns-noop/src/main/java/com/mogo/httpdns/noop/HttpDnsNoop.java
@@ -5,6 +5,7 @@ import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.httpdns.HttpDnsConst;
import com.mogo.httpdns.IHttpDnsCallback;
+import com.mogo.httpdns.IHttpDnsLocationChanged;
import com.mogo.httpdns.IHttpDnsTtlCallback;
import com.mogo.httpdns.IMogoHttpDns;
import com.mogo.utils.network.HttpDns;
@@ -29,6 +30,11 @@ class HttpDnsNoop implements IMogoHttpDns {
return host;
}
+ @Override
+ public String syncGetHttpDns(String host, int type, boolean useCache) {
+ return host;
+ }
+
@Override
public void getHttpDnsIp( String host,int type, boolean useCache, IHttpDnsCallback callback ) {
if ( callback != null ) {
@@ -46,6 +52,11 @@ class HttpDnsNoop implements IMogoHttpDns {
}
+ @Override
+ public void init(Context context, IHttpDnsLocationChanged locationChanged) {
+
+ }
+
@Override
public void init( Context context ) {
diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java
index f35b7a2549..4037c1772e 100644
--- a/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java
+++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/AbsMogoApplication.java
@@ -19,6 +19,7 @@ import com.mogo.commons.network.Constants;
import com.mogo.commons.network.ParamsUtil;
import com.mogo.commons.network.X509TrustManagerImpl;
import com.mogo.commons.storage.SpStorage;
+import com.mogo.httpdns.HttpDnsConst;
import com.mogo.httpdns.IMogoHttpDns;
import com.mogo.httpdns.MogoHttpDnsHandler;
import com.mogo.utils.ThreadPoolService;
@@ -178,7 +179,16 @@ public abstract class AbsMogoApplication extends Application {
.build();
return chain.proceed( request );
} )
- .setHttpDns( dns.dns() )
+ // 增加域名->域名的转换方式,暂时去掉httpdns方式
+ .addInterceptor(chain -> {
+ Request request = chain.request();
+ String path = request.url().encodedPath();
+ String host = "http://" + dns.syncGetHttpDns(request.url().host().replace("http://", "").replace("https://", ""), HttpDnsConst.HTTP_DNS_ADDRESS_TYPE_HTTP, true);
+ String url = host + path;
+ Logger.d("DomainExchange", "oriHost: " + request.url().host() + " newHost: " + host+" \r\n newUrl: "+url);
+ return chain.proceed(request.newBuilder().url(url).build());
+ })
+ .setHttpDns( null )
.setLoggable( DebugConfig.isDebug() );
}
}
diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/HostConst.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/HostConst.java
index 991a656092..e2e02bdf0e 100644
--- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/HostConst.java
+++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/constants/HostConst.java
@@ -18,7 +18,6 @@ public class HostConst {
public static final String STRATEGY_PUSH_HOST = "http://dzt-strategyPush.zhidaozhixing.com";
public static final String TRAVEL_CONDITION_HOST = "http://dzt-travelCondition.zhidaozhixing.com";
public static final String TMC_HOST = "http://dzt-tmcServer.zhidaozhixing.com";
-
public static final String IM_SOCKET_DOMAIN = "dzt-im.zhidaozhixing.com";
public static final String WEBSOCKET_DOMAIN = "dzt-Instant.zhidaozhixing.com";
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java
index 7b6e45376d..3eab4ed285 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/entrance/EntranceFragment.java
@@ -385,7 +385,7 @@ public class EntranceFragment extends MvpFragment stickViewCache = new ArrayList<>();
+
+ private void showStickView() {
+ if (stickViewCache.isEmpty()) {
+ return;
+ } else if (stickViewCache.size() == 1) {
+ MotionViewCache stickView = stickViewCache.remove(0);
+ startTopInAnim(stickView.view, stickView.params, stickView.statusListener);
+ return;
+ }
+ for (int i = 0; i < stickViewCache.size() - 2; i++) {
+ MotionViewCache stickView = stickViewCache.get(i);
+ stickView.statusListener.beforeViewRemoveAnim(stickView.view);
+ stickView.statusListener.onViewRemoved(stickView.view);
+ }
+ MotionViewCache stickView = stickViewCache.get(stickViewCache.size() - 1);
+ stickViewCache.clear();
+ startTopInAnim(stickView.view, stickView.params, stickView.statusListener);
+ }
+
public void startTopInAnim(View view, ViewGroup.LayoutParams params,
IMogoTopViewStatusListener statusListener) {
if (topMotionLayout == null) {
+ // 增加黏性事件
+ stickViewCache.add(new MotionViewCache(view, params, statusListener));
return;
}
@@ -442,6 +467,8 @@ public class TopViewAnimHelper {
/**
* 用于和{@link TopViewNoLinkageAnimHelper}互斥显示
+ *
+ * 网约车新增与网约车界面互斥
*/
public void removeAllViewExceptVrNav() {
Logger.d(TAG, "remove all view except vr nav");
diff --git a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/TopViewManager.java b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/TopViewManager.java
index eb3e21a46c..f7152a92a0 100644
--- a/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/TopViewManager.java
+++ b/modules/mogo-module-extensions/src/main/java/com/mogo/module/extensions/utils/TopViewManager.java
@@ -141,4 +141,14 @@ public class TopViewManager implements IMogoTopViewManager {
return false;
}
}
+
+ @Override
+ public void removeAllViewInVrMode() {
+ try {
+ TopViewAnimHelper.getInstance().removeAllViewExceptVrNav();
+ TopViewNoLinkageAnimHelper.getInstance().removeAllView();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/windowview/IMogoTopViewManager.java b/services/mogo-service-api/src/main/java/com/mogo/service/windowview/IMogoTopViewManager.java
index f76f75b384..3593e3ec8c 100644
--- a/services/mogo-service-api/src/main/java/com/mogo/service/windowview/IMogoTopViewManager.java
+++ b/services/mogo-service-api/src/main/java/com/mogo/service/windowview/IMogoTopViewManager.java
@@ -124,4 +124,9 @@ public interface IMogoTopViewManager extends IProvider {
* @return true-已经添加 false-未添加
*/
boolean isViewNoLinkageAdded(View view);
+
+ /**
+ * 在vr模式下,隐藏所有topview,除了vr模式下的导航信息
+ */
+ void removeAllViewInVrMode();
}