diff --git a/app/src/main/java/com/example/cosmosclient/views/GroupListActivity.java b/app/src/main/java/com/example/cosmosclient/views/GroupListActivity.java index 16bd164..386045f 100644 --- a/app/src/main/java/com/example/cosmosclient/views/GroupListActivity.java +++ b/app/src/main/java/com/example/cosmosclient/views/GroupListActivity.java @@ -29,6 +29,7 @@ import com.example.cosmosclient.entities.Group; import com.example.cosmosclient.entities.GroupListResponse; import com.example.cosmosclient.entities.MemberListResponse; +import com.example.cosmosclient.entities.jsons.GroupJson; import com.example.cosmosclient.views.DynamicGridView; import com.example.cosmosclient.resources.GroupsRest; import retrofit2.Call; @@ -48,7 +49,7 @@ private static final String TAG = GroupListActivity.class.getName(); private DynamicGridView gridView; - GroupListResponse result; + private GroupListResponse result; @Override @@ -58,8 +59,77 @@ Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); + + + + +// ArrayList GroupList = new ArrayList<>(); +// for (int i = 0; i < result.getGroupCount(); i++) { +// GroupList.add(result.getGroup(i).getName()); +// } + gridView = (DynamicGridView) findViewById(R.id.dynamic_grid); + + gridView.setOnDragListener(new DynamicGridView.OnDragListener() { + @Override + public void onDragStarted(int position) { + Log.d(TAG, "drag started at position" + position); + } + + @Override + public void onDragPositionsChanged(int oldPosition, int newPosition) { + Log.d(TAG, String.format("drag item position changed from %d to %d", oldPosition, newPosition)); + } + + }); + + gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { + @Override + public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { + gridView.startEditMode(position); + return true; + } + }); + + // グループの中にはいる(リクエスト一覧画面へ) + gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { +// Toast.makeText(GroupListActivity.this, parent.getAdapter().getItem(position).toString(), +// Toast.LENGTH_SHORT).show(); + GroupJson group = result.getGroups().get(position); +// app.setCurrentGroup(new Group(group)); + + Intent intent=new Intent(GroupListActivity.this, com.example.cosmosclient.views.RequestListActivity.class); + startActivity(intent); + } + }); + + /* とりあえずの画面遷移なので変更するかも */ +// TextView group1 = findViewById(R.id.group1); +// group1.setOnClickListener(new View.OnClickListener() { +// @Override +// public void onClick(View view) { +// gridView.stopEditMode(); +// Intent intent=new Intent(GroupListActivity.this, com.example.cosmosclient.views.RequestListActivity.class); +// startActivity(intent); +// } +// }); + + + DrawerLayout drawer = findViewById(R.id.drawer_layout); + NavigationView navigationView = findViewById(R.id.nav_view); + ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( + this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); + drawer.addDrawerListener(toggle); + toggle.syncState(); + navigationView.setNavigationItemSelectedListener(this); + } + + @Override + protected void onStart() { + super.onStart(); final String uId,token; - Cosmos app = (Cosmos) getApplication(); + final Cosmos app = (Cosmos) getApplication(); uId = app.getuId(); token = app.getToken(); @@ -73,7 +143,6 @@ userNameTextView.setText("ユーザ名:"+uName); userIDTextView.setText("ユーザID:"+uId); final ArrayList groupList = new ArrayList<>(); - //retrofitの処理 final Retrofit retrofit = new Retrofit.Builder() .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/cosmos/") @@ -95,9 +164,10 @@ result = result2; // Iterator it = result.member.iterator(); // int i = 0; - for (int i = 0; i < result.getGroupCount(); i++) { - groupList.add(result.getGroup(i).getName()); - } + +// for (int i = 0; i < result.getGroupCount(); i++) { +// groupList.add(result.getGroup(i).getName()); +// } // グループ名一覧の表示 gridView.setAdapter((ListAdapter) new CheeseDynamicAdapter(GroupListActivity.this, @@ -147,63 +217,6 @@ "グループ情報取得失敗", Toast.LENGTH_SHORT).show(); } }); - -// ArrayList GroupList = new ArrayList<>(); -// for (int i = 0; i < result.getGroupCount(); i++) { -// GroupList.add(result.getGroup(i).getName()); -// } - gridView = (DynamicGridView) findViewById(R.id.dynamic_grid); - - gridView.setOnDragListener(new DynamicGridView.OnDragListener() { - @Override - public void onDragStarted(int position) { - Log.d(TAG, "drag started at position" + position); - } - - @Override - public void onDragPositionsChanged(int oldPosition, int newPosition) { - Log.d(TAG, String.format("drag item position changed from %d to %d", oldPosition, newPosition)); - } - - }); - - gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { - @Override - public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { - gridView.startEditMode(position); - return true; - } - }); - - gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { -// Toast.makeText(GroupListActivity.this, parent.getAdapter().getItem(position).toString(), -// Toast.LENGTH_SHORT).show(); - Intent intent=new Intent(GroupListActivity.this, com.example.cosmosclient.views.RequestListActivity.class); - startActivity(intent); - } - }); - - /* とりあえずの画面遷移なので変更するかも */ -// TextView group1 = findViewById(R.id.group1); -// group1.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View view) { -// gridView.stopEditMode(); -// Intent intent=new Intent(GroupListActivity.this, com.example.cosmosclient.views.RequestListActivity.class); -// startActivity(intent); -// } -// }); - - - DrawerLayout drawer = findViewById(R.id.drawer_layout); - NavigationView navigationView = findViewById(R.id.nav_view); - ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( - this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); - drawer.addDrawerListener(toggle); - toggle.syncState(); - navigationView.setNavigationItemSelectedListener(this); } @Override