diff options
author | Torsten Grote <t@grobox.de> | 2020-05-12 15:26:44 -0300 |
---|---|---|
committer | Torsten Grote <t@grobox.de> | 2020-05-15 14:26:41 -0300 |
commit | e74f39ee86f32b4e0324405af1f0c7be061fb372 (patch) | |
tree | 484a9e2f6ad3d8d6c9662ff5f41c6f254d218b30 /wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt | |
parent | 4a6630d1d147ae35358272dc5222964831c234ab (diff) | |
download | taler-android-e74f39ee86f32b4e0324405af1f0c7be061fb372.tar.gz taler-android-e74f39ee86f32b4e0324405af1f0c7be061fb372.tar.bz2 taler-android-e74f39ee86f32b4e0324405af1f0c7be061fb372.zip |
[wallet] separate history and transactions UI
The history with its JSON payload is only shown in dev mode
while the transactions are prepared to move to the new API.
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt')
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt index 440d07f..5aca896 100644 --- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt +++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt @@ -34,13 +34,23 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder import net.taler.common.exhaustive import net.taler.common.toRelativeTime import net.taler.wallet.R +import net.taler.wallet.history.AmountType +import net.taler.wallet.history.DisplayAmount +import net.taler.wallet.history.History +import net.taler.wallet.history.HistoryEvent +import net.taler.wallet.history.OrderAcceptedHistoryEvent +import net.taler.wallet.history.OrderRefusedHistoryEvent +import net.taler.wallet.history.RefreshHistoryEvent +import net.taler.wallet.history.RefreshReason +import net.taler.wallet.history.ReserveBalanceUpdatedHistoryEvent +import net.taler.wallet.history.TipAcceptedHistoryEvent +import net.taler.wallet.history.TipDeclinedHistoryEvent import net.taler.wallet.transactions.TransactionAdapter.TransactionViewHolder internal class TransactionAdapter( - private val devMode: Boolean, - private val listener: OnEventClickListener, - private var transactions: Transactions = Transactions() + private val listener: OnTransactionClickListener, + private var transactions: History = History() ) : Adapter<TransactionViewHolder>() { lateinit var tracker: SelectionTracker<String> @@ -52,7 +62,7 @@ internal class TransactionAdapter( override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TransactionViewHolder { val view = LayoutInflater.from(parent.context) - .inflate(R.layout.list_item_transaction, parent, false) + .inflate(R.layout.list_item_history, parent, false) return TransactionViewHolder(view) } @@ -63,7 +73,7 @@ internal class TransactionAdapter( holder.bind(transaction, tracker.isSelected(transaction.eventId)) } - fun update(updatedTransactions: Transactions) { + fun update(updatedTransactions: History) { this.transactions = updatedTransactions this.notifyDataSetChanged() } @@ -84,8 +94,8 @@ internal class TransactionAdapter( private val selectableForeground = v.foreground private val amountColor = amount.currentTextColor - open fun bind(transaction: Transaction, selected: Boolean) { - if (devMode || transaction.detailPageLayout != 0) { + open fun bind(transaction: HistoryEvent, selected: Boolean) { + if (transaction.detailPageLayout != 0) { v.foreground = selectableForeground v.setOnClickListener { listener.onTransactionClicked(transaction) } } else { @@ -97,12 +107,12 @@ internal class TransactionAdapter( title.text = if (transaction.title == null) { when (transaction) { - is RefreshTransaction -> getRefreshTitle(transaction) - is OrderAcceptedTransaction -> context.getString(R.string.transaction_order_accepted) - is OrderRefusedTransaction -> context.getString(R.string.transaction_order_refused) - is TipAcceptedTransaction -> context.getString(R.string.transaction_tip_accepted) - is TipDeclinedTransaction -> context.getString(R.string.transaction_tip_declined) - is ReserveBalanceUpdatedTransaction -> context.getString(R.string.transaction_reserve_balance_updated) + is RefreshHistoryEvent -> getRefreshTitle(transaction) + is OrderAcceptedHistoryEvent -> context.getString(R.string.transaction_order_accepted) + is OrderRefusedHistoryEvent -> context.getString(R.string.transaction_order_refused) + is TipAcceptedHistoryEvent -> context.getString(R.string.transaction_tip_accepted) + is TipDeclinedHistoryEvent -> context.getString(R.string.transaction_tip_declined) + is ReserveBalanceUpdatedHistoryEvent -> context.getString(R.string.transaction_reserve_balance_updated) else -> transaction::class.java.simpleName } } else transaction.title @@ -137,7 +147,7 @@ internal class TransactionAdapter( } } - private fun getRefreshTitle(transaction: RefreshTransaction): String { + private fun getRefreshTitle(transaction: RefreshHistoryEvent): String { val res = when (transaction.refreshReason) { RefreshReason.MANUAL -> R.string.transaction_refresh_reason_manual RefreshReason.PAY -> R.string.transaction_refresh_reason_pay |