use the http responses directly for object creation
This commit is contained in:
parent
af37f7b307
commit
420b0dff79
3 changed files with 20 additions and 15 deletions
|
|
@ -100,9 +100,10 @@ public class LoginActivity extends AbsBaseActivity implements View.OnClickListen
|
|||
App.getApiClient().ChangeServerLocation(server);
|
||||
App.getApiClient().AuthenticateUserAsync(username, password, new Response<AuthenticationResult>() {
|
||||
@Override
|
||||
public void onResponse(AuthenticationResult result) {
|
||||
if (result.getAccessToken() == null) return;
|
||||
check(server, result.getUser().getId(), result.getAccessToken());
|
||||
public void onResponse(AuthenticationResult authenticationResult) {
|
||||
if (authenticationResult.getAccessToken() != null) {
|
||||
check(authenticationResult);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -119,13 +120,13 @@ public class LoginActivity extends AbsBaseActivity implements View.OnClickListen
|
|||
});
|
||||
}
|
||||
|
||||
private void check(String url, String name, String token) {
|
||||
private void check(AuthenticationResult authenticationResult) {
|
||||
App.getApiClient().GetSystemInfoAsync(new Response<SystemInfo>() {
|
||||
@Override
|
||||
public void onResponse(SystemInfo result) {
|
||||
if (result.getVersion().charAt(0) == '1') {
|
||||
Server server = new Server(result.getServerName(), url);
|
||||
User user = new User(server.id, name, token);
|
||||
Server server = new Server(result);
|
||||
User user = new User(authenticationResult);
|
||||
|
||||
App.getDatabase().serverDao().insertServer(server);
|
||||
App.getDatabase().userDao().insertUser(user);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue