diff --git a/app/build.gradle b/app/build.gradle index 40adf01..dbf7c23 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -27,6 +27,8 @@ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' // Retrofit implementation "com.squareup.retrofit2:retrofit:2.5.0" + //Jackson + implementation 'com.squareup.retrofit2:converter-jackson:2.5.0' //QRコードリーダー implementation 'com.journeyapps:zxing-android-embedded:3.6.0' implementation 'com.android.support:design:28.0.0' diff --git a/app/src/main/java/com/example/cosmosclient/views/SignupActivity.java b/app/src/main/java/com/example/cosmosclient/views/SignupActivity.java index 4216f00..451b52f 100644 --- a/app/src/main/java/com/example/cosmosclient/views/SignupActivity.java +++ b/app/src/main/java/com/example/cosmosclient/views/SignupActivity.java @@ -9,6 +9,13 @@ import com.example.cosmosclient.R; + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import retrofit2.Retrofit; +import retrofit2.converter.jackson.JacksonConverterFactory; + public class SignupActivity extends AppCompatActivity { @Override @@ -16,6 +23,16 @@ super.onCreate(savedInstanceState); setContentView(R.layout.activity_signup); + //retrofitの処理 + Retrofit retrofit = new Retrofit.Builder() + .baseUrl("http://cyberjapandata2.gsi.go.jp/") + .addConverterFactory(JacksonConverterFactory.create()) + .build(); + Signup signup = retrofit.create(Signup.class); + + //finalつけないとエラー出る + final Call call = signup.listUser("1d","2d","3"); + //各種idを取得 Button LoginButton = findViewById(R.id.LoginButton); Button MakeAccountButton = findViewById(R.id.MakeAccountButton); @@ -28,6 +45,22 @@ @Override public void onClick(View v){ Intent intent = new Intent(getApplication(), GroupList.class); + call.enqueue(new Callback() { + //成功時 + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful()) { + User result = response.body(); + } + } + + //失敗時 + @Override + public void onFailure(Call call, Throwable t) { + t.printStackTrace(); + } + + }); startActivity(intent); finish(); }