diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a1cd169..3ae40bb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,7 +19,7 @@ android:supportsRtl="true" android:theme="@style/AppTheme"> createGroup = createGroupService.createGroup(groupNameText.getText().toString(), uId, token); + + createGroup.enqueue(new Callback() { + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful()) { + Group result = response.body(); + +// //確認用 +// System.out.println(result.getgId()); +// System.out.println(result.getName()); +// System.out.println(result.getRequests()); +// System.out.println(result.getUri()); + + Toast.makeText(CreateGroupActivity.this, "グループを作成しました", Toast.LENGTH_SHORT).show(); + + finish(); + + } else { + System.out.println(""); + Toast.makeText(CreateGroupActivity.this,"通信エラー",Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onFailure(Call call, Throwable t) { + t.printStackTrace(); + Toast.makeText(CreateGroupActivity.this,"グループ作成失敗",Toast.LENGTH_SHORT); + } + }); + }catch(Exception e){ + e.printStackTrace(); + } + + } + }); + + + + + + + + + } +} diff --git a/app/src/main/java/com/example/cosmosclient/views/MakeGroupActivity.java b/app/src/main/java/com/example/cosmosclient/views/MakeGroupActivity.java deleted file mode 100644 index d3f50e2..0000000 --- a/app/src/main/java/com/example/cosmosclient/views/MakeGroupActivity.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.example.cosmosclient.views; - -import android.support.v7.app.AppCompatActivity; -import android.os.Bundle; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -import android.widget.Toast; - -import com.example.cosmosclient.R; -import com.example.cosmosclient.app.Cosmos; -import com.example.cosmosclient.entities.Group; -import com.example.cosmosclient.resources.GroupsRest; - -import retrofit2.Call; -import retrofit2.Callback; -import retrofit2.Response; -import retrofit2.Retrofit; -import retrofit2.converter.jackson.JacksonConverterFactory; - -public class MakeGroupActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_make_group); - - final EditText groupNameText = findViewById(R.id.groupNameText); - Button createGroupButton = findViewById(R.id.createGroupButton); - String name; - final String uId,token; - - //グループ作成に必要な情報の取得 - Cosmos app = (Cosmos) getApplication(); - uId = app.getuId(); - ////サインアップでトークンが返ってきてないため一時コメントアウト - //token = app.getToken(); - token="abcdef"; - - //retrofitの処理 - final Retrofit retrofit = new Retrofit.Builder() - .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/cosmos/") - .addConverterFactory(JacksonConverterFactory.create()) - .build(); - //interfaceから実装を取得 - final GroupsRest makeGroupService = retrofit.create(GroupsRest.class); - - createGroupButton.setOnClickListener(new View.OnClickListener(){ - @Override - public void onClick(View view){ - try { - Call createGroup = makeGroupService.createGroup(groupNameText.getText().toString(), uId, token); - - createGroup.enqueue(new Callback() { - @Override - public void onResponse(Call call, Response response) { - if (response.isSuccessful()) { - Group result = response.body(); - -// //確認用 -// System.out.println(result.getgId()); -// System.out.println(result.getName()); -// System.out.println(result.getRequests()); -// System.out.println(result.getUri()); - - Toast.makeText(MakeGroupActivity.this, "グループを作成しました", Toast.LENGTH_SHORT).show(); - - finish(); - - } else { - System.out.println(""); - Toast.makeText(MakeGroupActivity.this,"通信エラー",Toast.LENGTH_SHORT).show(); - } - } - - @Override - public void onFailure(Call call, Throwable t) { - t.printStackTrace(); - Toast.makeText(MakeGroupActivity.this,"グループ作成失敗",Toast.LENGTH_SHORT); - } - }); - }catch(Exception e){ - e.printStackTrace(); - } - - } - }); - - - - - - - - - } -} diff --git a/app/src/main/res/layout/activity_make_group.xml b/app/src/main/res/layout/activity_make_group.xml index 7b72ad6..0762055 100644 --- a/app/src/main/res/layout/activity_make_group.xml +++ b/app/src/main/res/layout/activity_make_group.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".views.MakeGroupActivity"> + tools:context=".views.CreateGroupActivity">