SHARE
TWEET

Untitled

a guest May 31st, 2017 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Override
  2.     public void createUserPart(SignUpUser signUpUser, final RestCallback<CreateUserResult> callback) {
  3.         File file = new File(signUpUser.getImagePath());
  4.         RequestBody fileBody = RequestBody.create(MediaType.parse("image/*"), file);
  5.         RequestBody fullName = RequestBody.create(MediaType.parse("text/plain"), signUpUser.getFullName());
  6.         RequestBody email = RequestBody.create(MediaType.parse("text/plain"), signUpUser.getEmail());
  7.         RequestBody username = RequestBody.create(MediaType.parse("text/plain"), signUpUser.getUsername());
  8.         RequestBody password = RequestBody.create(MediaType.parse("text/plain"), signUpUser.getPassword());
  9.         RequestBody desc = RequestBody.create(MediaType.parse("text/plain"), signUpUser.getDescription());
  10.         RequestBody clientId = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(Constants.CLIENT_ID));
  11.         RequestBody clientSecret = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(Constants.CLIENT_SECRET));
  12.  
  13.         Map<String, RequestBody> myMap = new HashMap<>();
  14.         myMap.put("profilePhoto\"; filename=\"" + file.getName(), fileBody);
  15.         myMap.put("name", fullName);
  16.         myMap.put("email", email);
  17.         myMap.put("username", username);
  18.         myMap.put("password", password);
  19.         myMap.put("description", desc);
  20.         myMap.put("client_id", clientId);
  21.         myMap.put("client_secret", clientSecret);
  22.  
  23.         mCallCreateUserPart = App.getRestClient().getApiService().createUserPart(myMap);
  24.         mCallCreateUserPart.enqueue(new Callback<CreateUserResult>() {
  25.             @Override
  26.             public void onResponse(Call<CreateUserResult> call, Response<CreateUserResult> response) {
  27.                 Result<CreateUserResult> result = new Result<>();
  28.                 CreateUserResult createUserResult = response.body();
  29.                 result.setData(createUserResult);
  30.                 callback.onSuccess(result);
  31.             }
  32.  
  33.             @Override
  34.             public void onFailure(Call<CreateUserResult> call, Throwable t) {
  35.  
  36.             }
  37.         });
  38.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top