| | package org.ntlab.radishforandroidstudio.cactusClient.views; |
---|
| | |
---|
| | |
---|
| | import android.os.Bundle; |
---|
| | import android.support.v4.app.Fragment; |
---|
| | import android.support.v4.app.FragmentManager; |
---|
| |
---|
| | import android.view.ViewGroup; |
---|
| | import android.widget.Button; |
---|
| | import android.widget.EditText; |
---|
| | import android.widget.Toast; |
---|
| | import net.arnx.jsonic.JSON; |
---|
| | import org.ntlab.radishforandroidstudio.R; |
---|
| | import org.ntlab.radishforandroidstudio.cactusClient.connections.SignUpFragmentConnection; |
---|
| | import org.ntlab.radishforandroidstudio.cactusClient.models.URIAddressedEntity; |
---|
| | import org.ntlab.radishforandroidstudio.framework.network.CallBack; |
---|
| | |
---|
| | public class SignUpFragment extends Fragment { |
---|
| | private SignUpFragmentConnection connection; |
---|
| | |
---|
| | @Override |
---|
| | public View onCreateView(LayoutInflater inflater, ViewGroup container, |
---|
| | Bundle savedInstanceState) { |
---|
| |
---|
| | |
---|
| | //↓↓↓↓↓↓↓↓画面遷移↓↓↓↓↓↓↓↓ |
---|
| | @Override |
---|
| | public void onStart() { |
---|
| | |
---|
| | super.onStart(); |
---|
| | |
---|
| | //ログインボタン |
---|
| | Button button = (Button) getActivity().findViewById(R.id.LoginButton2); |
---|
| | button.setOnClickListener(new View.OnClickListener() { |
---|
| | |
---|
| | @Override |
---|
| |
---|
| | transaction.commit(); |
---|
| | } |
---|
| | }); |
---|
| | |
---|
| | Button sihnupButton = (Button) getActivity().findViewById(R.id.signUp2); |
---|
| | sihnupButton.setOnClickListener(new View.OnClickListener(){ |
---|
| | //サインアップ |
---|
| | Button signUpButton = (Button) getActivity().findViewById(R.id.signUp2); |
---|
| | signUpButton.setOnClickListener(new View.OnClickListener(){ |
---|
| | @Override |
---|
| | public void onClick(View view) { |
---|
| | EditText inputPassword = (EditText)getActivity().findViewById(R.id.inputPassword2); |
---|
| | EditText checkPassWord = (EditText)getActivity().findViewById(R.id.checkPassword); |
---|
| | EditText inputUserName = (EditText)getActivity().findViewById(R.id.inputUserName); |
---|
| | EditText inputUserID = (EditText)getActivity().findViewById(R.id.inputUserID); |
---|
| | |
---|
| | String strInputPassword = EditTextChangeToString(inputPassword); |
---|
| | String strCheckPassWord = EditTextChangeToString(checkPassWord); |
---|
| | |
---|
| | if (strInputPassword.isEmpty()) { |
---|
| | if (inputPassword.getText().toString().isEmpty()) { |
---|
| | Toast.makeText(getActivity(), "パスワードを入力してください", Toast.LENGTH_SHORT).show(); |
---|
| | } else if (strCheckPassWord.isEmpty()) { |
---|
| | } else if (checkPassWord.getText().toString().isEmpty()) { |
---|
| | Toast.makeText(getActivity(), "確認用パスワードを入力してください", Toast.LENGTH_SHORT).show(); |
---|
| | } else if (!strInputPassword.equals(strCheckPassWord )) { |
---|
| | } else if (!inputPassword.getText().toString().equals(checkPassWord.getText().toString() )) { |
---|
| | Toast.makeText(getActivity(), "パスワードが一致しません", Toast.LENGTH_SHORT).show(); |
---|
| | }else{ |
---|
| | Toast.makeText(getActivity(), "アカウント作成に成功しましたね", Toast.LENGTH_SHORT).show(); |
---|
| | |
---|
| | connection = new SignUpFragmentConnection(); |
---|
| | connection.setCallBack(new CallBack() { |
---|
| | @Override |
---|
| | public void onResponse(String response) { |
---|
| | //通信した時の処理を書くのだよ |
---|
| | URIAddressedEntity ac = JSON.decode(response, URIAddressedEntity.class); |
---|
| | |
---|
| | System.out.println(ac.getUri()); |
---|
| | System.out.println(response); |
---|
| | |
---|
| | } |
---|
| | }); |
---|
| | |
---|
| | connection.addFormParam("user_id", inputUserID.getText().toString()); |
---|
| | connection.addFormParam("user_name", inputUserName.getText().toString()); |
---|
| | connection.addFormParam("password", inputPassword.getText().toString()); |
---|
| | connection.doPost(); |
---|
| | Toast.makeText(getActivity(),inputUserID.getText().toString(), Toast.LENGTH_SHORT).show(); |
---|
| | } |
---|
| | } |
---|
| | }); |
---|
| | } |
---|
| | |
---|
| | private static String EditTextChangeToString(EditText text){ |
---|
| | |
---|
| | CharSequence CharSequenceText = text.getText(); |
---|
| | |
---|
| | String str = CharSequenceText.toString(); |
---|
| | |
---|
| | return str; |
---|
| | } |
---|
| | } |
---|
| | |
たのまぁ
たのまぁれた
たのまぁれた
740caf7
intomaster
fromログインの通信
on 12 Jun 2018