| |
---|
| | |
---|
| | private static final String TAG = MainActivity.class.getSimpleName(); |
---|
| | LocationManager locationManager; |
---|
| | private ArrayList<LocationListener> listeners = new ArrayList<>(); |
---|
| | private HashMap<String ,Category> categories; |
---|
| | private ArrayList<String> checkedList = new ArrayList<>(); |
---|
| | HashMap<Integer,String> menuItemMap = new HashMap<>(); |
---|
| | static HashMap<String ,Category> categories; |
---|
| | ImageButton playbutton; |
---|
| | ImageButton stopbutton; |
---|
| | ImageButton skipbutton; |
---|
| | |
---|
| |
---|
| | public Category getCategory(String cid){ |
---|
| | return categories.get(cid); |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public boolean onCreateOptionsMenu(Menu menu) { |
---|
| | getMenuInflater().inflate(R.menu.nav_drawer_menu, menu); |
---|
| | |
---|
| | //カテゴリーの数だけitemを定義 |
---|
| | int id=0; |
---|
| | for(Category category : categories.values()){ |
---|
| | String name = category.getName(); |
---|
| | String cid = category.getcId(); |
---|
| | MenuItem newItem = menu.add(Menu.NONE, id, Menu.NONE, name); |
---|
| | menuItemMap.put(newItem.getItemId(),cid); |
---|
| | newItem.setCheckable(true); |
---|
| | newItem.setChecked(true); |
---|
| | checkedList.add(cid); |
---|
| | id++; |
---|
| | } |
---|
| | return true; |
---|
| | } |
---|
| | |
---|
| | |
---|
| | @Override |
---|
| | public boolean onOptionsItemSelected(MenuItem item) { |
---|
| | String cid = menuItemMap.get(item.getItemId()); |
---|
| | |
---|
| | item.setChecked(!item.isChecked()); |
---|
| | if(item.isChecked()){ |
---|
| | checkedList.add(cid); |
---|
| | }else{ |
---|
| | checkedList.remove(cid); |
---|
| | } |
---|
| | return super.onOptionsItemSelected(item); |
---|
| | } |
---|
| | |
---|
| | public ArrayList getCheckedCidList() { |
---|
| | return checkedList; |
---|
| | } |
---|
| | public static HashMap<String,Category> getCategories(){ |
---|
| | return categories; |
---|
| | } |
---|
| | |
---|
| | // |
---|
| | // @Override |
---|
| | // public boolean onCreateOptionsMenu(Menu menu) { |
---|
| | // getMenuInflater().inflate(R.menu.nav_drawer_menu, menu); |
---|
| | // |
---|
| | // //カテゴリーの数だけitemを定義 |
---|
| | // int id=0; |
---|
| | // for(Category category : categories.values()){ |
---|
| | // String name = category.getName(); |
---|
| | // String cid = category.getcId(); |
---|
| | // MenuItem newItem = menu.add(Menu.NONE, id, Menu.NONE, name); |
---|
| | // menuItemMap.put(newItem.getItemId(),cid); |
---|
| | // newItem.setCheckable(true); |
---|
| | // newItem.setChecked(true); |
---|
| | // checkedList.add(cid); |
---|
| | // id++; |
---|
| | // } |
---|
| | // return true; |
---|
| | // } |
---|
| | // |
---|
| | // |
---|
| | // @Override |
---|
| | // public boolean onOptionsItemSelected(MenuItem item) { |
---|
| | // String cid = menuItemMap.get(item.getItemId()); |
---|
| | // |
---|
| | // item.setChecked(!item.isChecked()); |
---|
| | // if(item.isChecked()){ |
---|
| | // checkedList.add(cid); |
---|
| | // }else{ |
---|
| | // checkedList.remove(cid); |
---|
| | // } |
---|
| | // return super.onOptionsItemSelected(item); |
---|
| | // } |
---|
| | // |
---|
| | // public ArrayList getCheckedCidList() { |
---|
| | // return checkedList; |
---|
| | // } |
---|
| | |
---|
| | } |
---|
| | |