添加网络测试
This commit is contained in:
@@ -37,5 +37,6 @@ dependencies {
|
||||
implementation project(path: ':foudations:mogo-passport')
|
||||
implementation project(path: ':foudations:mogo-commons')
|
||||
// implementation 'com.mogo.cloud:passport:1.0.0'
|
||||
|
||||
implementation rootProject.ext.dependencies.rxjava
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
}
|
||||
@@ -20,6 +20,14 @@
|
||||
<activity android:name=".MainActivity">
|
||||
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".network.NetworkActivity"
|
||||
android:label="网络测试">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
22
app/src/main/java/com/mogo/cloud/network/ApiService.java
Normal file
22
app/src/main/java/com/mogo/cloud/network/ApiService.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.mogo.cloud.network;
|
||||
|
||||
import com.mogo.cloud.network.V2XRoadDataRes;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
/**
|
||||
* created by wujifei on 2021/1/21 13:02
|
||||
* describe:
|
||||
*/
|
||||
public interface ApiService {
|
||||
|
||||
/**
|
||||
* 基于目的地预判的道路事件和违章高发情况的停车推荐
|
||||
*/
|
||||
@GET("/yycp-geo-fence-carService/car/road/getRoadDataOfVehiclesRecommend")
|
||||
Observable<V2XRoadDataRes> queryRoadDataOfVehiclesRecommend(@QueryMap Map<String, Object> parameters);
|
||||
}
|
||||
12
app/src/main/java/com/mogo/cloud/network/BaseData.java
Normal file
12
app/src/main/java/com/mogo/cloud/network/BaseData.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.mogo.cloud.network;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by congtaowang on 2019/1/7.
|
||||
*/
|
||||
public class BaseData implements Serializable, Cloneable {
|
||||
|
||||
public int code = -1;
|
||||
public String msg;
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.mogo.cloud.network;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.mogo.cloud.R;
|
||||
import com.mogo.utils.network.RetrofitFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* created by wujifei on 2021/1/21 12:26
|
||||
* describe:
|
||||
*/
|
||||
public class NetworkActivity extends AppCompatActivity {
|
||||
private Button btn;
|
||||
private TextView tvResult;
|
||||
|
||||
|
||||
private ApiService apiService;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_network);
|
||||
btn = (Button) findViewById(R.id.btn);
|
||||
tvResult = (TextView) findViewById(R.id.tv_result);
|
||||
apiService = RetrofitFactory.getInstance("http://dzt-test.zhidaozhixing.com")
|
||||
.create(ApiService.class);
|
||||
btn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
tvResult.setText("结果显示");
|
||||
queryRoadData("ZD802C1938L10797");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void queryRoadData(String sn) {
|
||||
if (apiService != null) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("sn", sn);
|
||||
apiService.queryRoadDataOfVehiclesRecommend(map)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<V2XRoadDataRes>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(V2XRoadDataRes value) {
|
||||
tvResult.setText(new Gson().toJson(value));
|
||||
System.out.println(new Gson().toJson(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
tvResult.setText(e.toString());
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
535
app/src/main/java/com/mogo/cloud/network/V2XRoadDataRes.java
Normal file
535
app/src/main/java/com/mogo/cloud/network/V2XRoadDataRes.java
Normal file
@@ -0,0 +1,535 @@
|
||||
package com.mogo.cloud.network;
|
||||
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* created by wujifei on 2020/12/24 11:05
|
||||
* describe:于目的地预判的道路事件和违章高发情况的停车推荐 返回数据
|
||||
*/
|
||||
public class V2XRoadDataRes extends BaseData {
|
||||
|
||||
private String detailMsg;
|
||||
private ResultDTO result;
|
||||
|
||||
public String getDetailMsg() {
|
||||
return detailMsg;
|
||||
}
|
||||
|
||||
public void setDetailMsg(String detailMsg) {
|
||||
this.detailMsg = detailMsg;
|
||||
}
|
||||
|
||||
public ResultDTO getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(ResultDTO result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public static class ResultDTO {
|
||||
private String formatAddress;
|
||||
private List<Double> fromPoint;
|
||||
private List<Double> topPoint;
|
||||
private List<PoiDataDTO> poiData;
|
||||
private List<IllegalParkingDataDTO> illegalParkingData;
|
||||
|
||||
public String getFormatAddress() {
|
||||
return formatAddress;
|
||||
}
|
||||
|
||||
public void setFormatAddress(String formatAddress) {
|
||||
this.formatAddress = formatAddress;
|
||||
}
|
||||
|
||||
public List<Double> getFromPoint() {
|
||||
return fromPoint;
|
||||
}
|
||||
|
||||
public void setFromPoint(List<Double> fromPoint) {
|
||||
this.fromPoint = fromPoint;
|
||||
}
|
||||
|
||||
public List<Double> getTopPoint() {
|
||||
return topPoint;
|
||||
}
|
||||
|
||||
public void setTopPoint(List<Double> topPoint) {
|
||||
this.topPoint = topPoint;
|
||||
}
|
||||
|
||||
public List<PoiDataDTO> getPoiData() {
|
||||
return poiData;
|
||||
}
|
||||
|
||||
public void setPoiData(List<PoiDataDTO> poiData) {
|
||||
this.poiData = poiData;
|
||||
}
|
||||
|
||||
public List<IllegalParkingDataDTO> getIllegalParkingData() {
|
||||
return illegalParkingData;
|
||||
}
|
||||
|
||||
public void setIllegalParkingData(List<IllegalParkingDataDTO> illegalParkingData) {
|
||||
this.illegalParkingData = illegalParkingData;
|
||||
}
|
||||
|
||||
public static class PoiDataDTO {
|
||||
/**
|
||||
* generateTime : 1607061691000
|
||||
* type : 0
|
||||
* lat : 39.988346
|
||||
* lon : 116.410857
|
||||
* direction : 333
|
||||
* items : [{"url":"http://petchfile-1255510688.cos.ap-beijing.myqcloud.com/sso-server-image/1603181678357.png?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKIDCWfcNwD5PXVWLxwejccR3Tiz5zhIkx0T%26q-sign-time%3D1607393278%3B1607400478%26q-key-time%3D1607393278%3B1607400478%26q-header-list%3D%26q-url-param-list%3D%26q-signature%3D78c0f738f4dae37e67c235561c78120b86433a04"}]
|
||||
* cityName :
|
||||
* distance : 21447
|
||||
* nickName : 独狼
|
||||
* headImgUrl : https://yycp-static-1255510688.cos.ap-beijing.myqcloud.com/defaultUserHeadImg/VN000015.jpg
|
||||
* sn :
|
||||
* userId : 0
|
||||
* trafficInfoType : 0
|
||||
* infoId : 784423898000445440
|
||||
* poiType : 10015
|
||||
* uploadType : 2
|
||||
* likeNum : 3
|
||||
* systemLikeNum : 3
|
||||
* fabulous : false
|
||||
*/
|
||||
|
||||
|
||||
private long generateTime;
|
||||
|
||||
private int type;
|
||||
private double lat;
|
||||
private double lon;
|
||||
|
||||
private int direction;
|
||||
private String cityName;
|
||||
|
||||
private int distance;
|
||||
private String nickName;
|
||||
|
||||
private String headImgUrl;
|
||||
|
||||
private String sn;
|
||||
|
||||
private long userId;
|
||||
|
||||
private String trafficInfoType;
|
||||
|
||||
private String infoId;
|
||||
|
||||
private String poiType;
|
||||
|
||||
private String uploadType;
|
||||
|
||||
private int likeNum;
|
||||
|
||||
private int systemLikeNum;
|
||||
|
||||
private boolean fabulous;
|
||||
|
||||
private List<ItemsDTO> items;
|
||||
|
||||
public long getGenerateTime() {
|
||||
return generateTime;
|
||||
}
|
||||
|
||||
public void setGenerateTime(long generateTime) {
|
||||
this.generateTime = generateTime;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
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 int getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setDirection(int direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
public String getCityName() {
|
||||
return cityName;
|
||||
}
|
||||
|
||||
public void setCityName(String cityName) {
|
||||
this.cityName = cityName;
|
||||
}
|
||||
|
||||
public int getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(int distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getHeadImgUrl() {
|
||||
return headImgUrl;
|
||||
}
|
||||
|
||||
public void setHeadImgUrl(String headImgUrl) {
|
||||
this.headImgUrl = headImgUrl;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getTrafficInfoType() {
|
||||
return trafficInfoType;
|
||||
}
|
||||
|
||||
public void setTrafficInfoType(String trafficInfoType) {
|
||||
this.trafficInfoType = trafficInfoType;
|
||||
}
|
||||
|
||||
public String getInfoId() {
|
||||
return infoId;
|
||||
}
|
||||
|
||||
public void setInfoId(String infoId) {
|
||||
this.infoId = infoId;
|
||||
}
|
||||
|
||||
public String getPoiType() {
|
||||
return poiType;
|
||||
}
|
||||
|
||||
public void setPoiType(String poiType) {
|
||||
this.poiType = poiType;
|
||||
}
|
||||
|
||||
public String getUploadType() {
|
||||
return uploadType;
|
||||
}
|
||||
|
||||
public void setUploadType(String uploadType) {
|
||||
this.uploadType = uploadType;
|
||||
}
|
||||
|
||||
public int getLikeNum() {
|
||||
return likeNum;
|
||||
}
|
||||
|
||||
public void setLikeNum(int likeNum) {
|
||||
this.likeNum = likeNum;
|
||||
}
|
||||
|
||||
public int getSystemLikeNum() {
|
||||
return systemLikeNum;
|
||||
}
|
||||
|
||||
public void setSystemLikeNum(int systemLikeNum) {
|
||||
this.systemLikeNum = systemLikeNum;
|
||||
}
|
||||
|
||||
public boolean isFabulous() {
|
||||
return fabulous;
|
||||
}
|
||||
|
||||
public void setFabulous(boolean fabulous) {
|
||||
this.fabulous = fabulous;
|
||||
}
|
||||
|
||||
public List<ItemsDTO> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<ItemsDTO> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
|
||||
public static class ItemsDTO {
|
||||
/**
|
||||
* url : http://petchfile-1255510688.cos.ap-beijing.myqcloud.com/sso-server-image/1603181678357.png?sign=q-sign-algorithm%3Dsha1%26q-ak%3DAKIDCWfcNwD5PXVWLxwejccR3Tiz5zhIkx0T%26q-sign-time%3D1607393278%3B1607400478%26q-key-time%3D1607393278%3B1607400478%26q-header-list%3D%26q-url-param-list%3D%26q-signature%3D78c0f738f4dae37e67c235561c78120b86433a04
|
||||
*/
|
||||
|
||||
|
||||
private String url;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class IllegalParkingDataDTO {
|
||||
/**
|
||||
* generateTime : 1594047156488
|
||||
* type : 3
|
||||
* lat : 40.028599
|
||||
* lon : 116.412712
|
||||
* direction : 0
|
||||
* addr : 红军营南路红军营南路万科星园北口至红军营南路北苑路口段
|
||||
* items : []
|
||||
* cityName :
|
||||
* distance : 6728
|
||||
* nickName :
|
||||
* headImgUrl :
|
||||
* sn :
|
||||
* userId : 0
|
||||
* trafficInfoType : 0
|
||||
* infoId : 686267
|
||||
* poiType : 10016
|
||||
* uploadType : 3
|
||||
* likeNum : 0
|
||||
* systemLikeNum : 0
|
||||
* fabulous : false
|
||||
*/
|
||||
|
||||
|
||||
private long generateTime;
|
||||
|
||||
private int type;
|
||||
|
||||
private double lat;
|
||||
|
||||
private double lon;
|
||||
|
||||
private int direction;
|
||||
|
||||
private String addr;
|
||||
|
||||
private String cityName;
|
||||
|
||||
private int distance;
|
||||
|
||||
private String nickName;
|
||||
|
||||
private String headImgUrl;
|
||||
|
||||
private String sn;
|
||||
|
||||
private long userId;
|
||||
|
||||
private String trafficInfoType;
|
||||
|
||||
private String infoId;
|
||||
|
||||
private String poiType;
|
||||
|
||||
private String uploadType;
|
||||
|
||||
private int likeNum;
|
||||
|
||||
private int systemLikeNum;
|
||||
|
||||
private boolean fabulous;
|
||||
|
||||
private List<?> items;
|
||||
|
||||
public long getGenerateTime() {
|
||||
return generateTime;
|
||||
}
|
||||
|
||||
public void setGenerateTime(long generateTime) {
|
||||
this.generateTime = generateTime;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
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 int getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setDirection(int direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
public String getAddr() {
|
||||
return addr;
|
||||
}
|
||||
|
||||
public void setAddr(String addr) {
|
||||
this.addr = addr;
|
||||
}
|
||||
|
||||
public String getCityName() {
|
||||
return cityName;
|
||||
}
|
||||
|
||||
public void setCityName(String cityName) {
|
||||
this.cityName = cityName;
|
||||
}
|
||||
|
||||
public int getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(int distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) {
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public String getHeadImgUrl() {
|
||||
return headImgUrl;
|
||||
}
|
||||
|
||||
public void setHeadImgUrl(String headImgUrl) {
|
||||
this.headImgUrl = headImgUrl;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getTrafficInfoType() {
|
||||
return trafficInfoType;
|
||||
}
|
||||
|
||||
public void setTrafficInfoType(String trafficInfoType) {
|
||||
this.trafficInfoType = trafficInfoType;
|
||||
}
|
||||
|
||||
public String getInfoId() {
|
||||
return infoId;
|
||||
}
|
||||
|
||||
public void setInfoId(String infoId) {
|
||||
this.infoId = infoId;
|
||||
}
|
||||
|
||||
public String getPoiType() {
|
||||
return poiType;
|
||||
}
|
||||
|
||||
public void setPoiType(String poiType) {
|
||||
this.poiType = poiType;
|
||||
}
|
||||
|
||||
public String getUploadType() {
|
||||
return uploadType;
|
||||
}
|
||||
|
||||
public void setUploadType(String uploadType) {
|
||||
this.uploadType = uploadType;
|
||||
}
|
||||
|
||||
public int getLikeNum() {
|
||||
return likeNum;
|
||||
}
|
||||
|
||||
public void setLikeNum(int likeNum) {
|
||||
this.likeNum = likeNum;
|
||||
}
|
||||
|
||||
public int getSystemLikeNum() {
|
||||
return systemLikeNum;
|
||||
}
|
||||
|
||||
public void setSystemLikeNum(int systemLikeNum) {
|
||||
this.systemLikeNum = systemLikeNum;
|
||||
}
|
||||
|
||||
public boolean isFabulous() {
|
||||
return fabulous;
|
||||
}
|
||||
|
||||
public void setFabulous(boolean fabulous) {
|
||||
this.fabulous = fabulous;
|
||||
}
|
||||
|
||||
public List<?> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<?> items) {
|
||||
this.items = items;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
app/src/main/res/layout/activity_network.xml
Normal file
19
app/src/main/res/layout/activity_network.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="网络请求" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_result"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="结果显示" />
|
||||
</LinearLayout>
|
||||
@@ -13,7 +13,6 @@ class HeaderNetworkInterceptor : Interceptor {
|
||||
val original = chain.request()
|
||||
val request = original.newBuilder()
|
||||
.header("token", MoGoAiCloudClient.getInstance().aiCloudClientConfig.token)
|
||||
.header("thirdPartyAppKey", MoGoAiCloudClient.getInstance().aiCloudClientConfig.thirdPartyAppKey)
|
||||
.method(original.method(), original.body())
|
||||
.build()
|
||||
return chain.proceed(request)
|
||||
|
||||
Reference in New Issue
Block a user