Skip to content

Instantly share code, notes, and snippets.

@hectorups
Created August 19, 2014 00:27
Show Gist options
  • Save hectorups/4e5aabb203f44a21135d to your computer and use it in GitHub Desktop.
Save hectorups/4e5aabb203f44a21135d to your computer and use it in GitHub Desktop.
Retrofit use
public interface Api {
@POST("/users/sign_in") Observable<Response> login(@Body Login login);
}
client.login(login)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(new Observer<Response>() {
@Override public void onCompleted() {
}
@Override public void onError(Throwable e) {
}
@Override public void onNext(Response response) {
User user;
try {
user = (User) gsonConverter.fromBody(response.getBody(), User.class);
} catch (Exception e) {
onError(e);
return;
}
//...
}
});
public class Login {
private String email;
private String password;
private String fbToken;
private String gplusToken;
private String audienceToken;
public Login(String email, String password) {
this.email = email;
this.password = password;
}
public Login() {
}
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment