import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.annotation.NonNull;
+import androidx.appcompat.widget.AppCompatTextView;
+import androidx.recyclerview.widget.RecyclerView;
+
+import net.ktnx.mobileledger.App;
import net.ktnx.mobileledger.R;
import net.ktnx.mobileledger.model.Data;
import net.ktnx.mobileledger.model.LedgerTransaction;
import net.ktnx.mobileledger.model.TransactionListItem;
import net.ktnx.mobileledger.utils.Colors;
import net.ktnx.mobileledger.utils.Globals;
-import net.ktnx.mobileledger.utils.MLDB;
import java.text.DateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
-import androidx.annotation.NonNull;
-import androidx.appcompat.widget.AppCompatTextView;
-import androidx.recyclerview.widget.RecyclerView;
-
import static net.ktnx.mobileledger.utils.DimensionUtils.dp2px;
public class TransactionListAdapter extends RecyclerView.Adapter<TransactionRowHolder> {
LedgerTransaction tr = p[0].transaction;
boolean odd = p[0].odd;
- SQLiteDatabase db = MLDB.getDatabase();
+ SQLiteDatabase db = App.getDatabase();
tr.loadData(db);
publishProgress(new TransactionLoaderStep(p[0].holder, p[0].position, tr, odd));
int rowIndex = 0;
+ // FIXME ConcurrentModificationException in ArrayList$ltr.next (ArrayList.java:831)
for (LedgerTransactionAccount acc : tr.getAccounts()) {
// debug(c.getAccountName(), acc.getAmount()));
publishProgress(new TransactionLoaderStep(p[0].holder, acc, rowIndex++,
int rowIndex = step.getAccountPosition();
Context ctx = holder.row.getContext();
LinearLayout row = (LinearLayout) holder.tableAccounts.getChildAt(rowIndex);
- TextView accName, accAmount;
if (row == null) {
- row = new LinearLayout(ctx);
- row.setLayoutParams(new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.MATCH_PARENT,
- LinearLayout.LayoutParams.WRAP_CONTENT));
- row.setGravity(Gravity.CENTER_VERTICAL);
- row.setOrientation(LinearLayout.HORIZONTAL);
- row.setPaddingRelative(dp2px(ctx, 8), 0, 0, 0);
- accName = new AppCompatTextView(ctx);
- accName.setLayoutParams(new LinearLayout.LayoutParams(0,
- LinearLayout.LayoutParams.WRAP_CONTENT, 5f));
- accName.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
- row.addView(accName);
- accAmount = new AppCompatTextView(ctx);
- LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
- llp.setMarginEnd(0);
- accAmount.setLayoutParams(llp);
- accAmount.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_END);
- accAmount.setMinWidth(dp2px(ctx, 60));
- row.addView(accAmount);
- holder.tableAccounts.addView(row);
- }
- else {
- accName = (TextView) row.getChildAt(0);
- accAmount = (TextView) row.getChildAt(1);
+ LayoutInflater inflater = ((Activity) ctx).getLayoutInflater();
+ row = (LinearLayout) inflater.inflate(
+ R.layout.transaction_list_row_accounts_table_row,
+ holder.tableAccounts);
}
+ TextView accName = row.findViewById(R.id.transaction_list_acc_row_acc_name);
+ TextView accComment =
+ row.findViewById(R.id.transaction_list_acc_row_acc_comment);
+ TextView accAmount = row.findViewById(R.id.transaction_list_acc_row_acc_amount);
LedgerTransactionAccount acc = step.getAccount();
accAmount.setTextColor(Colors.defaultTextColor);
accName.setText(acc.getAccountName());
}
+
+ String comment = acc.getComment();
+ if (comment != null && !comment.isEmpty()) {
+ accComment.setText(comment);
+ accComment.setVisibility(View.VISIBLE);
+ }
+ else {
+ accComment.setVisibility(View.GONE);
+ }
accAmount.setText(acc.toString());
break;