diff --git a/app/src/main/java/com/example/cosmosclient/views/SigninActivity.java b/app/src/main/java/com/example/cosmosclient/views/SigninActivity.java index 6147454..b75b599 100644 --- a/app/src/main/java/com/example/cosmosclient/views/SigninActivity.java +++ b/app/src/main/java/com/example/cosmosclient/views/SigninActivity.java @@ -6,9 +6,13 @@ import android.view.View; import android.widget.Button; import android.widget.EditText; +import android.widget.Toast; import com.example.cosmosclient.R; +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; import retrofit2.Retrofit; import retrofit2.converter.jackson.JacksonConverterFactory; @@ -27,20 +31,43 @@ Button ForgotPasswordButton = findViewById(R.id.ForgotPasswordButton); //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から実装を取得 - Signin signin = retrofit.create(Signin.class); + final Signin signin = retrofit.create(Signin.class); //Sign inボタンの処理 SigninButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent intent = new Intent(getApplication(), GroupList.class); - startActivity(intent); - finish(); + //Intent intent = new Intent(getApplication(), GroupList.class); + Call call = signin.loginlist(NameText.getText().toString(), PasswordText.getText().toString()); + + call.enqueue(new Callback() { + //成功時 + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful()) { + login 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(); + Toast.makeText(SigninActivity.this, + "ユーザIDもしくはパスワードが間違っています。",Toast.LENGTH_SHORT); + } + + }); } });