@Override
 public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
   if (hero.getPurse() != null) {
     PurseUnit unit = (PurseUnit) picker.getTag();
     if (unit != null) {
       hero.getPurse().setCoins(unit, newVal);
     }
   }
 }
 /*
  * (non-Javadoc)
  *
  * @see android.widget.AdapterView.OnItemSelectedListener#onItemSelected(android .widget.AdapterView,
  * android.view.View, int, long)
  */
 @Override
 public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
   if (hero.getPurse() != null) {
     Currency cur = (Currency) parent.getItemAtPosition(position);
     if (cur != hero.getPurse().getActiveCurrency()) {
       hero.getPurse().setActiveCurrency(cur);
       notifyDataSetChanged();
     }
   }
 }
  protected View prepareView(PurseListable item, int position, View convertView, ViewGroup parent) {
    PurseViewHolder holder = (PurseViewHolder) convertView.getTag();

    Currency currency = item.getCurrency();
    if (currency == null) {
      currency = hero.getPurse().getActiveCurrency();

      SpinnerSimpleAdapter<Currency> currencyAdapter =
          new SpinnerSimpleAdapter<Currency>(getContext(), Currency.values());
      holder.currencySpinner.setOnItemSelectedListener(null);
      holder.currencySpinner.setAdapter(currencyAdapter);
      holder.currencySpinner.setSelection(currencyAdapter.getPosition(currency));
      holder.currencySpinner.setOnItemSelectedListener(onPurseItemSelectedListener);
      holder.currencySpinner.setVisibility(View.VISIBLE);
      holder.header.setVisibility(View.GONE);
    } else {
      holder.currencySpinner.setVisibility(View.GONE);
      holder.currencySpinner.setOnItemSelectedListener(null);
      holder.header.setVisibility(View.VISIBLE);
      holder.header.setText(currency.xmlName());
    }

    List<PurseUnit> units = currency.units();
    for (int i = 0; i < units.size(); i++) {
      holder.picker[i].setVisibility(View.VISIBLE);
      holder.picker[i].setTag(units.get(i));
      holder.picker[i].setMinValue(0);
      if (i == 0) holder.picker[i].setMaxValue(999);
      else holder.picker[i].setMaxValue(100);

      holder.picker[i].setValue(hero.getPurse().getCoins(units.get(i)));
      holder.picker[i].setOnValueChangedListener(onPurseValueChangeListener);

      holder.labels[i].setVisibility(View.VISIBLE);
      holder.labels[i].setText(units.get(i).xmlName());
    }

    for (int i = units.size(); i < 4; i++) {
      holder.picker[i].setVisibility(View.GONE);
      holder.picker[i].setTag(null);
      holder.labels[i].setVisibility(View.GONE);
    }

    return convertView;
  }
  protected View prepareView(Spell spell, int position, View convertView, ViewGroup parent) {
    TalentViewHolder holder = (TalentViewHolder) convertView.getTag();

    holder.text1.setText(spell.getName());

    Util.setVisibility(holder.text2, false, holder.text1);
    holder.text3.setText(spell.getProbeInfo().getAttributesString());

    if (spell.getValue() != null) {
      int modifier = hero.getModifier(spell);
      Util.setText(holder.text4, spell.getValue(), modifier, null);
    } else {
      Debug.warning(spell.getName() + " has no value");
    }
    Util.setVisibility(holder.text5, false, holder.text1);

    if (holder.indicator != null) {
      if (spell.hasFlag(Spell.Flags.ZauberSpezialisierung)
          || !TextUtils.isEmpty(spell.getZauberSpezialisierung())) {
        holder.indicator.setVisibility(View.VISIBLE);
        holder.indicator.setImageBitmap(indicatorFlash);
      } else if (spell.hasFlag(Spell.Flags.ÜbernatürlicheBegabung)) {
        holder.indicator.setVisibility(View.VISIBLE);
        holder.indicator.setImageBitmap(indicatorStar);
      } else if (spell.hasFlag(Spell.Flags.Hauszauber)) {
        holder.indicator.setVisibility(View.VISIBLE);
        holder.indicator.setImageBitmap(indicatorHouseGray);
      } else if (spell.hasFlag(Spell.Flags.Begabung)) {
        holder.indicator.setVisibility(View.VISIBLE);
        holder.indicator.setImageBitmap(indicatorStarGray);
      } else {
        holder.indicator.setVisibility(View.INVISIBLE);
      }
    }
    Util.applyRowStyle(spell, convertView, position);

    return convertView;
  }
  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;
  }
  protected View prepareView(Talent talent, int position, View convertView, ViewGroup parent) {
    TalentViewHolder holder = (TalentViewHolder) convertView.getTag();

    holder.text1.setText(talent.getName());

    String be = talent.getProbeInfo().getBe();

    if (TextUtils.isEmpty(be)) {
      Util.setVisibility(holder.text2, false, holder.text1);
      holder.text2.setText(null);
    } else {
      Util.setVisibility(holder.text2, true, holder.text1);
      holder.text2.setText(be);
    }
    if (talent.getComplexity() != null) {
      Util.setVisibility(holder.text2, true, holder.text1);
      if (holder.text2.length() > 0) holder.text2.append(" ");
      holder.text2.append(Util.toString(talent.getComplexity()));
    }
    holder.text3.setText(talent.getProbeInfo().getAttributesString());

    if (talent instanceof CombatMeleeTalent) {
      CombatMeleeTalent meleeTalent = (CombatMeleeTalent) talent;

      if (meleeTalent.getAttack() != null && meleeTalent.getAttack().getValue() != null) {
        int modifier = 0;
        if (filter.getSettings().isIncludeModifiers()) {
          modifier = hero.getModifier(meleeTalent.getAttack());
        }
        Util.setText(holder.text4, meleeTalent.getAttack().getValue(), modifier, null);
        holder.text4.setOnClickListener(probeListener);
        holder.text4.setOnLongClickListener(editListener);
        holder.text4.setTag(R.id.TAG_KEY_VALUE, meleeTalent);
        holder.text4.setTag(R.id.TAG_KEY_PROBE, meleeTalent.getAttack());
        Util.setVisibility(holder.text4, true, holder.text1);
      } else {
        Util.setVisibility(holder.text4, false, holder.text1);
      }

      if (meleeTalent.getDefense() != null && meleeTalent.getDefense().getValue() != null) {
        int modifier = 0;
        if (filter.getSettings().isIncludeModifiers()) {
          modifier = hero.getModifier(meleeTalent.getDefense());
        }
        Util.setText(holder.text5, meleeTalent.getDefense().getValue(), modifier, null);
        holder.text5.setOnClickListener(probeListener);
        holder.text5.setOnLongClickListener(editListener);
        holder.text5.setTag(R.id.TAG_KEY_VALUE, meleeTalent);
        holder.text5.setTag(R.id.TAG_KEY_PROBE, meleeTalent.getDefense());
        Util.setVisibility(holder.text5, true, holder.text1);
      } else {
        holder.text5.setVisibility(View.INVISIBLE);
      }

    } else if (talent instanceof CombatDistanceTalent) {

      CombatDistanceTalent distanceTalent = (CombatDistanceTalent) talent;

      if (distanceTalent.getValue() != null) {
        int modifier = 0;

        if (filter.getSettings().isIncludeModifiers()) {
          modifier = hero.getModifier(distanceTalent);
        }
        Util.setText(holder.text4, distanceTalent.getValue(), modifier, null);
        holder.text4.setOnClickListener(null);
        holder.text4.setClickable(false);
        Util.setVisibility(holder.text4, true, holder.text1);
      } else {
        Util.setVisibility(holder.text4, false, holder.text1);
      }
      Util.setVisibility(holder.text5, false, holder.text1);
    } else {
      int modifier = 0;
      if (filter.getSettings().isIncludeModifiers()) {
        modifier = hero.getModifier(talent);
      }
      Util.setText(holder.text4, talent.getValue(), modifier, null);
      holder.text4.setOnClickListener(null);
      holder.text4.setClickable(false); // hide text5 and expand text1
      // with its width
      Util.setVisibility(holder.text5, false, holder.text1);
    }

    if (holder.indicator != null) {
      if (talent.hasFlag(Talent.Flags.TalentSpezialisierung)
          || !TextUtils.isEmpty(talent.getTalentSpezialisierung())) {
        holder.indicator.setVisibility(View.VISIBLE);
        holder.indicator.setImageBitmap(indicatorFlash);
      } else if (talent.hasFlag(Flags.Meisterhandwerk)) {
        holder.indicator.setVisibility(View.VISIBLE);
        holder.indicator.setImageBitmap(indicatorHouse);
      } else if (talent.hasFlag(Flags.Talentschub)) {
        holder.indicator.setVisibility(View.VISIBLE);
        holder.indicator.setImageBitmap(indicatorStar);
      } else if (talent.hasFlag(Flags.Begabung)) {
        holder.indicator.setVisibility(View.VISIBLE);
        holder.indicator.setImageBitmap(indicatorStarGray);
      } else {
        holder.indicator.setVisibility(View.INVISIBLE);
      }
    }

    Util.applyRowStyle(talent, convertView, position);
    return convertView;
  }