diff --git a/app/src/main/java/org/ntlab/amaryllis/client/LoginActivity.java b/app/src/main/java/org/ntlab/amaryllis/client/LoginActivity.java index 8b210d4..8fe1519 100644 --- a/app/src/main/java/org/ntlab/amaryllis/client/LoginActivity.java +++ b/app/src/main/java/org/ntlab/amaryllis/client/LoginActivity.java @@ -10,6 +10,7 @@ import android.widget.Button; import android.widget.EditText; import android.widget.TextView; +import android.widget.Toast; import org.ntlab.amaryllis.client.entities.SignUpJson; import org.ntlab.amaryllis.client.resources.AccountsRest; @@ -50,15 +51,20 @@ call.enqueue(new Callback(){ @Override public void onResponse(Call call, Response response) { - SignUpJson signUpJson =response.body(); - Amaryllis app = (Amaryllis) getApplication(); - app.setToken(signUpJson.getToken()); - app.setUid(nameText.getText().toString()); - app.setPassword(passWordEditText.getText().toString()); - app.setName(nameText.getText().toString()); - Intent intent = new Intent(getApplication(), MainActivity.class); - startActivity(intent); - finish(); + if (response.isSuccessful()) { + SignUpJson signUpJson =response.body(); + Amaryllis app = (Amaryllis) getApplication(); + app.setToken(signUpJson.getToken()); + app.setUid(nameText.getText().toString()); + app.setPassword(passWordEditText.getText().toString()); + app.setName(nameText.getText().toString()); + Intent intent = new Intent(getApplication(), MainActivity.class); + startActivity(intent); + finish(); + }else { + Toast.makeText(LoginActivity.this, + "nameもしくはパスワードが違います", Toast.LENGTH_SHORT).show(); + } } @Override