我正在使用Odoo服务来获取我的网络数据。在主类我有一个读取数据的方法:
public void OdooRead() {
OdooService.getCustomers(odoo, "myCallbackFunction");
}
所以,我确实创建了另一个类来提供这项服务:
public class OdooService {
public static final String[] odooAllFields = {"id","name","customer_account_number","customer_group_id","segment_id","subsegment_id","economic_group_id","type_stablishment_id","street","street2","final_user","final_taxpayer","cnpj_cpf","inscr_est","ccm","cnae","phone","phone_extension","mobile","fax","email","email_extra","website","lang"};
public static List<Customer> getCustomers(OdooClient client, "myCallbackFunction") {
List<Customer> list = new ArrayList<>();
ODomain domain = new ODomain();
OdooFields odooFields = new OdooFields();
odooFields.addAll(odooAllFields);
String sorting = "id ASC";
int offset = 0;
int limit = 0;
client.searchRead("res.partner", domain, odooFields, offset, limit, sorting, new IOdooResponse() {
@Override
public void onResult(OdooResult result) {
// HERE I WANTS CALL THE CALLBACK FUNCTION TO MAIN!
}
});
return list;
}
}
因此,当方法返回web上的搜索结果时,我想向main发送一个回调函数,结果列表作为参数。而在此期间,主类正常运行,当方法完成时我刷新用户界面。