/* (non-Javadoc) * calls {@link #convText for formatting the values retrieved from the cursor} * @see android.widget.SimpleCursorAdapter#setViewText(android.widget.TextView, java.lang.String) */ @Override public void setViewText(TextView v, String text) { switch (v.getId()) { case R.id.date: text = Utils.convDateTime(text, itemDateFormat); break; case R.id.amount: text = Utils.convAmount(text, mAccount.currency); } super.setViewText(v, text); }
private void fillSums(HeaderViewHolder holder, Cursor mGroupingCursor) { holder.sumExpense.setText( "- " + Utils.convAmount( DbUtils.getLongOr0L(mGroupingCursor, columnIndexGroupSumExpense), mAccount.currency)); holder.sumIncome.setText( "+ " + Utils.convAmount( DbUtils.getLongOr0L(mGroupingCursor, columnIndexGroupSumIncome), mAccount.currency)); holder.sumTransfer.setText( "<-> " + Utils.convAmount( DbUtils.getLongOr0L(mGroupingCursor, columnIndexGroupSumTransfer), mAccount.currency)); holder.interimBalance.setText( "= " + Utils.convAmount( DbUtils.getLongOr0L(mGroupingCursor, columIndexGroupSumInterim), mAccount.currency)); }
@Override public View getView(int position, View convertView, ViewGroup parent) { convertView = super.getView(position, convertView, parent); Cursor c = getCursor(); c.moveToPosition(position); boolean doesHavePlan = !c.isNull(columnIndexPlanId); TextView tv1 = (TextView) convertView.findViewById(R.id.amount); long amount = c.getLong(columnIndexAmount); tv1.setTextColor(amount < 0 ? colorExpense : colorIncome); tv1.setText( Utils.convAmount(amount, Utils.getSaveInstance(c.getString(columnIndexCurrency)))); int color = c.getInt(columnIndexColor); convertView.findViewById(R.id.colorAccount).setBackgroundColor(color); TextView tv2 = (TextView) convertView.findViewById(R.id.category); CharSequence catText = tv2.getText(); if (c.getInt(columnIndexTransferPeer) > 0) { catText = ((amount < 0) ? "=> " : "<= ") + catText; } else { Long catId = DbUtils.getLongOrNull(c, KEY_CATID); if (catId == null) { catText = Category.NO_CATEGORY_ASSIGNED_LABEL; } else { String label_sub = c.getString(columnIndexLabelSub); if (label_sub != null && label_sub.length() > 0) { catText = catText + categorySeparator + label_sub; } } } // TODO: simplify confer TemplateWidget SpannableStringBuilder ssb; String comment = c.getString(columnIndexComment); if (comment != null && comment.length() > 0) { ssb = new SpannableStringBuilder(comment); ssb.setSpan(new StyleSpan(android.graphics.Typeface.ITALIC), 0, comment.length(), 0); catText = TextUtils.concat(catText, commentSeparator, ssb); } String payee = c.getString(columnIndexPayee); if (payee != null && payee.length() > 0) { ssb = new SpannableStringBuilder(payee); ssb.setSpan(new UnderlineSpan(), 0, payee.length(), 0); catText = TextUtils.concat(catText, commentSeparator, ssb); } tv2.setText(catText); if (doesHavePlan) { String planInfo = c.getString(columnIndexPlanInfo); if (planInfo == null) { planInfo = getString( ContextCompat.checkSelfPermission( getActivity(), Manifest.permission.WRITE_CALENDAR) == PackageManager.PERMISSION_DENIED ? R.string.calendar_permission_required : R.string.plan_event_deleted); } ((TextView) convertView.findViewById(R.id.title)) .setText( //noinspection SetTextI18n c.getString(columnIndexTitle) + " (" + planInfo + ")"); } ((ImageView) convertView.findViewById(R.id.Plan)) .setImageResource(doesHavePlan ? R.drawable.ic_event : R.drawable.ic_menu_template); return convertView; }