예제 #1
0
  private void showPopupChoose(
      final List<DataAdapter> listData,
      final int indexSelect,
      final EquipsView.OnClickListenerResult eventResult) {
    ListView listView = new ListView(this);
    DataArrayAdapter adapter = new DataArrayAdapter(this, R.layout.data_choose_layout, listData);
    adapter.indexChoose = indexSelect;
    final AlertView mAlert = new AlertView(this);
    mAlert.setView(listView);
    mAlert.setNegativeButton(
        R.string.alert_tag_cancel,
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            mAlert.hide();
          }
        });
    mAlert.show();
    listView.setAdapter(adapter);

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
            final DataAdapter item = (DataAdapter) parent.getItemAtPosition(position);

            if (eventResult != null && item != null) eventResult.onClick(item.id);
            mAlert.hide();
          }
        });
  }
예제 #2
0
  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));
  }