| | |
| | | int uplodFilerepeatSize = 3; |
| | | |
| | | ApiService apiService; |
| | | private CompositeDisposable compositeDisposable = new CompositeDisposable(); // 管理订阅事件 |
| | | // 管理订阅事件 |
| | | private CompositeDisposable compositeDisposable = new CompositeDisposable(); |
| | | |
| | | /** |
| | | * 初始化通信框架 |
| | |
| | | public BaseResponse<T> apply(Object o) { |
| | | if (o instanceof BaseResponse) { |
| | | BaseResponse tem = (BaseResponse) o; |
| | | if (tem.getCode().equals("0000")) { |
| | | if (tem.getCode().equals(Constants.TOKEN_INVALID)) { |
| | | //当code为0000是跳转到登录界面 |
| | | tem.setMsg("登录失效请重新登录"); |
| | | redirectToLogin(); |
| | |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | Observable<ResponseBody> observable; |
| | | observable = apiService.downloadTile(urlPath); |
| | | observable |
| | | .subscribeOn(Schedulers.io()) // 网络请求在 I/O 线程中进行 |
| | | .observeOn(Schedulers.io()) // 回调处理也在 I/O 线程 |
| | | // 网络请求在 I/O 线程中进行 |
| | | .subscribeOn(Schedulers.io()) |
| | | // 回调处理也在 I/O 线程 |
| | | .observeOn(Schedulers.io()) |
| | | .subscribe( |
| | | responseBody -> { |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 判断当前code是否是未登录状态 |
| | | * |
| | | * @param responseBody the response body in JSON format |
| | | * @return true if login is required, false otherwise |
| | | */ |
| | | private boolean isLoginRequired(String responseBody) { |
| | | try { |
| | | Gson gson = new Gson(); |
| | | Map<String, Object> responseMap = gson.fromJson(responseBody, Map.class); |
| | | String code = (String) responseMap.get("code"); |
| | | return "0000".equals(code); // Check if the code is not 0000 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 当code为“0000”时跳转到登录界面 |