| |
---|
| | import org.ntlab.radishforandroidstudio.cactusClient.controller.UserLoginController; |
---|
| | |
---|
| | |
---|
| | public class LoginFragment extends Fragment { |
---|
| | private Cactus cactus; |
---|
| | private UserLoginController userLoginController; |
---|
| | private EditText userName; |
---|
| | private EditText passWord; |
---|
| | private boolean isLogin = false; |
---|
| | |
---|
| | // private LoginFragmentConnection connection; |
---|
| | // private Boolean testFlag = false; //trueにすると、通信せずにインスタンス画面へ遷移します。つまり、通信なしでテストするなら"true"にせい |
---|
| | |
---|
| | @Override |
---|
| | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
---|
| | View view = inflater.inflate(R.layout.login_fragment, container, false); |
---|
| | // Inflate the layout for this fragment |
---|
| | FragmentManager manager = getFragmentManager(); |
---|
| | |
---|
| | //サインアップ画面に移動 |
---|
| | Button button = (Button) view.findViewById(R.id.signUP1); |
---|
| | return inflater.inflate(R.layout.login_fragment, container, false); |
---|
| | } |
---|
| | |
---|
| | |
---|
| | public void changeFragment() { |
---|
| | FragmentManager manager = getFragmentManager(); |
---|
| | FragmentTransaction transaction = manager.beginTransaction(); |
---|
| | transaction.replace(R.id.fragment_place, new InstancesFragment()); |
---|
| | transaction.commit(); |
---|
| | |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public void onStart() { |
---|
| | super.onStart(); |
---|
| | |
---|
| | Button button = (Button) getActivity().findViewById(R.id.signUP1); |
---|
| | button.setOnClickListener(new View.OnClickListener() { |
---|
| | @Override |
---|
| | public void onClick(View v) { |
---|
| | //サインアップ画面に移動 |
---|
| | //Toast.makeText(getActivity(), "hoge!", Toast.LENGTH_SHORT).show(); |
---|
| | FragmentManager manager = getFragmentManager(); |
---|
| | FragmentTransaction transaction = manager.beginTransaction(); |
---|
| | transaction.addToBackStack(null); |
---|
| | transaction.replace(R.id.fragment_place, new SignUpFragment()); |
---|
| | transaction.commit(); |
---|
| | } |
---|
| | }); |
---|
| | |
---|
| | //ログイン処理 |
---|
| | Button loginButton = (Button) view.findViewById(R.id.login); |
---|
| | Button loginButton = (Button) getActivity().findViewById(R.id.login); |
---|
| | loginButton.setOnClickListener(new View.OnClickListener() { |
---|
| | @Override |
---|
| | public void onClick(View view) { |
---|
| | userName = (EditText) getActivity().findViewById(R.id.inputUserName); |
---|
| | passWord = (EditText) getActivity().findViewById(R.id.checkPassword); |
---|
| | EditText userName = (EditText) getActivity().findViewById(R.id.inputUserName); |
---|
| | EditText passWord = (EditText) getActivity().findViewById(R.id.checkPassword); |
---|
| | |
---|
| | // /**************************************************************** |
---|
| | // if (testFlag) { |
---|
| | // FragmentManager manager = getFragmentManager(); |
---|
| | // FragmentTransaction transaction = manager.beginTransaction(); |
---|
| | // transaction.replace(R.id.fragment_place, new InstancesFragment()); |
---|
| | // transaction.commit(); |
---|
| | // return; |
---|
| | // } |
---|
| | // **********************************************************************/ |
---|
| | |
---|
| | |
---|
| | if (userName.getText().toString().isEmpty()) { |
---|
| | Toast.makeText(getActivity(), "ユーザー名が未記入です", Toast.LENGTH_SHORT).show(); |
---|
| | return; |
---|
| |
---|
| | Toast.makeText(getActivity(), "パスワードが未記入です", Toast.LENGTH_SHORT).show(); |
---|
| | return; |
---|
| | } |
---|
| | |
---|
| | |
---|
| | //通信処理 |
---|
| | cactus = (Cactus) getActivity().getApplication(); |
---|
| | userLoginController = new UserLoginController(cactus, userName, passWord); |
---|
| | Cactus c = (Cactus) getActivity().getApplication(); |
---|
| | FragmentManager manager = getFragmentManager(); |
---|
| | UserLoginController userLoginController = new UserLoginController(c, userName, passWord, manager); |
---|
| | userLoginController.addFormParam(); |
---|
| | userLoginController.loginResponse(); |
---|
| | |
---|
| | |
---|
| | // userLoginController.login(); |
---|
| | isLogin = userLoginController.login(); |
---|
| | |
---|
| | if (isLogin){ |
---|
| | FragmentManager manager = getFragmentManager(); |
---|
| | FragmentTransaction transaction = manager.beginTransaction(); |
---|
| | transaction.replace(R.id.fragment_place, new InstancesFragment()); |
---|
| | transaction.commit(); |
---|
| | System.out.println("成功"); |
---|
| | |
---|
| | userLoginController.addUserFormParam(); |
---|
| | |
---|
| | }else{ |
---|
| | System.out.println("失敗"); |
---|
| | |
---|
| | } |
---|
| | } |
---|
| | }); |
---|
| | |
---|
| | return view; |
---|
| | } |
---|
| | |
---|
| | |
---|
| | |
---|
| | } |
---|
| | |
---|
| | |