.setText(String.format("%s\n%s", tr.getDescription(), tr.getDate()));
TableLayout tbl = holder.row.findViewById(R.id.transaction_row_acc_amounts);
tbl.removeAllViews();
- for (Iterator<LedgerTransactionAccount> it = tr.getAccountsIterator(); it.hasNext(); ) {
- LedgerTransactionAccount acc = it.next();
+ for (LedgerTransactionAccount acc : tr.getAccounts()) {
TableRow row = new TableRow(holder.row.getContext());
TextView child = new TextView(ctx);
child.setText(acc.getShortAccountName());
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
if (token != null) params.add_pair("_token", token);
params.add_pair("date", ltr.getDate());
params.add_pair("description", ltr.getDescription());
- {
- Iterator<LedgerTransactionAccount> items = ltr.getAccountsIterator();
- while (items.hasNext()) {
- LedgerTransactionAccount item = items.next();
- params.add_pair("account", item.getAccountName());
- if (item.isAmountSet())
- params.add_pair("amount", String.format(Locale.US, "%1.2f", item.getAmount()));
- else params.add_pair("amount", "");
- }
+ for (LedgerTransactionAccount acc : ltr.getAccounts()) {
+ params.add_pair("account", acc.getAccountName());
+ if (acc.isAmountSet())
+ params.add_pair("amount", String.format(Locale.US, "%1.2f", acc.getAmount()));
+ else params.add_pair("amount", "");
}
String body = params.toString();
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Comparator;
-import java.util.Iterator;
public class LedgerTransaction {
private static final String DIGEST_TYPE = "SHA-256";
private Integer id;
private String date;
private String description;
- private ArrayList<LedgerTransactionAccount> items;
- private String dataHash;
- private boolean dataLoaded;
+ private ArrayList<LedgerTransactionAccount> accounts;
public LedgerTransaction(Integer id, String date, String description) {
this.id = id;
this.date = date;
this.description = description;
- this.items = new ArrayList<>();
+ this.accounts = new ArrayList<>();
this.dataHash = null;
dataLoaded = false;
}
+ private String dataHash;
+ private boolean dataLoaded;
+ public ArrayList<LedgerTransactionAccount> getAccounts() {
+ return accounts;
+ }
public LedgerTransaction(String date, String description) {
this(null, date, description);
}
this(id, null, null);
}
public void addAccount(LedgerTransactionAccount item) {
- items.add(item);
+ accounts.add(item);
dataHash = null;
}
public String getDate() {
this.description = description;
dataHash = null;
}
- public Iterator<LedgerTransactionAccount> getAccountsIterator() {
- return new Iterator<LedgerTransactionAccount>() {
- private int pointer = 0;
- @Override
- public boolean hasNext() {
- return pointer < items.size();
- }
-
- @Override
- public LedgerTransactionAccount next() {
- return hasNext() ? items.get(pointer++) : null;
- }
- };
- }
public int getId() {
return id;
}
db.execSQL("INSERT INTO transactions(id, date, description, data_hash) values(?,?,?,?)",
new Object[]{id, date, description, dataHash});
- for (LedgerTransactionAccount item : items) {
+ for (LedgerTransactionAccount item : accounts) {
db.execSQL("INSERT INTO transaction_accounts(transaction_id, account_name, amount, " +
"currency) values(?, ?, ?, ?)",
new Object[]{id, item.getAccountName(), item.getAmount(), item.getCurrency()});
data.append('\0');
data.append(getDescription());
data.append('\0');
- for (LedgerTransactionAccount item : items) {
+ for (LedgerTransactionAccount item : accounts) {
data.append(item.getAccountName());
data.append('\0');
data.append(item.getCurrency());
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:text="TextView" />
+ android:text="\?"
+ tools:ignore="HardcodedText" />
</LinearLayout>
<View
android:layout_height="wrap_content"
android:indeterminate="true"
android:indeterminateBehavior="cycle"
- android:progress="40"
android:progressTint="@color/colorPrimary"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
~ along with Mobile-Ledger. If not, see <https://www.gnu.org/licenses/>.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/transaction_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="36dp"
android:orientation="horizontal"
android:paddingStart="8dp"
- android:paddingEnd="8dp"
- tools:showIn="@layout/transaction_list_fragment">
+ android:paddingEnd="8dp">
<!--android:button="@drawable/checkbox_star_black"-->
<TextView
android:id="@+id/transaction_row_description"
style="@style/account_summary_account_name"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="5"
android:text="Sample description goes here."
tools:ignore="HardcodedText" />
<TableLayout
android:id="@+id/transaction_row_acc_amounts"
- android:layout_width="wrap_content"
- android:layout_height="match_parent">
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="8dp"
+ android:layout_weight="5"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintStart_toEndOf="@id/transaction_row_description">
<TableRow>
tools:ignore="HardcodedText" />
</TableRow>
</TableLayout>
-</LinearLayout>
\ No newline at end of file
+</android.support.constraint.ConstraintLayout>
\ No newline at end of file