@@ -20,8 +20,7 @@ import java.util.Locale
20
20
import javax.inject.Inject
21
21
22
22
class HistoryPresenter @Inject constructor(
23
- private val mUseCaseHandler : UseCaseHandler ,
24
- private val mLocalRepository : LocalRepository
23
+ private val mUseCaseHandler : UseCaseHandler , private val mLocalRepository : LocalRepository
25
24
) : TransactionsHistoryPresenter, TransactionsHistoryAsync {
26
25
@JvmField
27
26
@Inject
@@ -59,8 +58,7 @@ class HistoryPresenter @Inject constructor(
59
58
override fun onSuccess (response : FetchAccount .ResponseValue ? ) {
60
59
mAccount = response?.account
61
60
response?.account?.id?.let {
62
- mTransactionsHistory
63
- ?.fetchTransactionsHistory(it)
61
+ mTransactionsHistory?.fetchTransactionsHistory(it)
64
62
}
65
63
}
66
64
@@ -70,30 +68,29 @@ class HistoryPresenter @Inject constructor(
70
68
})
71
69
}
72
70
73
- override fun filterTransactionType (type : TransactionType ? ) {
71
+ override fun filterTransactionType (type : TransactionType ) {
74
72
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 {
76
81
for (transaction in allTransactions!! ) {
77
82
if (transaction.transactionType == type) {
78
83
filterTransactions.add(transaction)
79
84
}
80
85
}
81
- if (filterTransactions.isEmpty()) {
82
- showEmptyTransactionTypeStateView(type.toString().lowercase(Locale .getDefault()))
83
- } else {
86
+ if (filterTransactions.isNotEmpty()) {
84
87
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()))
93
91
94
92
}
95
93
}
96
-
97
94
}
98
95
99
96
override fun handleTransactionClick (transactionIndex : Int ) {
@@ -103,7 +100,8 @@ class HistoryPresenter @Inject constructor(
103
100
104
101
private fun showErrorStateView () {
105
102
mHistoryView!! .showStateView(
106
- R .drawable.ic_error_state, R .string.error_oops,
103
+ R .drawable.ic_error_state,
104
+ R .string.error_oops,
107
105
R .string.error_no_transaction_history_subtitle
108
106
)
109
107
}
0 commit comments