protected View prepareView(Art art, int position, View convertView, ViewGroup parent) { TalentViewHolder holder = (TalentViewHolder) convertView.getTag(); Util.setVisibility(holder.text5, false, holder.text1); holder.text1.setText(art.getFullName()); ArtInfo artInfo = art.getInfo(); StringBuilder info = new StringBuilder(); if (artInfo != null && !TextUtils.isEmpty(artInfo.getTarget())) { info.append(artInfo.getTarget()); } if (artInfo != null && !TextUtils.isEmpty(artInfo.getRange())) { if (info.length() > 0) info.append(","); info.append(artInfo.getRange()); } if (artInfo != null && !TextUtils.isEmpty(artInfo.getCastDuration())) { if (info.length() > 0) info.append(","); info.append(artInfo.getCastDuration()); } holder.text2.setText(info); if (art.hasCustomProbe() && !TextUtils.isEmpty(art.getProbeInfo().getAttributesString())) { holder.text3.setText(art.getProbeInfo().getAttributesString()); } else if (!TextUtils.isEmpty(artInfo.getProbe()) && art.getProbeInfo().getAttributeTypes() == null) { holder.text3.setText(artInfo.getProbe()); } else { if (artInfo != null && !TextUtils.isEmpty(artInfo.getEffectDuration())) holder.text3.setText(artInfo.getEffectDuration()); else holder.text3.setText(null); } if (art.getProbeInfo().getErschwernis() != null) { holder.text4.setText(Util.toProbe(art.getProbeInfo().getErschwernis())); holder.text4.setVisibility(View.VISIBLE); } else holder.text4.setVisibility(View.INVISIBLE); if (holder.indicator != null) { if (art.hasFlag(Art.Flags.Begabung)) { holder.indicator.setVisibility(View.VISIBLE); holder.indicator.setImageBitmap(indicatorStarGray); } else { holder.indicator.setVisibility(View.INVISIBLE); } } Util.applyRowStyle(art, convertView, position); 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(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; }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { switch (getItemViewType(position)) { case ITEM_TYPE_VIEW: { convertView = (ItemListItem) inflater.inflate(R.layout.item_listitem_view, parent, false); ViewHolder holder = new ViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); holder.text3 = (TextView) convertView.findViewById(R.id.text3); holder.icon1 = (ImageView) convertView.findViewById(android.R.id.icon1); holder.flip = (FlipImageView) convertView.findViewById(android.R.id.icon1); holder.icon2 = (ImageView) convertView.findViewById(android.R.id.icon2); holder.icon_chain_bottom = (ImageView) convertView.findViewById(R.id.icon_chain_bottom); holder.icon_chain_top = (ImageView) convertView.findViewById(R.id.icon_chain_top); convertView.setTag(holder); break; } case ITEM_TYPE_EDIT: { convertView = (ItemListItem) inflater.inflate(R.layout.item_listitem_equippeditem, parent, false); ViewHolder holder = new ViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); holder.text3 = (TextView) convertView.findViewById(R.id.text3); holder.icon1 = (ImageView) convertView.findViewById(android.R.id.icon1); holder.icon2 = (ImageView) convertView.findViewById(android.R.id.icon2); holder.icon_chain_bottom = (ImageView) convertView.findViewById(R.id.icon_chain_bottom); holder.icon_chain_top = (ImageView) convertView.findViewById(R.id.icon_chain_top); convertView.setTag(holder); break; } case ITEM_TYPE_SEEK: { convertView = (ViewGroup) inflater.inflate(R.layout.item_listitem_seek, parent, false); SeekViewHolder viewHolder = new SeekViewHolder(); viewHolder.seek = (SeekBarEx) convertView.findViewById(R.id.wheel); viewHolder.text = (TextView) convertView.findViewById(R.id.wheel_label); viewHolder.value = (Button) convertView.findViewById(R.id.wheel_value); convertView.setTag(viewHolder); break; } case ITEM_TYPE_COMBAT_TALENT: case ITEM_TYPE_SIMPLE_TALENT: { convertView = inflater.inflate(R.layout.item_listitem_talent, parent, false); TalentViewHolder holder = new TalentViewHolder(); // name holder.text1 = (TextView) convertView.findViewById(R.id.talent_list_item_text1); // be holder.text2 = (TextView) convertView.findViewById(R.id.talent_list_item_text2); // probe holder.text3 = (TextView) convertView.findViewById(R.id.talent_list_item_text3); // value / at holder.text4 = (TextView) convertView.findViewById(R.id.talent_list_item_text4); // pa holder.text5 = (TextView) convertView.findViewById(R.id.talent_list_item_text5); holder.indicator = (ImageView) convertView.findViewById(R.id.talent_list_item_indicator); convertView.setTag(holder); break; } case ITEM_TYPE_MODIFIER: { // We need the layoutinflater to pick up the view from xml // Pick up the TwoLineListItem defined in the xml file convertView = inflater.inflate(R.layout.item_listitem_modifier, parent, false); ModifierViewHolder holder = new ModifierViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); holder.flip = (FlipImageView) convertView.findViewById(android.R.id.icon1); holder.active = (CheckBox) convertView.findViewById(R.id.active); convertView.setTag(holder); break; } case ITEM_TYPE_HEADER: { convertView = inflater.inflate(R.layout.item_listitem_header, parent, false); HeaderViewHolder holder = new HeaderViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); convertView.setTag(holder); break; } case ITEM_TYPE_NOTES: { convertView = inflater.inflate(R.layout.item_listitem_event, parent, false); EventViewHolder holder = new EventViewHolder(); holder.text1 = (TextView) convertView.findViewById(android.R.id.text1); holder.text2 = (TextView) convertView.findViewById(android.R.id.text2); holder.text3 = (TextView) convertView.findViewById(R.id.text3); holder.flip = (FlipImageView) convertView.findViewById(android.R.id.icon1); holder.icon2 = (ImageView) convertView.findViewById(android.R.id.icon2); convertView.setTag(holder); break; } case ITEM_TYPE_PURSE: convertView = inflater.inflate(R.layout.item_listitem_purse, parent, false); PurseViewHolder holder = new PurseViewHolder(); holder.currencySpinner = (Spinner) convertView.findViewById(R.id.sp_currency); holder.header = (TextView) convertView.findViewById(R.id.tv_currency_header); holder.picker = new NumberPicker[4]; holder.picker[0] = (NumberPicker) convertView.findViewById(R.id.popup_purse_dukat); holder.picker[1] = (NumberPicker) convertView.findViewById(R.id.popup_purse_silver); holder.picker[2] = (NumberPicker) convertView.findViewById(R.id.popup_purse_heller); holder.picker[3] = (NumberPicker) convertView.findViewById(R.id.popup_purse_kreuzer); holder.labels = new TextView[4]; holder.labels[0] = (TextView) convertView.findViewById(R.id.tv_currency1); holder.labels[1] = (TextView) convertView.findViewById(R.id.tv_currency2); holder.labels[2] = (TextView) convertView.findViewById(R.id.tv_currency3); holder.labels[3] = (TextView) convertView.findViewById(R.id.tv_currency4); convertView.setTag(holder); break; } } FlippableViewHolder.prepare(position, convertView, (ListView) parent); Listable item = getItem(position); if (item instanceof EquippedItem) { convertView = prepareView((EquippedItem) item, position, convertView, parent); } else if (item instanceof Attribute) { convertView = prepareView((Attribute) item, position, convertView, parent); } else if (item instanceof Talent) { convertView = prepareView((Talent) item, position, convertView, parent); } else if (item instanceof Spell) { convertView = prepareView((Spell) item, position, convertView, parent); } else if (item instanceof Art) { convertView = prepareView((Art) item, position, convertView, parent); } else if (item instanceof Modificator) { convertView = prepareView((Modificator) item, position, convertView, parent); } else if (item instanceof HeaderListItem) { convertView = prepareView((HeaderListItem) item, position, convertView, parent); } else if (item instanceof FileListable) { convertView = prepareView((FileListable) item, position, convertView, parent); } else if (item instanceof NotesItem) { convertView = prepareView((NotesItem) item, position, convertView, parent); } else if (item instanceof PurseListable) { convertView = prepareView((PurseListable) item, position, convertView, parent); } if (item instanceof Markable) { Util.applyRowStyle((Markable) item, convertView, position); } else { Util.applyRowStyle(convertView, position); } return convertView; }