Newer
Older
IrisClient / app / src / main / java / org / ntlab / irisclient / OwnerRoomActivity.java
  1. package org.ntlab.irisclient;
  2.  
  3. import android.graphics.Color;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.widget.ArrayAdapter;
  7. import android.widget.Button;
  8. import android.widget.ImageButton;
  9. import android.widget.ListView;
  10. import android.widget.TextView;
  11.  
  12. import androidx.appcompat.app.AppCompatActivity;
  13.  
  14. import org.ntlab.irisclient.resources.RoomsRest;
  15.  
  16. import java.util.ArrayList;
  17. import java.util.Collections;
  18.  
  19. import retrofit2.Call;
  20. import retrofit2.Callback;
  21. import retrofit2.Response;
  22. import retrofit2.Retrofit;
  23. import retrofit2.converter.jackson.JacksonConverterFactory;
  24.  
  25. public class OwnerRoomActivity extends AppCompatActivity {
  26.  
  27. //フィールド
  28. String r = "部屋ID " + "123456";
  29.  
  30. @Override
  31. protected void onCreate(Bundle savedInstanceState) {
  32. super.onCreate(savedInstanceState);
  33. setContentView(R.layout.activity_owner_room);
  34.  
  35. //--------------------------------------------------------------------------
  36. //各ボタン処理
  37. ArrayList<String> members = new ArrayList<>();
  38. Button redMasterButton = (Button) findViewById(R.id.beRedMaster);
  39. Button redSpyButton = (Button) findViewById(R.id.beRedSpy);
  40. Button blueMasterButton = (Button) findViewById(R.id.beBlueMaster);
  41. Button blueSpyButton = (Button) findViewById(R.id.beBlueSpy);
  42. Button randomButton = (Button) findViewById(R.id.random);
  43. Button startButton = (Button) findViewById(R.id.start);
  44. ImageButton copyButton = (ImageButton) findViewById(R.id.copyButton);
  45.  
  46. //---------------------------------------------------------------------------
  47. //メンバーリスト
  48. ArrayAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, members);
  49. ListView listView = (ListView)findViewById(R.id.MembersList);
  50. listView.setAdapter(adapter);
  51.  
  52.  
  53. redMasterButton.setOnClickListener(new View.OnClickListener() {
  54. @Override
  55. public void onClick(View v) {
  56. r = "部屋ID " + "red";
  57. TextView RoomIdText = findViewById(R.id.roomID);
  58. RoomIdText.setText(r);
  59.  
  60. members.clear();
  61. members.add("マスターのRedさん");
  62. ListView listView = (ListView)findViewById(R.id.MembersList);
  63.  
  64. listView.setAdapter(adapter);
  65. }
  66. });
  67.  
  68. redSpyButton.setOnClickListener(new View.OnClickListener() {
  69. @Override
  70. public void onClick(View v) {
  71. r = "部屋ID " + "red";
  72. TextView RoomIdText = findViewById(R.id.roomID);
  73. RoomIdText.setText(r);
  74.  
  75. members.add("スパイのRedさん");
  76. ListView listView = (ListView)findViewById(R.id.MembersList);
  77. listView.setAdapter(adapter);
  78. }
  79. });
  80.  
  81. blueMasterButton.setOnClickListener(new View.OnClickListener() {
  82. @Override
  83. public void onClick(View v) {
  84. r = "部屋ID " + "blue";
  85. TextView RoomIdText = findViewById(R.id.roomID);
  86. RoomIdText.setText(r);
  87.  
  88. members.add("マスターのBlueさん");
  89. listView.setBackgroundColor(Color.parseColor("#e83a48"));
  90. ListView listView = (ListView)findViewById(R.id.MembersList);
  91. listView.setAdapter(adapter);
  92.  
  93. }
  94. });
  95.  
  96. blueSpyButton.setOnClickListener(new View.OnClickListener() {
  97. @Override
  98. public void onClick(View v) {
  99. r = "部屋ID " + "red";
  100. TextView RoomIdText = findViewById(R.id.roomID);
  101. RoomIdText.setText(r);
  102.  
  103. members.add("スパイのBlueさん");
  104. ListView listView = (ListView)findViewById(R.id.MembersList);
  105. listView.setBackgroundColor(Color.parseColor("#3a5fe8"));
  106. listView.setAdapter(adapter);
  107. }
  108. });
  109.  
  110. randomButton.setOnClickListener(new View.OnClickListener() {
  111. @Override
  112. public void onClick(View v) {
  113. r = "部屋ID " + "random";
  114. TextView RoomIdText = findViewById(R.id.roomID);
  115. RoomIdText.setText(r);
  116.  
  117. members.add("ランダムさん");
  118. ListView listView = (ListView)findViewById(R.id.MembersList);
  119. listView.setAdapter(adapter);
  120.  
  121. Retrofit retrofit = new Retrofit.Builder()
  122. .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/iris/")
  123. .addConverterFactory(JacksonConverterFactory.create())
  124. .build();
  125. final RoomsRest roomsRest = retrofit.create(RoomsRest.class);
  126.  
  127. }
  128. });
  129.  
  130. startButton.setOnClickListener(new View.OnClickListener() {
  131. @Override
  132. public void onClick(View v) {
  133. r = "部屋ID " + "start";
  134. TextView RoomIdText = findViewById(R.id.roomID);
  135. RoomIdText.setText(r);
  136.  
  137. members.add("スタートさん");
  138. ListView listView = (ListView)findViewById(R.id.MembersList);
  139. listView.setAdapter(adapter);
  140. }
  141. });
  142.  
  143. copyButton.setOnClickListener(new View.OnClickListener() {
  144. @Override
  145. public void onClick(View v) {
  146. r = "部屋ID " + "copy";
  147. TextView RoomIdText = findViewById(R.id.roomID);
  148. RoomIdText.setText(r);
  149.  
  150. members.add("コピーしました");
  151. ListView listView = (ListView)findViewById(R.id.MembersList);
  152. listView.setAdapter(adapter);
  153. }
  154. });
  155.  
  156. //--------------------------------------------------------------------------
  157. //メンバー表示
  158.  
  159. //members.add("1さん");
  160.  
  161. //---------------------------------------------------------------
  162. //settings情報
  163. String s = "設定\\nお絵描き";
  164. TextView settingsText = findViewById(R.id.settings);
  165. settingsText.setText(s);
  166.  
  167. //---------------------------------------------------------------
  168. //部屋ID情報
  169. TextView RoomIdText = findViewById(R.id.roomID);
  170. RoomIdText.setText(r);
  171. }
  172.  
  173. /*private getMemberInformation(){
  174.  
  175. }*/
  176.  
  177. /*private void addMemberToMemberList(String m){
  178. members.add(m);
  179. }*/
  180. }