平面图上不兼容的类型

时间:2018-12-06 11:27:59

标签: android android-studio flatmap

我试图从平面图中返回ResponseBody,但出现错误:不兼容的类型必需的ResponseBody,但是flatmap被推论为Observable:不存在类型变量R的实例,因此Observable符合ResponseBody

public ResponseBody deleteRecord(String date, Integer id) {
    return connectivityManager.isConnectedToCompanyObservableOnErrorResumeNext()
            .flatMap(isReachable -> {
                List<RecordDB> recordsDb = recordDao.getRecordsByApiType(apiStringList);
                for (RecordDB recordDB : recordsDb) {
                    Record record = RecordDB.convertRecordDBToRecord(recordDB);
                    if (recordDB.isSyncedWithServer()) {
                        if (recordDB.isSyncedWithServer()) {
                            if (isReachable) {
                                return recordsManager.deleteRecord(id);
                            } else {
                                recordDB.setSyncedWithServer(false);
                                recordDB.setApiType(ApiType.DELETE.name());
                                recordDao.insert(recordDB);
                            }
                        } else {
                            if (recordDB.getApiType().equals("POST") || recordDB.getApiType().equals("UPDATE")) {
                                recordDao.delete(recordDB);
                            } else {
                                if (isReachable) {
                                    return recordsManager.deleteRecord(id);
                                } else {
                                    recordDB.setApiType(ApiType.DELETE.name());
                                    recordDB.setSyncedWithServer(false);
                                    recordDao.insert(recordDB);
                                }
                            }
                        }
                    }
                }
                return Observable.empty();
            });
}

这是deleteRecord方法

public Observable<ResponseBody> deleteRecord(long recordId) {
    return apiService.deleteRecord(sessionManager.getAccessToken(), recordId);
}

0 个答案:

没有答案