diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/controller/UserLoginController.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/controller/UserLoginController.java index 1d1d5b5..bd4f1f9 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/controller/UserLoginController.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/controller/UserLoginController.java @@ -9,45 +9,55 @@ import org.ntlab.radishforandroidstudio.cactusClient.connections.LoginFragmentConnection; import org.ntlab.radishforandroidstudio.cactusClient.models.account.Account; import org.ntlab.radishforandroidstudio.cactusClient.models.account.URIAddressedAccount; +import org.ntlab.radishforandroidstudio.cactusClient.views.LoginFragment; import org.ntlab.radishforandroidstudio.framework.network.CallBack; public class UserLoginController { - private LoginFragmentConnection loginFragmentConnection = new LoginFragmentConnection(); - String userId; - String userPass; - Cactus cactus; + private String userId; + private String userPass; + private Cactus cactus; + private LoginFragmentConnection loginFragmentConnection; + + public UserLoginController(){} public UserLoginController(Cactus cactus, EditText userName, EditText passWord) { + loginFragmentConnection = new LoginFragmentConnection(); this.userId = userName.getText().toString(); this.userPass = passWord.getText().toString(); this.cactus = cactus; } - public UserLoginController() { - } - public boolean login() { + + public void login() { + loginFragmentConnection = new LoginFragmentConnection(); loginFragmentConnection.setCallBack(new CallBack() { @Override public void onResponse(String response) { - URIAddressedAccount uriAddressedAccount = JSON.decode(response, new TypeReference() { - }); + //通信した時の処理を書くのだよ + URIAddressedAccount uriAddressedAccount = JSON.decode(response, new TypeReference(){}); +// System.out.println(response); Account account = uriAddressedAccount.getAccount(); if (account.isLogin()) { cactus.setMyAccount(account);//Cactusにアカウントセット cactus.setAddressedAccount(uriAddressedAccount);//Jsonから + LoginFragment loginFragment = new LoginFragment(); + loginFragment.transFragment(); + System.out.println("ログインに成功しました。"); + + + } else { + System.out.println("ログインに失敗しました。"); + } } }); - return true; - } - - - public void addUserFormParam() { loginFragmentConnection.addFormParam("userID", userId); loginFragmentConnection.addFormParam("userPass", userPass); loginFragmentConnection.doPut(); + } + }