private void showPopupChooseElement() { final ArrayList<DataAdapter> listData = new ArrayList<DataAdapter>(); for (Map.Entry<Integer, ElementKind> entry : Database.getInst().getAllElementsKindTbs().entrySet()) { ElementKind value = entry.getValue(); if (value != null) listData.add(new DataAdapter(value.id.intValue(), value.name_vn)); } int idSelect = -1; if (MyData.getInst().myHeroElementKind != null) idSelect = MyData.getInst().myHeroElementKind.id.intValue(); showPopupChoose( listData, idSelect, new EquipsView.OnClickListenerResult() { @Override public void onClick(int iEquip) { ElementKind value = (ElementKind) Database.getInst().getAllElementsKindTbs().get(iEquip); MyData.getInst().myHeroElementKind = value; if (value != null) { if (value.id != EnumDB.none) { txtElementKind.setText(value.name_vn); txtElementKind.setTextColor(Color.parseColor(value.color)); Constanst.setInt( MainActivity.this, "element_hero", (value != null ? value.id.intValue() : -1)); } else { txtElementKind.setText(R.string.edit_properties_default); txtElementKind.setTextColor(getResources().getColor(R.color.edit_text_default)); } } } @Override public void onResultPoint(int id, Point p) {} }); }
public void showProperties() { listData.clear(); mapPro.clear(); if (adapter == null) { adapter = new DataArrayAdapter(this, R.layout.data_choose_layout, listData); listViewProperties.setAdapter(adapter); } // add thuoc tinh bang dau addMap(Database.getInst().getPropertiesKindTbs(1), 0); // + Sinh Luc addMap(Database.getInst().getPropertiesKindTbs(3), 0); // + Noi Luc addMap(Database.getInst().getPropertiesKindTbs(5), 0); // + The Luc addMap(Database.getInst().getPropertiesKindTbs(7), 0); // + Suc Manh addMap(Database.getInst().getPropertiesKindTbs(9), 0); // + Sinh Khi addMap(Database.getInst().getPropertiesKindTbs(8), 0); // + Than Phap addMap(Database.getInst().getPropertiesKindTbs(10), 0); // + Noi Cong addMap(Database.getInst().getPropertiesKindTbs(11), 0); // + PTVL addMap(Database.getInst().getPropertiesKindTbs(15), 0); // + Khang Bang addMap(Database.getInst().getPropertiesKindTbs(14), 0); // + Khang Loi addMap(Database.getInst().getPropertiesKindTbs(13), 0); // + Khang Hoa addMap(Database.getInst().getPropertiesKindTbs(12), 0); // + Khang Doc addMap(Database.getInst().getPropertiesKindTbs(19), 0); // + Phuc Hoi addMap(Database.getInst().getPropertiesKindTbs(16), 0); // + Lam Cham addMap(Database.getInst().getPropertiesKindTbs(18), 0); // + Choang addMap(Database.getInst().getPropertiesKindTbs(17), 0); // + Thoi Gian trung doc for (Equipment e : MyData.getInst().myEquips) { if (e != null) { boolean[] bProperties = new boolean[Equipment.MAX_ROW_PROPERTIES]; bProperties[0] = bProperties[2] = bProperties[4] = true; ElementKind heroElement = MyData.getInst().myHeroElementKind; ElementKind equipElement = e.elementsKind(); int flag = 0; if (!chAll.isChecked()) { if (heroElement != null && equipElement != null && heroElement.id != EnumDB.none && equipElement.id != EnumDB.none && heroElement.creation_id == equipElement.id) { bProperties[1] = true; flag = 1; } if (e.checkEquipCreation1()) { if (flag == 1) bProperties[3] = true; else bProperties[1] = true; flag++; } if (e.checkEquipCreation2()) { if (flag == 2) bProperties[5] = true; else if (flag == 1) bProperties[3] = true; else bProperties[1] = true; } } for (int i = 0; i < Equipment.MAX_ROW_PROPERTIES; i++) { Properties p = e.getValueEquip(i); if (p == null || p.getId() == EnumDB.none) continue; if (!chAll.isChecked() && !bProperties[i]) continue; PropertiesKind pro = p.getPropertiesKind(); if (pro.id != 0) // khac khang tat ca addMap(pro, p.getValue()); else { // neu la khang tat ca addMap(Database.getInst().getPropertiesKindTbs(11), p.getValue()); // + PTVL addMap(Database.getInst().getPropertiesKindTbs(15), p.getValue()); // + PTVL addMap(Database.getInst().getPropertiesKindTbs(14), p.getValue()); // + PTVL addMap(Database.getInst().getPropertiesKindTbs(13), p.getValue()); // + PTVL addMap(Database.getInst().getPropertiesKindTbs(12), p.getValue()); // + PTVL } } } } adapter.notifyDataSetChanged(); listViewProperties.getLayoutParams().height = (int) (listData.size() * getResources().getDimension(R.dimen.main_height_pro)); }