diff --git a/.idea/misc.xml b/.idea/misc.xml index cf9962a..a65c3ba 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,6 +5,11 @@ + + + + + diff --git a/app/src/main/java/org/ntlab/irisclient/GameMasterActivity.java b/app/src/main/java/org/ntlab/irisclient/GameMasterActivity.java index 2d01c58..e0b32ce 100644 --- a/app/src/main/java/org/ntlab/irisclient/GameMasterActivity.java +++ b/app/src/main/java/org/ntlab/irisclient/GameMasterActivity.java @@ -25,30 +25,26 @@ //操作可能かどうかを記録。これがfalseの時は何のボタンを押すこともできない。 //時間があればオフラインの動作はできるようにしたい。 private boolean IsActive = false; + private String myTeam; - //Irisから必要な情報を取得 - Iris iris = (Iris) this.getApplication(); - private String myTeam = iris.getTeam(); - - @Override + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_game_master); - // Fragmentを作成します + // Fragmentを作成します DrawingCardFragment fragment = new DrawingCardFragment(); - GamePlayerListFragment RedPlayerListFragment = new GamePlayerListFragment(); - GamePlayerListFragment BluePlayerListFragment = new GamePlayerListFragment(); - + GamePlayerListFragment RedPlayerList = new GamePlayerListFragment("r"); + GamePlayerListFragment BluePlayerList = new GamePlayerListFragment("b"); // Fragmentの追加や削除といった変更を行う際は、Transactionを利用します FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - // 新しく追加を行うのでaddを使用します // 他にも、よく使う操作で、replace removeといったメソッドがあります // メソッドの1つ目の引数は対象のViewGroupのID、2つ目の引数は追加するfragment transaction.add(R.id.container, fragment); - /* transaction.add(R.id.RedPlayerListContainer, RedPlayerListFragment); - transaction.add(R.id.BluePlayerListContainer, BluePlayerListFragment);*/ + transaction.add(R.id.RedPlayerListContainer, RedPlayerList); + transaction.add(R.id.BluePlayerListContainer,BluePlayerList); + // 最後にcommitを使用することで変更を反映します transaction.commit(); @@ -56,6 +52,7 @@ Iris iris = (Iris) this.getApplication(); String rid = iris.getRid(); String nickName = iris.getNickname(); + myTeam = iris.getTeam(); //viewModelに必用な情報をセット gameViewModel= new ViewModelProvider(this).get(GameViewModel.class); @@ -67,7 +64,9 @@ buttonProcesses(); //自分が赤チームマスターの場合はヒントが入力可能 - if(myTeam.equals("r")){ + if(myTeam == null) { + System.out.println(("myteamがnullです")); + }else if(myTeam.equals("r")){ IsActive = true; } @@ -86,6 +85,7 @@ } }); + } public void buttonProcesses(){ diff --git a/app/src/main/java/org/ntlab/irisclient/GamePlayerListFragment.java b/app/src/main/java/org/ntlab/irisclient/GamePlayerListFragment.java index b459eb5..21db43b 100644 --- a/app/src/main/java/org/ntlab/irisclient/GamePlayerListFragment.java +++ b/app/src/main/java/org/ntlab/irisclient/GamePlayerListFragment.java @@ -8,26 +8,67 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ListView; +import android.widget.TextView; +import android.view.Gravity; + +import org.ntlab.irisclient.models.Member; + +import java.util.ArrayList; +import java.util.List; public class GamePlayerListFragment extends Fragment { - public static GamePlayerListFragment newInstance(String str){ - // インスタンス生成 - GamePlayerListFragment fragment = new GamePlayerListFragment(); - return fragment; + private String myTeam; + + public GamePlayerListFragment(String team) + { + myTeam = team; } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); - Resources resources = getResources(); - View view = inflater.inflate(R.layout.fragment_card_drawing, container, false); + View view = inflater.inflate(R.layout.fragment_game_player_list, container, false); + Checkteam(view); + + //irisからプレイヤーの一覧を取得 + Iris iris = (Iris)this.getActivity().getApplication(); + List players = iris.getMemberList(); + + //テスト用 + Member test2 = new Member("test2"); + Member test3 = new Member("test3"); + players.add(test2); + players.add(test3); + + //memberのリストから名前(string)だけを抽出 + ArrayList viewPlayers = new ArrayList<>(); + players.forEach(m -> viewPlayers.add(m.getNickname())); + + ListView playersList = (ListView) view.findViewById(R.id.PlayersList); + + BaseAdapter adapter = new MemberListAdapter(this.getActivity().getApplicationContext(), R.layout.member_list_layout, viewPlayers, players); + // BaseAdapter adapter = new MemberListAdapter(this.getActivity().getApplicationContext(), R.layout.fragment_game_player_list, viewPlayers, players); + playersList.setAdapter(adapter); + + //なぜか他のGamePlayerListFragmentにplayerの内容が引き継がれてしまうので、ここで初期化する。 + players.clear(); return view; } //赤チームのプレイヤー全員を表示 //青チームのプレイヤー全員を表示 + private String Checkteam(View view){ + if(myTeam.equals("r")){ + + return "赤チーム"; + }else{ + + return "青チーム"; + } + } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_game_master.xml b/app/src/main/res/layout/activity_game_master.xml index 1db4629..aa827e8 100644 --- a/app/src/main/res/layout/activity_game_master.xml +++ b/app/src/main/res/layout/activity_game_master.xml @@ -2,6 +2,7 @@ @@ -84,7 +85,8 @@ app:layout_constraintStart_toEndOf="@+id/GameHintMax" app:layout_constraintTop_toTopOf="parent" /> - - - + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.0" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_game_player_list.xml b/app/src/main/res/layout/fragment_game_player_list.xml index 0e535d3..67af562 100644 --- a/app/src/main/res/layout/fragment_game_player_list.xml +++ b/app/src/main/res/layout/fragment_game_player_list.xml @@ -7,20 +7,11 @@ android:layout_height="match_parent" tools:context=".GamePlayerListFragment"> - + + \ No newline at end of file