public void addAmount(float amount) {
this.addAmount(amount, null);
}
-
+ public int getAmountCount() { return amounts.size(); }
public String getAmountsString() {
if ((amounts == null) || amounts.isEmpty()) return "";
return builder.toString();
}
+ public String getAmountsString(int limit) {
+ if ((amounts == null) || amounts.isEmpty()) return "";
+ int included = 0;
+ StringBuilder builder = new StringBuilder();
+ for (LedgerAmount amount : amounts) {
+ String amt = amount.toString();
+ if (builder.length() > 0) builder.append('\n');
+ builder.append(amt);
+ included++;
+ if (included == limit) break;
+ }
+
+ return builder.toString();
+ }
public int getLevel() {
return level;
}
public class AccountSummaryAdapter
extends RecyclerView.Adapter<AccountSummaryAdapter.LedgerRowHolder> {
+ public static final int AMOUNT_LIMIT = 3;
private boolean selectionActive;
AccountSummaryAdapter() {
holder.expanderContainer
.setVisibility(acc.hasSubAccounts() ? View.VISIBLE : View.INVISIBLE);
holder.expanderContainer.setRotation(acc.isExpanded() ? 0 : 180);
- holder.tvAccountAmounts.setText(acc.getAmountsString());
+ int amounts = acc.getAmountCount();
+ if ((amounts > AMOUNT_LIMIT) && !acc.amountsExpanded()) {
+ holder.tvAccountAmounts.setText(acc.getAmountsString(AMOUNT_LIMIT));
+ holder.accountExpanderContainer.setVisibility(View.VISIBLE);
+ }
+ else {
+ holder.tvAccountAmounts.setText(acc.getAmountsString());
+ holder.accountExpanderContainer.setVisibility(View.GONE);
+ }
if (acc.isHiddenByStar()) {
holder.tvAccountName.setTypeface(null, Typeface.ITALIC);
View vTrailer;
FrameLayout expanderContainer;
ImageView expander;
+ FrameLayout accountExpanderContainer;
public LedgerRowHolder(@NonNull View itemView) {
super(itemView);
this.row = itemView.findViewById(R.id.account_summary_row);
this.vTrailer = itemView.findViewById(R.id.account_summary_trailer);
this.expanderContainer = itemView.findViewById(R.id.account_expander_container);
this.expander = itemView.findViewById(R.id.account_expander);
+ this.accountExpanderContainer = itemView.findViewById(R.id.account_row_amounts_expander_container);
MainActivity activity = (MainActivity) row.getContext();
}
break;
case R.id.account_row_acc_amounts:
- showAccountTransactions(acc);
+ if (acc.getAmountCount() > AccountSummaryAdapter.AMOUNT_LIMIT) {
+ acc.toggleAmountsExpanded();
+ DbOpQueue
+ .add("update accounts set amounts_expanded=? where name=? and profile=?",
+ new Object[]{acc.amountsExpanded(), acc.getName(),
+ Data.profile.get().getUuid()
+ });
+ Data.accounts.triggerItemChangedNotification(acc);
+ }
break;
}
}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright © 2019 Damyan Ivanov.
+ ~ This file is part of MoLe.
+ ~ MoLe is free software: you can distribute it and/or modify it
+ ~ under the term of the GNU General Public License as published by
+ ~ the Free Software Foundation, either version 3 of the License, or
+ ~ (at your opinion), any later version.
+ ~
+ ~ MoLe is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ~ GNU General Public License terms for details.
+ ~
+ ~ You should have received a copy of the GNU General Public License
+ ~ along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+ -->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+ <gradient
+ android:startColor="#40ffffff"
+ android:endColor="#FFffffff"
+ android:angle="270"
+ />
+</shape>
\ No newline at end of file
android:layout_marginEnd="8dp"
android:layout_weight="0"
android:gravity="center_vertical"
+ android:minWidth="@dimen/thumb_row_height"
android:onClick="onAccountSummaryRowViewClicked"
android:text="123,45\n678,90"
- android:minWidth="@dimen/thumb_row_height"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="HardcodedText" />
+ <FrameLayout
+ android:id="@+id/account_row_amounts_expander_container"
+ android:layout_width="0dp"
+ android:layout_height="12sp"
+ app:layout_constraintStart_toStartOf="@id/account_row_acc_amounts"
+ app:layout_constraintEnd_toEndOf="@id/account_row_acc_amounts"
+ app:layout_constraintBottom_toBottomOf="@id/account_row_acc_amounts"
+ android:background="@drawable/fade_down_white">
+
+ <!--<ImageView-->
+ <!--android:layout_gravity="center_vertical|end"-->
+ <!--android:id="@+id/account_row_amounts_expander"-->
+ <!--android:layout_width="20dp"-->
+ <!--android:layout_height="20dp"-->
+ <!--android:background="@drawable/ic_expand_more_black_24dp" />-->
+
+ </FrameLayout>
+
<View
android:id="@+id/account_summary_trailer"
android:layout_width="match_parent"