diff --git a/app/src/main/java/org/ntlab/irisclient/OwnerRoomActivity.java b/app/src/main/java/org/ntlab/irisclient/OwnerRoomActivity.java index 4f24299..42ef07b 100644 --- a/app/src/main/java/org/ntlab/irisclient/OwnerRoomActivity.java +++ b/app/src/main/java/org/ntlab/irisclient/OwnerRoomActivity.java @@ -36,7 +36,9 @@ //フィールド ArrayList members = new ArrayList<>(); String r;// = "部屋ID " + "123456"; - String nickname; + //String nickname; + String belongs; + Boolean isMaster; String myName = "null"; @Override @@ -44,18 +46,18 @@ super.onCreate(savedInstanceState); setContentView(R.layout.activity_owner_room); - ((Iris) getApplication()).getNickname(); //nickname = "aaa"; - ((Iris) getApplication()).getRid(); //r ="276393b5-d835-4e4c-a35b-c00996c73a2b"; + myName = ((Iris) getApplication()).getNickname(); //nickname = "aaa"; + r = ((Iris) getApplication()).getRid(); //r ="276393b5-d835-4e4c-a35b-c00996c73a2b"; - //--------------------------------------------------------------------------- + //メンバーリスト ListView membersList = (ListView) findViewById(R.id.MembersList); BaseAdapter adapter = new MemberListAdapter(this.getApplicationContext(), R.layout.member_list_layout, members); membersList.setAdapter(adapter); //自分のなまえ - Intent intentMain = getIntent(); - myName = intentMain.getStringExtra("nickname"); + //Intent intentMain = getIntent(); + //myName = intentMain.getStringExtra("nickname"); Member mn = new Member(myName); mn.setBelongs("g"); @@ -72,12 +74,12 @@ roomViewModel.getMembersLiveData().observe(this, new Observer>() { private List members; @Override - public void onChanged(List members) { + public void onChanged(List irisMembers) { } }); - //-------------------------------------------------------------------------- + //各ボタン処理 ArrayList members = new ArrayList<>(); Button redMasterButton = (Button) findViewById(R.id.beRedMaster); @@ -89,68 +91,42 @@ ImageButton copyButton = (ImageButton) findViewById(R.id.copyButton); + //チームと役職の変更 + //赤チーム・スパイマスター redMasterButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - r = "部屋ID " + "red"; - TextView RoomIdText = findViewById(R.id.roomID); - RoomIdText.setText(r); - - members.clear(); - members.add("マスターのRedさん"); - ListView listView = (ListView)findViewById(R.id.MembersList); - - listView.setAdapter(adapter); + roomViewModel.changeBelongsAndMaster(r, myName,"r",true); } }); + //赤チーム・諜報員 redSpyButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - r = "部屋ID " + "red"; - TextView RoomIdText = findViewById(R.id.roomID); - RoomIdText.setText(r); - - members.add("スパイのRedさん"); - ListView listView = (ListView)findViewById(R.id.MembersList); - listView.setAdapter(adapter); + roomViewModel.changeBelongsAndMaster(r, myName,"r",false); } }); + //青チーム・スパイマスター blueMasterButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - r = "部屋ID " + "blue"; - TextView RoomIdText = findViewById(R.id.roomID); - RoomIdText.setText(r); - + roomViewModel.changeBelongsAndMaster(r, myName,"b",true); } }); + //青チーム・諜報員 blueSpyButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - r = "部屋ID " + "red"; - TextView RoomIdText = findViewById(R.id.roomID); - RoomIdText.setText(r); - - members.add("スパイのBlueさん"); - ListView listView = (ListView)findViewById(R.id.MembersList); - listView.setBackgroundColor(Color.parseColor("#3a5fe8")); - listView.setAdapter(adapter); + roomViewModel.changeBelongsAndMaster(r, myName,"b",false); } }); randomButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - r = "部屋ID " + "random"; - TextView RoomIdText = findViewById(R.id.roomID); - RoomIdText.setText(r); - - members.add("ランダムさん"); - ListView listView = (ListView)findViewById(R.id.MembersList); - listView.setAdapter(adapter); Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/iris/") @@ -164,7 +140,7 @@ startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - roomViewModel.startDrawing(r, nickname); + roomViewModel.startDrawing(r, myName); Intent intent = new Intent(OwnerRoomActivity.this,DrawingActivity.class); startActivity(intent); @@ -175,13 +151,7 @@ copyButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - r = "部屋ID " + "copy"; - TextView RoomIdText = findViewById(R.id.roomID); - RoomIdText.setText(r); - - members.add("コピーしました"); - ListView listView = (ListView)findViewById(R.id.MembersList); - listView.setAdapter(adapter); + } });