Newer
Older
CosmosClient / app / src / main / java / com / example / cosmosclient / views / SignupActivity.java
package com.example.cosmosclient.views;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.cosmosclient.R;


import java.util.regex.Pattern;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;

public class SignupActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_signup);

        //retrofitの処理
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("/cosmos")
                .addConverterFactory(JacksonConverterFactory.create())
                .build();
        Signup signup = retrofit.create(Signup.class);


        //各種idを取得
        Button LoginButton = findViewById(R.id.LoginButton);
        Button MakeAccountButton = findViewById(R.id.MakeAccountButton);
        final EditText EmailAddressText = findViewById(R.id.EMailAddressText);
        final EditText PasswordText = findViewById(R.id.PasswordText);
        final EditText ConfirmPasswordText = findViewById(R.id.ConfirmPasswordText);

        //finalつけないとエラー出る
        final Call<User> 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<User>() {
//                    //成功時
//                    @Override
//                    public void onResponse(Call<User> call, Response<User> response) {
//                        if (response.isSuccessful()) {
//                            User result = response.body();
//                        }
//                    }
//
//                    //失敗時
//                    @Override
//                    public void onFailure(Call<User> call, Throwable t) {
//                        t.printStackTrace();
//                    }
//
//                });
                startActivity(intent);
                finish();
            }
        });

        //サインイン画面への遷移処理
        LoginButton.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                Intent intent = new Intent(getApplication(),SigninActivity.class);
                startActivity(intent);
                finish();
            }
        });

    }
}