Exemple #1
0
  public Uri getIconUri() {

    if (iconUri != null) {
      return iconUri;
    } else {
      if (getSpecifications().isEmpty()) return null;
      else return Util.getUriForResourceId(DsaUtil.getResourceId(getSpecifications().get(0)));
    }
  }
  protected View prepareView(
      EquippedItem equippedItem, int position, View convertView, ViewGroup parent) {

    ViewHolder holder = (ViewHolder) convertView.getTag();

    Item item = equippedItem.getItem();
    ItemSpecification itemSpecification = equippedItem.getItemSpecification();

    // if (equippedItem.getSecondaryItem() != null
    // &&
    // (equippedItem.getSecondaryItem().getItem().hasSpecification(Shield.class)
    // || (equippedItem
    // .getSecondaryItem().getItem().hasSpecification(Weapon.class) &&
    // equippedItem.getHand() == Hand.rechts))) {
    //
    // } else {
    // fightItemsOdd = !fightItemsOdd;
    // }

    StyleableSpannableStringBuilder title = new StyleableSpannableStringBuilder();
    if (!TextUtils.isEmpty(item.getTitle())) title.append(item.getTitle());

    holder.text2.setText(itemSpecification.getInfo());
    holder.text3.setText(null);

    holder.icon1.setImageResource(DsaUtil.getResourceId(itemSpecification));
    holder.icon1.setVisibility(View.VISIBLE);

    if (itemSpecification instanceof DistanceWeapon) {
      DistanceWeapon distanceWeapon = (DistanceWeapon) itemSpecification;

      holder.icon2.setImageResource(R.drawable.icon_target);
      holder.icon2.setVisibility(View.VISIBLE);

      if (equippedItem.getTalent() != null) {
        CombatProbe probe = equippedItem.getCombatProbeAttacke();
        Util.appendValue(hero, title, probe, null, getFilter().getSettings().isIncludeModifiers());
        holder.icon2.setEnabled(true);
        holder.icon1.setEnabled(true);
        holder.icon2.setTag(equippedItem);
        holder.icon2.setOnClickListener(targetListener);
        holder.icon1.setTag(probe);
        holder.icon1.setOnClickListener(probeListener);
      } else {
        holder.icon2.setEnabled(false);
        holder.icon2.setTag(null);
        holder.icon2.setOnClickListener(null);

        holder.icon1.setEnabled(false);
        holder.icon1.setTag(null);
        holder.icon1.setOnClickListener(null);
      }

      holder.text2.setText(distanceWeapon.getInfo(hero.getModifierTP(equippedItem)));

      if (hero.getHuntingWeapon() != null && hero.getHuntingWeapon().equals(equippedItem)) {
        holder.text3.setText(" Jagdwaffe");
      }

    } else if (itemSpecification instanceof Shield) {
      holder.icon1.setVisibility(View.INVISIBLE);
      holder.icon1.setTag(null);
      holder.icon1.setOnClickListener(null);

      if (equippedItem.getUsageType() == UsageType.Paradewaffe)
        holder.icon2.setImageURI(item.getIconUri());
      else holder.icon2.setImageResource(R.drawable.icon_shield);

      holder.icon2.setVisibility(View.VISIBLE);
      if (equippedItem.getTalent() != null) {
        holder.icon2.setEnabled(true);
        CombatProbe probe = equippedItem.getCombatProbeDefense();
        Util.appendValue(hero, title, probe, null, getFilter().getSettings().isIncludeModifiers());
        holder.icon2.setTag(probe);
        holder.icon2.setOnClickListener(probeListener);

        holder.text3.setText(equippedItem.getTalent().getName());
      } else {
        holder.icon2.setEnabled(false);
        holder.icon2.setTag(null);
        holder.icon2.setOnClickListener(null);
      }

    } else if (itemSpecification instanceof Weapon) {
      Weapon weapon = (Weapon) itemSpecification;

      holder.icon2.setImageResource(R.drawable.icon_shield);
      holder.icon2.setVisibility(View.VISIBLE);
      if (equippedItem.getTalent() != null) {

        CombatProbe pa = null, at = null;

        if (weapon.isAttackable()) {
          holder.icon1.setEnabled(true);
          holder.icon1.setVisibility(View.VISIBLE);
          at = equippedItem.getCombatProbeAttacke();
          holder.icon1.setTag(at);
          holder.icon1.setOnClickListener(probeListener);
        } else {
          holder.icon1.setVisibility(View.INVISIBLE);
          holder.icon1.setTag(null);
          holder.icon1.setOnClickListener(null);
        }

        if (weapon.isDefendable()) {
          holder.icon2.setEnabled(true);
          holder.icon2.setVisibility(View.VISIBLE);
          pa = equippedItem.getCombatProbeDefense();
          holder.icon2.setTag(pa);
          holder.icon2.setOnClickListener(probeListener);
        } else {
          holder.icon2.setVisibility(View.INVISIBLE);
          holder.icon2.setTag(null);
          holder.icon2.setOnClickListener(null);
        }

        String talentName = null;
        if (equippedItem.getTalent() != null) {
          talentName = equippedItem.getTalent().getName();
        }

        SpannableStringBuilder sb = new SpannableStringBuilder();

        if (!TextUtils.isEmpty(weapon.getName())) {
          sb.append(weapon.getName());
          sb.append("/");
        }
        if (!TextUtils.isEmpty(equippedItem.getItemSpecification().getSpecificationLabel())) {
          sb.append(equippedItem.getItemSpecification().getSpecificationLabel());
          sb.append("/");
        }
        sb.append(talentName);

        if (equippedItem.getHand() == Hand.links) {
          sb.append(" (Links)");
        }

        if (equippedItem.isBeidhändigerKampf()) {
          sb.append(" - BK");
        }

        holder.text3.setText(sb);

        Util.appendValue(hero, title, at, pa, getFilter().getSettings().isIncludeModifiers());
      } else {
        holder.icon2.setEnabled(false);
        holder.icon2.setTag(null);
        holder.icon2.setOnClickListener(null);

        holder.icon1.setEnabled(false);
        holder.icon1.setTag(null);
        holder.icon1.setOnClickListener(null);
      }
      if (getFilter().getSettings().isIncludeModifiers()) {
        holder.text2.setText(
            weapon.getInfo(
                hero.getModifiedValue(AttributeType.Körperkraft, true, true),
                hero.getModifierTP(equippedItem)));
      } else {
        holder.text2.setText(weapon.getInfo());
      }
    } else if (itemSpecification instanceof Armor) {
      // Armor armor = (Armor) itemSpecification;
      holder.icon2.setVisibility(View.GONE);
      holder.icon2.setTag(null);
      holder.icon2.setOnClickListener(null);
    }

    if (holder.icon_chain_top != null && holder.icon_chain_bottom != null) {
      if (equippedItem.getSecondaryItem() != null) {
        if (position > 0 && getItem(position - 1).equals(equippedItem.getSecondaryItem())) {
          holder.icon_chain_bottom.setVisibility(View.VISIBLE);
          holder.icon_chain_top.setVisibility(View.GONE);
        } else if (position < getCount()
            && getItem(position + 1).equals(equippedItem.getSecondaryItem())) {
          holder.icon_chain_top.setVisibility(View.VISIBLE);
          holder.icon_chain_bottom.setVisibility(View.GONE);
        }
      } else {
        holder.icon_chain_top.setVisibility(View.GONE);
        holder.icon_chain_bottom.setVisibility(View.GONE);
      }
    }

    holder.text1.setText(title);

    return convertView;
  }