diff --git a/app/src/main/java/org/ntlab/amaryllis/client/MainActivity.java b/app/src/main/java/org/ntlab/amaryllis/client/MainActivity.java index 299cfff..c343164 100644 --- a/app/src/main/java/org/ntlab/amaryllis/client/MainActivity.java +++ b/app/src/main/java/org/ntlab/amaryllis/client/MainActivity.java @@ -4,6 +4,8 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; import androidx.navigation.NavController; import androidx.navigation.Navigation; import androidx.navigation.ui.AppBarConfiguration; @@ -51,7 +53,7 @@ private static final String TAG = MainActivity.class.getSimpleName(); LocationManager locationManager; private ArrayList listeners = new ArrayList<>(); - private HashMap categories; + static HashMap categories; ArrayList checkedList = new ArrayList<>(); HashMap menuItemMap = new HashMap<>(); @@ -200,40 +202,58 @@ public Category getCategory(String cid){ return categories.get(cid); } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.nav_drawer_menu, menu); - - //カテゴリーの数だけitemを定義 - for(Category category : categories.values()){ - String name = category.getName(); - String cid = category.getcId(); - MenuItem newItem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, name); - menuItemMap.put(newItem.getItemId(),cid); - newItem.setCheckable(true); - newItem.setChecked(true); - checkedList.add(cid); - } - return true; + public static HashMap getCategories(){ + return categories; } + //以下MapsFragmentに移植 +// @Override +// public boolean onCreateOptionsMenu(Menu menu) { +// getMenuInflater().inflate(R.menu.nav_drawer_menu, menu); +// +// //カテゴリーの数だけitemを定義 +// +// for(Category category : categories.values()){ +// String name = category.getName(); +// String cid = category.getcId(); +// MenuItem newItem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, name); +// menuItemMap.put(newItem.getItemId(),cid); +// newItem.setCheckable(true); +// newItem.setChecked(true); +// checkedList.add(cid); +// } +// return true; +// } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - String cid = menuItemMap.get(item.getItemId()); - - item.setChecked(!item.isChecked()); - if(item.isChecked()){ - checkedList.remove(cid); - }else{ - checkedList.add(cid); - } - return super.onOptionsItemSelected(item); - } - - public ArrayList getCheckedCidList() { - return checkedList; - } +// +// @Override +// public boolean onOptionsItemSelected(MenuItem item) { +// String cid = menuItemMap.get(item.getItemId()); +// +// item.setChecked(!item.isChecked()); +// if(item.isChecked()){ +// checkedList.remove(cid); +// }else{ +// checkedList.add(cid); +// } +// return super.onOptionsItemSelected(item); +// } +// +// public ArrayList getCheckedCidList() { +// return checkedList; +// } +// +// @Override +// +// public boolean onPrepareOptionsMenu(Menu menu) { +// Fragment f =getSupportFragmentManager().findFragmentById(R.id.map); +// +// if (true) { +// return true; +// } else { +// return false; +// } +// +// } } \ No newline at end of file