version:1.0.0
update:更换包名 bugfixes:
This commit is contained in:
1513
app/src/main/java/com/xxpatx/os/network/NetInterfaceManager.java
Normal file
1513
app/src/main/java/com/xxpatx/os/network/NetInterfaceManager.java
Normal file
File diff suppressed because it is too large
Load Diff
175
app/src/main/java/com/xxpatx/os/network/UrlAddress.java
Normal file
175
app/src/main/java/com/xxpatx/os/network/UrlAddress.java
Normal file
@@ -0,0 +1,175 @@
|
||||
package com.xxpatx.os.network;
|
||||
|
||||
public class UrlAddress {
|
||||
public static final String ROOT_URL = "https://led.zuoyepad.com/android/";
|
||||
/*百度地图*/
|
||||
@Deprecated
|
||||
public static final String AMAP_ROOT_URL = "https://api.map.baidu.com/";
|
||||
/*和风天气*/
|
||||
public static final String QWEATHER_ROOT_URL = "https://geoapi.qweather.com/";
|
||||
|
||||
|
||||
/**
|
||||
* 旧接口
|
||||
* SN
|
||||
*/
|
||||
/*获取用户头像和信息*/
|
||||
public static final String GET_USER_AVATAR_INFO = "sn/getUserAvatarInfo";
|
||||
|
||||
|
||||
/**
|
||||
* 新接口
|
||||
* SN
|
||||
*/
|
||||
/*爱心提醒通知成功接口*/
|
||||
public static final String UPDATE_ALARM_CLOCK = "updateAlarmClock";
|
||||
/*上传截屏图片*/
|
||||
public static final String SEND_SCREENSHOT = "sn/uploadScreenshot";
|
||||
/*获取系统设置其它管控*/
|
||||
public final static String GET_SETTINGS = "control/getSetting";
|
||||
/*sos记录*/
|
||||
public static final String SOS_RECORD = "sosRecord";
|
||||
/*上传地址信息*/
|
||||
public static final String UPDATE_ADDRESS = "sn/update-address";
|
||||
/*获取设备家庭地址*/
|
||||
public static final String FAMILY_ADDRESS = "sn/family-address";
|
||||
|
||||
|
||||
/*获取抢购列表*/
|
||||
public static final String GET_GOODS_LIST = "getGoodsList";
|
||||
/*获取抢购详情*/
|
||||
public static final String GET_GOODS_DETAILS = "getGoodsDetails";
|
||||
/*获取资讯列表*/
|
||||
public static final String GET_ARTICLE_LIST = "getArticleList";
|
||||
/*获取资讯详情*/
|
||||
public static final String GET_ARTICLE_DETAILS = "getArticleDetails";
|
||||
|
||||
/*获取健康码*/
|
||||
public static final String GET_HEALTH_CODE = "getHealthCode";
|
||||
/*获取设备信息*/
|
||||
public static final String SNINFO = "sn/getSnInfo";
|
||||
/*获取用户编号*/
|
||||
public static final String GET_USER_ID = "getUserId";
|
||||
|
||||
/*获取商品分类列表*/
|
||||
public static final String GOODS_TYPE_LIST = "goods-type-list";
|
||||
/*获取负二屏开关*/
|
||||
public static final String GET_ADMIN_SN_SETTING = "getAdminSnSetting";
|
||||
/*更新app隐藏或者显示状态*/
|
||||
public static final String APP_ICON_UPDATE = "Control/appIconUpdate";
|
||||
/*获取联系人*/
|
||||
public static final String GET_MAIL_LIST = "Control/getMailList";
|
||||
/*添加联系人*/
|
||||
public static final String MAIL_LIST_ADD = "MailList/mailListAdd";
|
||||
/*编辑联系人*/
|
||||
public static final String MAIL_LIST_EDIT = "MailList/mailListEdit";
|
||||
/*删除联系人*/
|
||||
public static final String MAIL_LIST_DELETE = "MailList/mailListDelete";
|
||||
/*编号查询联系人*/
|
||||
public static final String MAIL_LIST_BY_ID = "MailList/mailListById";
|
||||
|
||||
/**
|
||||
* 应用统计
|
||||
*/
|
||||
/*应用使用记录*/
|
||||
public static final String APP_USAGE_RECORD = "appUsageRecord";
|
||||
|
||||
/**
|
||||
* 应用
|
||||
*/
|
||||
/*正在运行的应用*/
|
||||
public static final String RUN_NEW_APP = "app/runNewApp";
|
||||
|
||||
/**
|
||||
* 桌面布局
|
||||
*/
|
||||
/*更新桌面布局*/
|
||||
public static final String UPDATE_DESKTOP_LAYOUT = "updateDesktopLayout";
|
||||
/*获取桌面布局*/
|
||||
public static final String GET_DESKTOP_LAYOUT = "getDesktopLayout";
|
||||
|
||||
/**
|
||||
* 同城活动
|
||||
*/
|
||||
/*同城活动列表*/
|
||||
public static final String GET_ACTIVITY_LIST = "activityList";
|
||||
|
||||
/**
|
||||
* 服务需求
|
||||
*/
|
||||
/*同城需求列表*/
|
||||
public static final String GET_DEMAND_LIST = "demandList";
|
||||
|
||||
/**
|
||||
* 闹钟
|
||||
*/
|
||||
/*添加闹钟*/
|
||||
public static final String ALARM_CLOCK_ADD = "AlarmClock/alarmClockAdd";
|
||||
/*编辑闹钟*/
|
||||
public static final String ALARM_CLOCK_EDIT = "AlarmClock/alarmClockEdit";
|
||||
/*编号查询闹钟*/
|
||||
public static final String ALARM_CLOCK_BY_ID = "AlarmClock/alarmClockById";
|
||||
/*删除闹钟*/
|
||||
public static final String ALARM_CLOCK_DELETE = "AlarmClock/alarmClockDelete";
|
||||
/*获取闹钟*/
|
||||
public static final String GET_ALARM_CLOCK = "getAlarmClock";
|
||||
|
||||
/**
|
||||
* 养生视频分类
|
||||
*/
|
||||
/*养生视频列表*/
|
||||
public static final String GET_LIVEN_VIDEO_LIST = "livenVideo/getLivenVideoList";
|
||||
/*知识视频列表*/
|
||||
public static final String GET_KNOWLEDGE_VIDEO_LIST = "knowledgeVideo/getKnowledgeVideoList";
|
||||
/*养生资讯分类*/
|
||||
public static final String ARTICLE_CATEGORYS = "article/categorys";
|
||||
|
||||
/**
|
||||
* 商品购买
|
||||
*/
|
||||
/*商品下单*/
|
||||
public static final String GOODS_BUY = "goods/buy";
|
||||
/*商品调起支付*/
|
||||
public static final String ORDER_PAY = "pay/order-pay";
|
||||
/*商品支付查询(低频轮询)*/
|
||||
public static final String ORDER_PAY_CHECK = "pay/order-pay-check";
|
||||
|
||||
/**
|
||||
* 公共接口
|
||||
*/
|
||||
/*获取省市区数据*/
|
||||
public static final String REGION_LIST = "common/region-list";
|
||||
/*获取企业客服*/
|
||||
public static final String SERVE_PIC = "common/serve";
|
||||
|
||||
|
||||
/**
|
||||
* 订单管理
|
||||
*/
|
||||
/*订单列表*/
|
||||
public static final String ORDER_INDEX = "order/index";
|
||||
/*订单详情*/
|
||||
public static final String ORDER_SHOW = "order/show";
|
||||
/*订单物流查询*/
|
||||
public static final String ORDER_EXPRESS = "order/express";
|
||||
|
||||
/**
|
||||
* 用户地址
|
||||
*/
|
||||
/*用户地址列表*/
|
||||
public static final String ADDRESS_INDEX = "address/index";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*逆地理编码*/
|
||||
@Deprecated
|
||||
public static final String GEOCODING = "geocoding/v3/";
|
||||
|
||||
/*城市搜索*/
|
||||
public static final String CITY_LOOKUP = "v2/city/lookup";
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xxpatx.os.network.api.amap;
|
||||
|
||||
import com.xxpatx.os.bean.BaiduMapGeoBean;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GeocodingApi {
|
||||
@GET(UrlAddress.GEOCODING)
|
||||
Observable<BaiduMapGeoBean> geocoding(
|
||||
@Query("address") String address,
|
||||
@Query("output") String output,
|
||||
@Query("ak") String key
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xxpatx.os.network.api.qweather;
|
||||
|
||||
import com.xxpatx.os.bean.QweatherLookup;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface LookupApi {
|
||||
@GET(UrlAddress.CITY_LOOKUP)
|
||||
Observable<QweatherLookup> lookup(
|
||||
@Query("location") String location,
|
||||
@Query("key") String key
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.ActivityBean;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ActivityListApi {
|
||||
@GET(UrlAddress.GET_ACTIVITY_LIST)
|
||||
Observable<BaseResponse<List<ActivityBean>>> getActivityList(
|
||||
@Query("sn") String sn,
|
||||
@Query("startSize") int startSize,
|
||||
@Query("pageSize") int pageSize,
|
||||
@Query("user_id") int user_id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.AddressInfo;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface AddressIndexApi {
|
||||
@GET(UrlAddress.ADDRESS_INDEX)
|
||||
Observable<BaseResponse<List<AddressInfo>>> getAddressList(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface AppUsageRecordApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.APP_USAGE_RECORD)
|
||||
Observable<BaseResponse> sendappUsageRecord(
|
||||
@Field("sn") String sn,
|
||||
@Field("app_name") String app_name,
|
||||
@Field("app_package") String app_package,
|
||||
@Field("open_time") long open_time,
|
||||
@Field("close_time") long close_time
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.ArticleList;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ArticleCategorysListApi {
|
||||
@GET(UrlAddress.GET_ARTICLE_LIST)
|
||||
Observable<BaseResponse<ArticleList>> getArticleList(
|
||||
@Query("sn") String sn,
|
||||
@Query("article_type") int articleType
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.ArticleDetails;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ArticleDetailsApi {
|
||||
@GET(UrlAddress.GET_ARTICLE_DETAILS)
|
||||
Observable<BaseResponse<ArticleDetails>> getArticleDetails(
|
||||
@Query("id") int id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.ArticleList;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ArticleListApi {
|
||||
@GET(UrlAddress.GET_ARTICLE_LIST)
|
||||
Observable<BaseResponse<ArticleList>> getArticleList(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.CategoryBean;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface CategorysApi {
|
||||
@GET(UrlAddress.ARTICLE_CATEGORYS)
|
||||
Observable<BaseResponse<List<CategoryBean>>> getArticleCategorys(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.DemandBean;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface DemandListApi {
|
||||
@GET(UrlAddress.GET_DEMAND_LIST)
|
||||
Observable<BaseResponse<List<DemandBean>>> getDemandList(
|
||||
@Query("sn") String sn,
|
||||
@Query("startSize") int startSize,
|
||||
@Query("pageSize") int pageSize,
|
||||
@Query("user_id") int user_id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetAdminSnSettingApi {
|
||||
@GET(UrlAddress.GET_ADMIN_SN_SETTING)
|
||||
Observable<BaseResponse> getAdminSnSetting(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.Contact;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetMailList {
|
||||
@GET(UrlAddress.GET_MAIL_LIST)
|
||||
Observable<BaseResponse<List<Contact>>> getContact(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.UserId;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetUserIDApi {
|
||||
@GET(UrlAddress.GET_USER_ID)
|
||||
Observable<BaseResponse<UserId>> getUserID(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.GoodsDetails;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GoodsDetailsApi {
|
||||
@GET(UrlAddress.GET_GOODS_DETAILS)
|
||||
Observable<BaseResponse<GoodsDetails>> getGoodsDetails(
|
||||
@Query("id") int id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.GoodsList;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GoodsListApi {
|
||||
@GET(UrlAddress.GET_GOODS_LIST)
|
||||
Observable<BaseResponse<GoodsList>> getGoodsList(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.GoodsType;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
|
||||
public interface GoodsTypeApi {
|
||||
@GET(UrlAddress.GOODS_TYPE_LIST)
|
||||
Observable<BaseResponse<List<GoodsType>>> getGoodsTypeList(
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.GoodsList;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GoodsTypeListApi {
|
||||
@GET(UrlAddress.GET_GOODS_LIST)
|
||||
Observable<BaseResponse<GoodsList>> getGoodsList(
|
||||
@Query("sn") String sn,
|
||||
@Query("goods_type") int goodsType
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.HealthCode;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface HealthCodeApi {
|
||||
@GET(UrlAddress.GET_HEALTH_CODE)
|
||||
Observable<BaseResponse<List<HealthCode>>> getArticleDetails(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.uiui.video.bean.VideoInfo;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface KnowledgeVideoListApi {
|
||||
@GET(UrlAddress.GET_KNOWLEDGE_VIDEO_LIST)
|
||||
Observable<BaseResponse<ArrayList<VideoInfo>>> getKnowledgeVideoList(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.RegionInfo;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface RegionListApi {
|
||||
@GET(UrlAddress.REGION_LIST)
|
||||
Observable<BaseResponse<List<RegionInfo>>> getRegionList(
|
||||
@Query("parent_id") String parent_id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.RegionInfo;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface RegionListCall {
|
||||
@GET(UrlAddress.REGION_LIST)
|
||||
Flowable<BaseResponse<List<RegionInfo>>> getRegionList(
|
||||
@Query("parent_id") String parent_id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.ServeBean;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ServeApi {
|
||||
@GET(UrlAddress.SERVE_PIC)
|
||||
Observable<BaseResponse<ServeBean>> getServe(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface UpdateAppIconApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.APP_ICON_UPDATE)
|
||||
Observable<BaseResponse> appIconUpdate(
|
||||
@Field("sn") String sn,
|
||||
@Field("app_package") String app_package,
|
||||
@Field("type") int type,//类型 1显示 0隐藏
|
||||
@Field("app_name") String app_name
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xxpatx.os.network.api.uiui;
|
||||
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.UserAvatarInfo;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface UserInfoControl {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.GET_USER_AVATAR_INFO)
|
||||
Observable<BaseResponse<UserAvatarInfo>> getUserAvatarInfo(
|
||||
@Field("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xxpatx.os.network.api.uiui.alarmclock;
|
||||
|
||||
import com.xxpatx.os.bean.AlarmClockId;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import okhttp3.MultipartBody;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Part;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
public interface AlarmClockAddApi {
|
||||
@Multipart
|
||||
@POST(UrlAddress.ALARM_CLOCK_ADD)
|
||||
Observable<BaseResponse<AlarmClockId>> addAlarmClock(
|
||||
@QueryMap Map<String, String> params,
|
||||
@Part MultipartBody.Part body
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xxpatx.os.network.api.uiui.alarmclock;
|
||||
|
||||
import com.xxpatx.os.alarm.AlarmClockData;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface AlarmClockApi {
|
||||
@GET(UrlAddress.GET_ALARM_CLOCK)
|
||||
Observable<BaseResponse<List<AlarmClockData>>> getAlarmClock(
|
||||
@Query("sn") String sn,
|
||||
@Query("class") int clazz
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui.alarmclock;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface AlarmClockDeleteApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.ALARM_CLOCK_DELETE)
|
||||
Observable<BaseResponse> alarmClockDelete(
|
||||
@Field("sn") String sn,
|
||||
@Field("id") int id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.xxpatx.os.network.api.uiui.alarmclock;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import okhttp3.MultipartBody;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Part;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
public interface AlarmClockEditApi {
|
||||
@Multipart
|
||||
@POST(UrlAddress.ALARM_CLOCK_EDIT)
|
||||
Observable<BaseResponse> editAlarmClock(
|
||||
@QueryMap Map<String, String> params,
|
||||
@Part MultipartBody.Part body
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xxpatx.os.network.api.uiui.alarmclock;
|
||||
|
||||
import com.xxpatx.os.alarm.AlarmClockData;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface AlarmClockQueryApi {
|
||||
@GET(UrlAddress.ALARM_CLOCK_BY_ID)
|
||||
Observable<BaseResponse<AlarmClockData>> getAlarmClockById(
|
||||
@Query("sn") String sn,
|
||||
@Query("id") int id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui.app;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface RunNewApp {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.RUN_NEW_APP)
|
||||
Observable<BaseResponse> sendRunningInfo(
|
||||
@Field("sn") String sn,
|
||||
@Field("app") String app
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.xxpatx.os.network.api.uiui.contact;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import okhttp3.MultipartBody;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Part;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
public interface MailListAddApi {
|
||||
@Multipart
|
||||
@POST(UrlAddress.MAIL_LIST_ADD)
|
||||
Observable<BaseResponse> addMailList(
|
||||
@QueryMap Map<String, String> params,
|
||||
@Part MultipartBody.Part body
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui.contact;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface MailListDeleteApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.MAIL_LIST_DELETE)
|
||||
Observable<BaseResponse> deleteMailList(
|
||||
@Field("sn") String sn,
|
||||
@Field("id") String id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.xxpatx.os.network.api.uiui.contact;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import okhttp3.MultipartBody;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Part;
|
||||
import retrofit2.http.QueryMap;
|
||||
|
||||
public interface MailListEditApi {
|
||||
@Multipart
|
||||
@POST(UrlAddress.MAIL_LIST_EDIT)
|
||||
Observable<BaseResponse> editContact(
|
||||
@QueryMap Map<String, String> params,
|
||||
@Part MultipartBody.Part body
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui.desktop;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.NetDesktopIcon;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetDesktopApi {
|
||||
@GET(UrlAddress.GET_DESKTOP_LAYOUT)
|
||||
Observable<BaseResponse<List<NetDesktopIcon>>> getDesktopLayout(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui.desktop;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface UpdateDesktopApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.UPDATE_DESKTOP_LAYOUT)
|
||||
Observable<BaseResponse> updateLayout(
|
||||
@Field("sn") String sn,
|
||||
@Field("app") String app
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui.liven;
|
||||
|
||||
import com.uiui.video.bean.VideoInfo;
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface LivenVideoListApi {
|
||||
@GET(UrlAddress.GET_LIVEN_VIDEO_LIST)
|
||||
Observable<BaseResponse<ArrayList<VideoInfo>>> getLivenVideoList(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xxpatx.os.network.api.uiui.order;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.OrderIndexData;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface AllOrderApi {
|
||||
@GET(UrlAddress.ORDER_INDEX)
|
||||
Observable<BaseResponse<OrderIndexData>> getOrderIndex(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui.order;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.ExpressData;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface OrderExpressApi {
|
||||
@GET(UrlAddress.ORDER_EXPRESS)
|
||||
Observable<BaseResponse<ExpressData>> getOrderExpress(
|
||||
@Query("sn") String sn,
|
||||
@Query("order_sn") String order_sn,
|
||||
@Query("order_id") String order_id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xxpatx.os.network.api.uiui.order;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.OrderIndexData;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface OrderIndexApi {
|
||||
@GET(UrlAddress.ORDER_INDEX)
|
||||
Observable<BaseResponse<OrderIndexData>> getOrderIndex(
|
||||
@Query("sn") String sn,
|
||||
@Query("status") int status
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xxpatx.os.network.api.uiui.pay;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.OrderBean;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.PartMap;
|
||||
|
||||
public interface GoodsBuyApi {
|
||||
@Multipart
|
||||
@POST(UrlAddress.GOODS_BUY)
|
||||
Observable<BaseResponse<OrderBean>> goodsBuy(
|
||||
@PartMap Map<String, RequestBody> params
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xxpatx.os.network.api.uiui.pay;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.WxpayBean;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface OrderPayApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.ORDER_PAY)
|
||||
Observable<BaseResponse<WxpayBean>> orderPay(
|
||||
@Field("sn") String sn,
|
||||
@Field("order_sn") String order_sn,
|
||||
@Field("order_id") String order_id,
|
||||
@Field("desktop_app_package") String desktop_app_package
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xxpatx.os.network.api.uiui.pay;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface OrderPayCheckApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.ORDER_PAY_CHECK)
|
||||
Observable<BaseResponse> checkOrder(
|
||||
@Field("sn") String sn,
|
||||
@Field("order_sn") String order_sn,
|
||||
@Field("order_id") String order_id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xxpatx.os.network.api.uiui.sn;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.FamilyAddress;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface FamilyAddressApi {
|
||||
@GET(UrlAddress.FAMILY_ADDRESS)
|
||||
Observable<BaseResponse<FamilyAddress>> getFamilyAddress(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xxpatx.os.network.api.uiui.sn;
|
||||
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import okhttp3.MultipartBody;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Part;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface SendScreenshotApi {
|
||||
@Multipart
|
||||
@POST(UrlAddress.SEND_SCREENSHOT)
|
||||
Observable<BaseResponse> sendScreenshot(
|
||||
@Query("sn") String sn,
|
||||
@Part MultipartBody.Part file
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xxpatx.os.network.api.uiui.sn;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.SystemSettings;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface SettingApi {
|
||||
@GET(UrlAddress.GET_SETTINGS)
|
||||
Observable<BaseResponse<SystemSettings>> getSetting(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xxpatx.os.network.api.uiui.sn;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.bean.SnInfo;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface SnInfoApi {
|
||||
@GET(UrlAddress.SNINFO)
|
||||
Observable<BaseResponse<SnInfo>> getSninfo(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xxpatx.os.network.api.uiui.sn;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface SosRecordApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.SOS_RECORD)
|
||||
Observable<BaseResponse> sendSosRecord(
|
||||
@Field("sn") String sn,
|
||||
@Field("longitude") String longitude,
|
||||
@Field("latitude") String latitude,
|
||||
@Field("address") String address
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xxpatx.os.network.api.uiui.sn;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface UpdateAddressApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.UPDATE_ADDRESS)
|
||||
Observable<BaseResponse> updateAddress(
|
||||
@Field("sn") String sn,
|
||||
@Field("address") String address,
|
||||
@Field("longitude") double longitude,
|
||||
@Field("latitude") double latitude
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xxpatx.os.network.api.uiui.sn;
|
||||
|
||||
import com.xxpatx.os.bean.BaseResponse;
|
||||
import com.xxpatx.os.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface UpdateAlarmClockApi {
|
||||
@FormUrlEncoded
|
||||
@POST(UrlAddress.UPDATE_ALARM_CLOCK)
|
||||
Observable<BaseResponse> updateAlarm(
|
||||
@Field("sn") String sn,
|
||||
@Field("id") int id
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.xxpatx.os.network.interceptor;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.xxpatx.os.BuildConfig;
|
||||
import com.xxpatx.os.utils.MD5Util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Protocol;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import okio.Buffer;
|
||||
|
||||
/**
|
||||
* v1.0 2022-07-15 16:16:52
|
||||
*/
|
||||
public class RepeatRequestInterceptor implements Interceptor {
|
||||
private static final String TAG = RepeatRequestInterceptor.class.getSimpleName();
|
||||
|
||||
private final ConcurrentHashMap<String, Long> requestIdsMap = new ConcurrentHashMap<>();
|
||||
public static final String REPEAT_REQUEST_PROTOCOL = "OKHTTP_REPEAT_REQUEST_PROTOCOL";
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Response intercept(@NotNull Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
Response response = chain.proceed(request);
|
||||
ResponseBody responseBody = response.body();
|
||||
|
||||
//会消费请求,导致请求多次
|
||||
String content = responseBody.string();
|
||||
// Response copy = response.newBuilder().body(responseBody).build();
|
||||
ResponseBody copy = ResponseBody.create(responseBody.contentType(), content);
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (content.length() < 1024) {
|
||||
Log.e(TAG, "请求体返回:| Response: " + request.url() + "\t body: " + content);
|
||||
}else {
|
||||
Log.e(TAG, "请求体返回:| Response: " + request.url() + "\t body: too long" );
|
||||
}
|
||||
}
|
||||
//相同的请求
|
||||
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString() + requestBodyToString(request.body()));
|
||||
long time = System.currentTimeMillis();//请求时间
|
||||
try {
|
||||
if (requestIdsMap.size() > 0 && requestIdsMap.containsKey(requestKey)) {
|
||||
log("重复请求:", requestKey, request);
|
||||
//下面这行写了不会抛出onerror
|
||||
// chain.call().cancel();
|
||||
return new Response.Builder()
|
||||
.protocol(Protocol.get(REPEAT_REQUEST_PROTOCOL))
|
||||
.request(request) //multi thread
|
||||
.build();
|
||||
}
|
||||
requestIdsMap.put(requestKey, time);
|
||||
log("注册请求:", requestKey, request);
|
||||
// RepeatRequestInterceptor.Builder builder = request.newBuilder();
|
||||
// builder.addHeader("header", jsonObject.toString());
|
||||
return response.newBuilder().body(copy).build();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "intercept: " + e.getMessage());
|
||||
throw e;
|
||||
} finally {
|
||||
if (requestIdsMap.containsKey(requestKey) && requestIdsMap.containsValue(time)) {//请求任务完成删除map中的数据
|
||||
requestIdsMap.remove(requestKey);
|
||||
log("移除请求:", requestKey, request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void log(String action, String requestKey, Request request) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.e("REPEAT-REQUEST", action + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url().encodedPath() + "\t" + bodyToString(request));
|
||||
} else {
|
||||
Log.e("REPEAT-REQUEST", action + requestKey + " Method @" + request.method());
|
||||
}
|
||||
}
|
||||
|
||||
private static String bodyToString(final Request request) {
|
||||
try {
|
||||
final Request copy = request.newBuilder().build();
|
||||
final Buffer buffer = new Buffer();
|
||||
copy.body().writeTo(buffer);
|
||||
if (buffer.size() > 1024) {
|
||||
return "-too long";
|
||||
}
|
||||
return buffer.readUtf8();
|
||||
} catch (Exception e) {
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
|
||||
private static String requestBodyToString(RequestBody body) {
|
||||
try {
|
||||
final Buffer buffer = new Buffer();
|
||||
body.writeTo(buffer);
|
||||
if (buffer.size() > 1024) {
|
||||
return "-too long";
|
||||
}
|
||||
return buffer.readUtf8();
|
||||
} catch (Exception e) {
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user