version:1.1
fix: update:迁移到UIUISOS
This commit is contained in:
1076
app/src/main/java/com/uiuios/aios/network/NetInterfaceManager.java
Normal file
1076
app/src/main/java/com/uiuios/aios/network/NetInterfaceManager.java
Normal file
File diff suppressed because it is too large
Load Diff
50
app/src/main/java/com/uiuios/aios/network/URLAddress.java
Normal file
50
app/src/main/java/com/uiuios/aios/network/URLAddress.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package com.uiuios.aios.network;
|
||||
|
||||
public class URLAddress {
|
||||
public static final String ROOT_URL = "https://led.zuoyepad.com/android/";
|
||||
/*设备信息接口*/
|
||||
public static final String SNINFO = "sn/getSnInfo";
|
||||
/*获取用户头像和信息*/
|
||||
public static final String GET_USER_AVATAR_INFO = "sn/getUserAvatarInfo";
|
||||
/*获取闹钟*/
|
||||
public static final String GET_ALARM_CLOCK = "getAlarmClock";
|
||||
/*应用使用记录*/
|
||||
public static final String APP_USAGE_RECORD = "appUsageRecord";
|
||||
/*正在运行的应用*/
|
||||
public static final String RUN_NEW_APP = "app/runNewApp";
|
||||
/*上传截图*/
|
||||
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_ALARM_CLOCK = "updateAlarmClock";
|
||||
/*更新桌面布局*/
|
||||
public static final String UPDATE_DESKTOP_LAYOUT = "updateDesktopLayout";
|
||||
/*获取桌面布局*/
|
||||
public static final String GET_DESKTOP_LAYOUT = "getDesktopLayout";
|
||||
/*获取抢购列表*/
|
||||
public static final String GET_GOODS_LIST = "getGoodsList";
|
||||
/*获取资讯列表*/
|
||||
public static final String GET_ARTICLE_LIST = "getArticleList";
|
||||
/*获取抢购详情*/
|
||||
public static final String GET_GOODS_DETAILS = "getGoodsDetails";
|
||||
/*获取资讯详情*/
|
||||
public static final String GET_ARTICLE_DETAILS = "getArticleDetails";
|
||||
/*同城活动列表*/
|
||||
public static final String GET_ACTIVITY_LIST = "activityList";
|
||||
/*同城需求列表*/
|
||||
public static final String GET_DEMAND_LIST = "demandList";
|
||||
/*获取健康吗*/
|
||||
public static final String GET_HEALTH_CODE = "getHealthCode";
|
||||
/*获取联系人*/
|
||||
public static final String GET_MAIL_LIST = "Control/getMailList";
|
||||
/*获取负二屏开关*/
|
||||
public static final String GET_ADMIN_SN_SETTING = "getAdminSnSetting";
|
||||
|
||||
|
||||
|
||||
public static final String GET_USER_ID = "getUserId";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.ActivityBean;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.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.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.AlarmClockData;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.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>>> getAlarmClockApiApi(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.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,16 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.ArticleDetails;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.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,18 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.ArticleInfo;
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.network.URLAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ArticleListApi {
|
||||
@GET(URLAddress.GET_ARTICLE_LIST)
|
||||
Observable<BaseResponse<List<ArticleInfo>>> getArticleList(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.DemandBean;
|
||||
import com.uiuios.aios.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.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.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.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.NetDesktopIcon;
|
||||
import com.uiuios.aios.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.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.Contact;
|
||||
import com.uiuios.aios.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.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.UserId;
|
||||
import com.uiuios.aios.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.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.GoodsDetails;
|
||||
import com.uiuios.aios.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,18 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.GoodsInfo;
|
||||
import com.uiuios.aios.network.URLAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GoodsListApi {
|
||||
@GET(URLAddress.GET_GOODS_LIST)
|
||||
Observable<BaseResponse<List<GoodsInfo>>> getGoodsList(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.HealthCode;
|
||||
import com.uiuios.aios.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
|
||||
);
|
||||
}
|
||||
18
app/src/main/java/com/uiuios/aios/network/api/RunNewApp.java
Normal file
18
app/src/main/java/com/uiuios/aios/network/api/RunNewApp.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.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
|
||||
);
|
||||
}
|
||||
16
app/src/main/java/com/uiuios/aios/network/api/SNInfoApi.java
Normal file
16
app/src/main/java/com/uiuios/aios/network/api/SNInfoApi.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.SnInfo;
|
||||
import com.uiuios.aios.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.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.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,21 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.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
|
||||
);
|
||||
}
|
||||
16
app/src/main/java/com/uiuios/aios/network/api/Setting.java
Normal file
16
app/src/main/java/com/uiuios/aios/network/api/Setting.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.SystemSettings;
|
||||
import com.uiuios.aios.network.URLAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface Setting {
|
||||
@GET(URLAddress.GET_SETTINGS)
|
||||
Observable<BaseResponse<SystemSettings>> getSetting(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.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,18 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.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,19 @@
|
||||
package com.uiuios.aios.network.api;
|
||||
|
||||
|
||||
import com.uiuios.aios.bean.BaseResponse;
|
||||
import com.uiuios.aios.bean.UserAvatarInfo;
|
||||
import com.uiuios.aios.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,85 @@
|
||||
package com.uiuios.aios.network.interceptor;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.uiuios.aios.BuildConfig;
|
||||
import com.uiuios.aios.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.Response;
|
||||
import okio.Buffer;
|
||||
|
||||
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(chain.request());
|
||||
String content = response.body().string();
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.e(TAG, "请求体返回:| Response:" + content);
|
||||
//相同的请求
|
||||
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString() + 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 chain.proceed(request);
|
||||
} 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() > 4096) {
|
||||
return "-too long";
|
||||
}
|
||||
return buffer.readUtf8();
|
||||
} catch (Exception e) {
|
||||
return "-" + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user