I have a class
like an util
, It contains all preparing and calling requests (I want easily to manage requests). Ex:
public void reqLogin(String emailAddress, String password) {
JsonRequestBody parameters = new JsonRequestBody();
parameters.put(USER_NAME, emailAddress);
parameters.put(PASSWORD, password);
mService.login(parameters.createRequestBody());
}
public void reqRegister(LocationWrapper location) {
JsonRequestBody jsonRequestBody = new JsonRequestBody();
jsonRequestBody.put(DEVICE_TOKEN, "myToken");
jsonRequestBody.put(DEVICE_TOKEN_TYPE, "type");
mService.register(jsonRequestBody.createRequestBody());
}
...
But problem of this design is that in LoginFragment
I can call Register request
, and in RegisterFragment
I can call Login request
. So, is it bad solution to create this util
class? Is there a pattern to solve my issue
?
Aucun commentaire:
Enregistrer un commentaire