diff --git a/app/src/main/java/com/example/cosmosclient/views/SignupActivity.java b/app/src/main/java/com/example/cosmosclient/views/SignupActivity.java index 8f21d0c..ea0f04f 100644 --- a/app/src/main/java/com/example/cosmosclient/views/SignupActivity.java +++ b/app/src/main/java/com/example/cosmosclient/views/SignupActivity.java @@ -6,6 +6,7 @@ import android.view.View; import android.widget.Button; import android.widget.EditText; +import android.widget.Toast; import com.example.cosmosclient.R; @@ -19,6 +20,7 @@ import retrofit2.converter.jackson.JacksonConverterFactory; public class SignupActivity extends AppCompatActivity { + public static final String UserInfomation="com.example.cosmosclient.views"; @Override protected void onCreate(Bundle savedInstanceState) { @@ -26,12 +28,12 @@ setContentView(R.layout.activity_signup); //retrofitの処理 - Retrofit retrofit = new Retrofit.Builder() + final Retrofit retrofit = new Retrofit.Builder() .baseUrl("nitta-lab-www.is.konan-u.ac.jp") .addConverterFactory(JacksonConverterFactory.create()) .build(); //interfaceから実装を取得 - Signup signup = retrofit.create(Signup.class); + final Signup signup = retrofit.create(Signup.class); //各種idを取得 @@ -42,32 +44,43 @@ final EditText ConfirmPasswordText = findViewById(R.id.ConfirmPasswordText); - //finalつけないとエラー出る - final Call call = signup.listUser(EmailAddressText.getText().toString(),PasswordText.getText().toString(),"3"); //Make Accountボタンの処理 MakeAccountButton.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ - Intent intent = new Intent(getApplication(), GroupList.class); -// call.enqueue(new Callback() { -// //成功時 -// @Override -// public void onResponse(Call call, Response response) { -// if (response.isSuccessful()) { -// User result = response.body(); -// } -// } -// -// //失敗時 -// @Override -// public void onFailure(Call call, Throwable t) { -// t.printStackTrace(); -// } -// -// }); - startActivity(intent); - finish(); + + //パスワードと確認パスワードが一致していない際の処理 + if(!PasswordText.equals(ConfirmPasswordText)){ + Toast.makeText(SignupActivity.this,"入力されたパスワードが一致しません。",Toast.LENGTH_SHORT); + return; + } + + //API呼び出しのための値入力 + Call call = signup.listUser(EmailAddressText.getText().toString(),PasswordText.getText().toString(),null); + + call.enqueue(new Callback() { + //成功時 + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful()) { + User result = response.body(); + Intent intent = new Intent(getApplication(), GroupList.class); + //intent.putExtra("UserInfomation",result); + startActivity(intent); + finish(); + + } + } + + //失敗時 + @Override + public void onFailure(Call call, Throwable t) { + t.printStackTrace(); + } + + }); + } });