Esempio n. 1
0
  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) {}
        });
  }
Esempio n. 2
0
 private void showDetailEquip() {
   Equipment equipment = MyData.getInst().myEquips[idEquip];
   LinearLayout ln = new LinearLayout(this);
   ln.setLayoutParams(
       new LinearLayout.LayoutParams(
           LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
   DetailEquipView detailView = new DetailEquipView(this);
   ln.addView(detailView);
   detailView.showInforEquip(equipment);
   final AlertView alertView = AlertView.showAlert(this, ln, R.string.alert_tag_close);
   View.OnClickListener onClickGoup =
       new View.OnClickListener() {
         @Override
         public void onClick(View view) {
           alertView.hide();
         }
       };
 }
Esempio n. 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    DataManager.getInstall(this);
    setContentView(R.layout.activity_main);

    HeaderView header = (HeaderView) findViewById(R.id.gr_header);
    header.setTitle(R.string.header_title_main);

    chAll = (CheckBox) findViewById(R.id.chAll);
    chAll.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            showProperties();
          }
        });
    listViewProperties = (ListView) findViewById(R.id.listPro);
    txtElementKind = (TextView) findViewById(R.id.txt_element_kind);
    menuEquip = (MenuEquipView) findViewById(R.id.menu_equip);
    menuEquip.setOnListener(
        new MenuEquipView.OnClickListenerMenuResult() {
          @Override
          public void onClick(int idMenu) {
            if (idEquip == EnumDB.none) return;
            switch (idMenu) {
              case MenuEquipView.MENU_VIEW:
                showDetailEquip();
                break;
              case MenuEquipView.MENU_EDIT:
                Intent intent = new Intent(getBaseContext(), EditEquipAct.class);
                intent.putExtra(DataManager.key_equip_id, idEquip);
                intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                startActivity(intent);
                break;
              case MenuEquipView.MENU_CHANGE:
                //                        Equipment equipment = null;
                //                        Log.d("MainACt", equipment.toString());
                showProperties();
                break;
              case MenuEquipView.MENU_DELETE:
                if (MyData.getInst().myEquips[idEquip] != null) {
                  MyData.getInst().myEquips[idEquip].setActive(false);
                  MyData.getInst().myEquips[idEquip].update(getBaseContext());
                }
                MyData.getInst().myEquips[idEquip] = null;
                if (equipsView != null) equipsView.invalidate();
                showProperties();
                break;
            }
          }
        });
    equipsView = (EquipsView) findViewById(R.id.equip_view);

    equipsView.setClickListenerEquip(
        new EquipsView.OnClickListenerResult() {
          @Override
          public void onClick(int iEquip) {
            //                Log.d(this.getClass().getSimpleName(), "you Sellect :" + iEquip );
            //                showInformationEquip(iEquip);
          }

          @Override
          public void onResultPoint(int iEquip, Point p) {

            idEquip = iEquip;
            //                equipsView.invalidate();
            if (idEquip >= 0 && MyData.getInst().myEquips[iEquip] == null) {
              if (menuEquip != null) menuEquip.stopAni();
              Intent intent = new Intent(getBaseContext(), EditEquipAct.class);
              intent.putExtra(DataManager.key_equip_id, idEquip);
              intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
              intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
              startActivity(intent);
            } else if (menuEquip != null) menuEquip.moveToPoint(p, equipsView.mHeightScreen);
          }
        });

    if (MyData.getInst().myHeroElementKind != null) {
      if (MyData.getInst().myHeroElementKind.id != EnumDB.none) {
        txtElementKind.setText(MyData.getInst().myHeroElementKind.name_vn);
        txtElementKind.setTextColor(Color.parseColor(MyData.getInst().myHeroElementKind.color));
      } else {
        txtElementKind.setText(R.string.edit_properties_default);
        txtElementKind.setTextColor(getResources().getColor(R.color.edit_text_default));
      }
    }
  }
Esempio n. 4
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));
  }