square / retrofit

A type-safe HTTP client for Android and the JVM
https://square.github.io/retrofit/
Apache License 2.0
43.05k stars 7.31k forks source link

How can I make a callback < T > be generic #677

Closed xooder closed 9 years ago

xooder commented 9 years ago

public void verificationCode(String tel, String code, Callback cb) { Map<String, String> param = new HashMap<>(); param.put("userTel", tel); param.put("smsCode", code); request("aam_user_reg_sms_validate_req", param, cb); }

public void sendCode(String tel, Callback cb) { Map<String, String> param = new HashMap<>(); param.put("userTel", tel); request("aam_user_reg_sms_apply_req", param, cb); }

void request(String serviceName, Map param, Callback cb) { Service service = mRestAdapter.create(Service.class); service.request(encryption(serviceName, param), cb); } public interface Service { @FormUrlEncoded @POST("/service/proxy") void request(@Field("jsonRequest") String param, Callback cb); }
JakeWharton commented 9 years ago

Callback is already generic. I think you want to ask this question on StackOverflow with the 'retrofit' tag since it's a usage question and not a feature request or bug report.