Skip to content

Commit 4e1b82c

Browse files
committed
Squashed commit of the following:
commit 880471cf58cc7927998cdaf1b52842ef7cc193b4 Author: devrahul-2508 <[email protected]> Date: Mon Feb 19 22:17:47 2024 +0530 Fix: Not displaying all transactions on button click
1 parent b0f3361 commit 4e1b82c

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

mifospay/src/main/java/org/mifos/mobilewallet/mifospay/history/HistoryContract.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface HistoryContract {
2626

2727
interface TransactionsHistoryPresenter : BasePresenter {
2828
fun fetchTransactions()
29-
fun filterTransactionType(type: TransactionType?)
29+
fun filterTransactionType(type: TransactionType)
3030
fun handleTransactionClick(transactionIndex: Int)
3131
}
3232

mifospay/src/main/java/org/mifos/mobilewallet/mifospay/history/presenter/HistoryPresenter.kt

+17-19
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ import java.util.Locale
2020
import javax.inject.Inject
2121

2222
class HistoryPresenter @Inject constructor(
23-
private val mUseCaseHandler: UseCaseHandler,
24-
private val mLocalRepository: LocalRepository
23+
private val mUseCaseHandler: UseCaseHandler, private val mLocalRepository: LocalRepository
2524
) : TransactionsHistoryPresenter, TransactionsHistoryAsync {
2625
@JvmField
2726
@Inject
@@ -59,8 +58,7 @@ class HistoryPresenter @Inject constructor(
5958
override fun onSuccess(response: FetchAccount.ResponseValue?) {
6059
mAccount = response?.account
6160
response?.account?.id?.let {
62-
mTransactionsHistory
63-
?.fetchTransactionsHistory(it)
61+
mTransactionsHistory?.fetchTransactionsHistory(it)
6462
}
6563
}
6664

@@ -70,30 +68,29 @@ class HistoryPresenter @Inject constructor(
7068
})
7169
}
7270

73-
override fun filterTransactionType(type: TransactionType?) {
71+
override fun filterTransactionType(type: TransactionType) {
7472
val filterTransactions: MutableList<Transaction> = ArrayList()
75-
if(type!=null){
73+
74+
if (type == TransactionType.OTHER) {
75+
if (allTransactions!!.isNotEmpty()) {
76+
mHistoryView!!.refreshTransactions(allTransactions)
77+
} else {
78+
showEmptyStateView()
79+
}
80+
} else {
7681
for (transaction in allTransactions!!) {
7782
if (transaction.transactionType == type) {
7883
filterTransactions.add(transaction)
7984
}
8085
}
81-
if (filterTransactions.isEmpty()) {
82-
showEmptyTransactionTypeStateView(type.toString().lowercase(Locale.getDefault()))
83-
} else {
86+
if (filterTransactions.isNotEmpty()) {
8487
mHistoryView!!.refreshTransactions(filterTransactions)
85-
}
86-
}
87-
else{
88-
if(allTransactions!!.isEmpty()){
89-
showEmptyStateView()
90-
}
91-
else{
92-
mHistoryView!!.refreshTransactions(allTransactions)
88+
89+
} else {
90+
showEmptyTransactionTypeStateView(type.toString().lowercase(Locale.getDefault()))
9391

9492
}
9593
}
96-
9794
}
9895

9996
override fun handleTransactionClick(transactionIndex: Int) {
@@ -103,7 +100,8 @@ class HistoryPresenter @Inject constructor(
103100

104101
private fun showErrorStateView() {
105102
mHistoryView!!.showStateView(
106-
R.drawable.ic_error_state, R.string.error_oops,
103+
R.drawable.ic_error_state,
104+
R.string.error_oops,
107105
R.string.error_no_transaction_history_subtitle
108106
)
109107
}

mifospay/src/main/java/org/mifos/mobilewallet/mifospay/history/ui/HistoryFragment.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class HistoryFragment : BaseFragment(), HistoryView {
216216
btnFilterAll!!.setChipBackgroundColorResource(R.color.clickedblue)
217217
btnFilterCredits!!.setChipBackgroundColorResource(R.color.changedBackgroundColour)
218218
btnFilterDebits!!.setChipBackgroundColorResource(R.color.changedBackgroundColour)
219-
mTransactionsHistoryPresenter!!.filterTransactionType(null)
219+
mTransactionsHistoryPresenter!!.filterTransactionType(TransactionType.OTHER)
220220
}
221221

222222
@OnClick(R.id.btn_filter_credits)

0 commit comments

Comments
 (0)