This commit is contained in:
wangcongtao
2021-01-20 14:09:00 +08:00
21 changed files with 858 additions and 4 deletions

1
.idea/gradle.xml generated
View File

@@ -89,6 +89,7 @@
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
</component>

View File

@@ -39,15 +39,21 @@ dependencies {
implementation rootProject.ext.dependencies.androidxappcompat
implementation rootProject.ext.dependencies.arouter
annotationProcessor rootProject.ext.dependencies.aroutercompiler
implementation rootProject.ext.dependencies.androidxconstraintlayout
implementation rootProject.ext.dependencies.rxjava
implementation rootProject.ext.dependencies.rxandroid
if (Boolean.valueOf(RELEASE)) {
implementation rootProject.ext.dependencies.mogooch
implementation rootProject.ext.dependencies.mogoutils
implementation rootProject.ext.dependencies.mogocommons
implementation rootProject.ext.dependencies.modulecommon
} else {
implementation project(":OCH:mogo-och")
implementation project(":foudations:mogo-utils")
implementation project(":foudations:mogo-commons")
implementation project(":modules:mogo-module-common")
}
}

View File

@@ -0,0 +1,93 @@
package com.mogo.och.bus;
import android.content.Context;
import androidx.fragment.app.FragmentActivity;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.och.IMogoOCH;
import com.mogo.och.OCHConstants;
import com.mogo.och.bus.bean.OchBusStation;
import com.mogo.och.bus.fragment.OchBusFragment;
import com.mogo.service.connection.IMogoOnMessageListener;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.logger.Logger;
import java.util.List;
/**
* 网约车小巴业务实现入口
*
* @author tongchenfei
*/
@Route(path = OCHConstants.PATH)
public class OchBusProvider implements IMogoOCH {
private static final String TAG = "OchBusProvider";
private OchBusFragment busFragment;
private int containerId;
private FragmentActivity activity;
@Override
public void init(FragmentActivity activity, int containerId) {
this.containerId = containerId;
this.activity = activity;
}
@Override
public void init(Context context) {
MogoApisHandler.getInstance().getApis().getStatusManagerApi().registerStatusChangedListener("OchBus", StatusDescriptor.VR_MODE, statusChangedListener);
MogoApisHandler.getInstance().getApis().getStatusManagerApi().registerStatusChangedListener("OchBus", StatusDescriptor.TOP_VIEW, statusChangedListener);
MogoApisHandler.getInstance().getApis().getSocketManagerApi(context).registerOnMessageListener(401017,messageListener);
}
private void showFragment() {
if (busFragment == null) {
Logger.d(TAG,"准备add fragment======");
busFragment = new OchBusFragment();
activity.getSupportFragmentManager().beginTransaction().add(containerId, busFragment).commit();
return;
}
Logger.d(TAG,"准备show fragment");
activity.getSupportFragmentManager().beginTransaction().show(busFragment).commit();
}
private void hideFragment() {
if (busFragment != null) {
Logger.d(TAG,"准备hide fragment");
activity.getSupportFragmentManager().beginTransaction().hide(busFragment).commit();
}
}
private final IMogoStatusChangedListener statusChangedListener = (descriptor, isTrue) -> {
if (descriptor == StatusDescriptor.VR_MODE) {
// 进入vr模式默认显示网约车小巴fragment
if (isTrue) {
showFragment();
} else {
hideFragment();
}
} else if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() && descriptor == StatusDescriptor.TOP_VIEW) {
// topView进行展示时推出网约车界面但是不隐藏整个fragment
if (busFragment != null && isTrue) {
busFragment.hideOchBus();
}
}
};
private final IMogoOnMessageListener<List<OchBusStation>> messageListener = new IMogoOnMessageListener<List<OchBusStation>>() {
@Override
public Class<List<OchBusStation>> target() {
return null;
}
@Override
public void onMsgReceived(List<OchBusStation> obj) {
// 刷新列表
busFragment.getPresenter().getStationListFromSocket(obj);
}
};
}

View File

@@ -0,0 +1,24 @@
package com.mogo.och.bus.bean;
/**
* 公交驶离车站,同步服务端请求参数封装
*
* @author tongchenfei
*/
public class OchBusLeaveStationRequest {
private final String sn;
private final int siteId;
public OchBusLeaveStationRequest(String sn, int siteId) {
this.sn = sn;
this.siteId = siteId;
}
public String getSn() {
return sn;
}
public int getSiteId() {
return siteId;
}
}

View File

@@ -0,0 +1,42 @@
package com.mogo.och.bus.bean;
/**
* 网约车小巴路线请求参数封装
*
* @author tongchenfei
*/
public class OchBusRoutesRequest {
double lat;
double lon;
String sn;
public OchBusRoutesRequest(String sn, double lat, double lon) {
this.lat = lat;
this.lon = lon;
this.sn = sn;
}
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
public double getLon() {
return lon;
}
public void setLon(double lon) {
this.lon = lon;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
}

View File

@@ -0,0 +1,27 @@
package com.mogo.och.bus.bean;
import com.mogo.commons.data.BaseData;
/**
* 网约车小巴路线接口请求响应结果
*
* @author tongchenfei
*/
public class OchBusRoutesResponse extends BaseData {
private OchBusRoutesResult result;
public OchBusRoutesResult getResult() {
return result;
}
public void setResult(OchBusRoutesResult result) {
this.result = result;
}
@Override
public String toString() {
return "OchBusRoutesResponse{" +
"result=" + result +
'}';
}
}

View File

@@ -0,0 +1,27 @@
package com.mogo.och.bus.bean;
import java.util.List;
/**
* 网约车小巴路线接口返回接口数据封装
*
* @author tongchenfei
*/
public class OchBusRoutesResult {
private List<OchBusStation> site;
public List<OchBusStation> getSite() {
return site;
}
public void setSite(List<OchBusStation> site) {
this.site = site;
}
@Override
public String toString() {
return "OchBusRoutesResult{" +
"site=" + site +
'}';
}
}

View File

@@ -0,0 +1,146 @@
package com.mogo.och.bus.bean;
/**
* 单个网约车小巴车站信息
*
* @author tongchenfei
*/
public class OchBusStation {
private int lineId;
private int siteId;
private String siteName;
private String cityCode;
private String areaCode;
private String areaName;
private double lat;
private double lon;
private String siteDesc;
private int siteState;
private int isCurrentSite;
private int siteColor;
private String peoples;
public int getLineId() {
return lineId;
}
public void setLineId(int lineId) {
this.lineId = lineId;
}
public int getSiteId() {
return siteId;
}
public void setSiteId(int siteId) {
this.siteId = siteId;
}
public String getSiteName() {
return siteName;
}
public void setSiteName(String siteName) {
this.siteName = siteName;
}
public String getCityCode() {
return cityCode;
}
public void setCityCode(String cityCode) {
this.cityCode = cityCode;
}
public String getAreaCode() {
return areaCode;
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
public String getAreaName() {
return areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public double getLat() {
return lat;
}
public void setLat(double lat) {
this.lat = lat;
}
public double getLon() {
return lon;
}
public void setLon(double lon) {
this.lon = lon;
}
public String getSiteDesc() {
return siteDesc;
}
public void setSiteDesc(String siteDesc) {
this.siteDesc = siteDesc;
}
public int getSiteState() {
return siteState;
}
public void setSiteState(int siteState) {
this.siteState = siteState;
}
public int getIsCurrentSite() {
return isCurrentSite;
}
public void setIsCurrentSite(int isCurrentSite) {
this.isCurrentSite = isCurrentSite;
}
public int getSiteColor() {
return siteColor;
}
public void setSiteColor(int siteColor) {
this.siteColor = siteColor;
}
public String getPeoples() {
return peoples;
}
public void setPeoples(String peoples) {
this.peoples = peoples;
}
@Override
public String toString() {
return "OchBusStation{" +
"lineId=" + lineId +
", siteId=" + siteId +
", siteName='" + siteName + '\'' +
", cityCode='" + cityCode + '\'' +
", areaCode='" + areaCode + '\'' +
", areaName='" + areaName + '\'' +
", lat=" + lat +
", lon=" + lon +
", siteDesc='" + siteDesc + '\'' +
", siteState=" + siteState +
", isCurrentSite=" + isCurrentSite +
", siteColor=" + siteColor +
", peoples='" + peoples + '\'' +
'}';
}
}

View File

@@ -0,0 +1,129 @@
package com.mogo.och.bus.fragment;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.Group;
import com.mogo.commons.mvp.MvpFragment;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.view.OnPreventFastClickListener;
import com.mogo.och.bus.R;
import com.mogo.och.bus.bean.OchBusStation;
import com.mogo.och.bus.presenter.OchBusPresenter;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.List;
/**
* 网约车小巴界面
*
* @author tongchenfei
*/
public class OchBusFragment extends MvpFragment<OchBusFragment, OchBusPresenter> {
private static final String TAG = "OchBusFragment";
private Group groupOchBus;
private final List<OchBusStation> stationList = new ArrayList<>();
private Button btnExecute;
private TextView tvNotice;
@Override
protected int getLayoutId() {
return R.layout.fragment_och_bus;
}
@Override
protected void initViews() {
groupOchBus = findViewById(R.id.groupOchBus);
findViewById(R.id.btnEnterOchBus).setOnClickListener(new OnPreventFastClickListener() {
@Override
public void onClickImpl(View v) {
showOchBus();
}
});
btnExecute = findViewById(R.id.btnExecute);
btnExecute.setOnClickListener(new OnPreventFastClickListener() {
@Override
public void onClickImpl(View v) {
mPresenter.autoDriveToNextStation();
}
});
tvNotice = findViewById(R.id.vBusRoute);
}
@NonNull
@Override
protected OchBusPresenter createPresenter() {
return new OchBusPresenter(this);
}
public void showOchBus() {
MogoApisHandler.getInstance().getApis().getTopViewManager().removeAllViewInVrMode();
groupOchBus.setVisibility(View.VISIBLE);
}
@Override
public void onResume() {
super.onResume();
queryStationListIfNecessary();
}
@Override
public void onHiddenChanged(boolean hidden) {
super.onHiddenChanged(hidden);
Logger.d(TAG, "onHiddenChanged: " + hidden);
if (!hidden) {
// 判断是否需要请求接口
queryStationListIfNecessary();
}
}
public void refreshBusStations(List<OchBusStation> 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();
}
}
}

View File

@@ -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 {
/**
* 根据车机坐标获取所在区域全部站点信息
* <p>
* 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<OchBusRoutesResponse> 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<BaseData> leaveStation(@Body RequestBody requestBody);
}

View File

@@ -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<OchBusFragment> 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<OchBusStation> 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<OchBusRoutesResponse>(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<OchBusStation> 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<BaseData>(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_STOPEDcurrentStationIndex增加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);
}
}
}

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btnEnterOchBus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="进入网约车小巴"
android:textSize="40sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<Button
android:id="@+id/btnExecute"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="准备出发"
android:textSize="30sp"
app:layout_constraintRight_toRightOf="@id/vBusRoute"
app:layout_constraintTop_toBottomOf="@id/vBusRoute" />
<TextView
android:id="@+id/vBusRoute"
android:layout_width="600px"
android:layout_height="300px"
android:background="#0f0"
android:gravity="center"
android:text="notice"
android:textSize="30sp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Group
android:id="@+id/groupOchBus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="vBusRoute,btnExecute" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -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 回调
// *

View File

@@ -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<String, String> 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;
}

View File

@@ -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 ) {

View File

@@ -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() );
}
}

View File

@@ -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";

View File

@@ -385,7 +385,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
mUploadRoadCondition.setVisibility(View.VISIBLE);
groupUserHead.setVisibility(View.VISIBLE);
if(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isSeekHelping()) {
seekHelpGroup.setVisibility( View.VISIBLE );
seekHelpGroup.setVisibility(View.VISIBLE);
}
// mWeatherContainer.setVisibility(View.VISIBLE);
// mMsgContainer.setVisibility(View.VISIBLE);

View File

@@ -83,6 +83,9 @@ public class TopViewAnimHelper {
cameraMode = rootView.findViewById(R.id.module_ext_id_north);
// 初始化默认隐藏导航
hideNaviView();
showStickView();
}
private volatile boolean isTopViewOut = true;
@@ -185,10 +188,32 @@ public class TopViewAnimHelper {
}).start();
}
private final List<MotionViewCache> 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");

View File

@@ -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();
}
}
}

View File

@@ -124,4 +124,9 @@ public interface IMogoTopViewManager extends IProvider {
* @return true-已经添加 false-未添加
*/
boolean isViewNoLinkageAdded(View view);
/**
* 在vr模式下隐藏所有topview除了vr模式下的导航信息
*/
void removeAllViewInVrMode();
}