@Override public int getItemViewType(int position) { Util.Lang lang = activity.getTextLang(); if (lang == Util.Lang.BI || itemList.get(position).getText(lang).length() == 0) return BI_LINK_TEXT_VIEW_TYPE; else return MONO_LINK_TEXT_VIEW_TYPE; }
@Override public void onBindViewHolder(LinkTextHolder holder, int position) { Util.Lang lang = activity.getTextLang(); Segment link = itemList.get(position); if (link.getText(lang).length() == 0) lang = Util.Lang.BI; // TODO noah, make this better. holder.title.setVisibility(View.VISIBLE); holder.title.setText(Html.fromHtml(link.getLocationString(Settings.getMenuLang()))); holder.title.setFont(Settings.getMenuLang(), true, activity.getTextSize()); holder.setPosition(position); // itemList might not have updated yet if you switched pesukim. make sure it's up to date if (!holder.getItemList().equals(itemList)) holder.setItemList(itemList); if (holder instanceof LinkMonoTextHolder) { LinkMonoTextHolder monoHolder = (LinkMonoTextHolder) holder; String text; if (link.getText(lang).length() == 0) text = activity.getResources().getString(R.string.no_text); else text = link.getText(lang); monoHolder.monoTv.setText(Html.fromHtml(Util.getBidiString(text, lang))); monoHolder.monoTv.setFont(lang, true, activity.getTextSize()); monoHolder.monoTv.setLangGravity(lang); } else if (holder instanceof LinkBiTextHolder) { LinkBiTextHolder biHolder = (LinkBiTextHolder) holder; biHolder.enTv.setVisibility(View.VISIBLE); biHolder.heTv.setVisibility(View.VISIBLE); String enText = link.getText(Util.Lang.EN); String heText = link.getText(Util.Lang.HE); if (enText.length() == 0) biHolder.enTv.setVisibility(View.GONE); else biHolder.enTv.setText(Html.fromHtml(Util.getBidiString(enText, Util.Lang.EN))); biHolder.enTv.setFont(Util.Lang.EN, true, activity.getTextSize()); if (heText.length() == 0) biHolder.heTv.setVisibility(View.GONE); else biHolder.heTv.setText(Html.fromHtml(Util.getBidiString(heText, Util.Lang.HE))); biHolder.heTv.setFont(Util.Lang.HE, true, activity.getTextSize()); } }