Skip to content

Commit a37095f

Browse files
Merge pull request openMF#133 from ashwinkey04/swiperefresh
Add functionality to SwipeRefreshLayout
2 parents fe4caf6 + 926273f commit a37095f

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

app/src/main/kotlin/org/mifos/mobile/cn/ui/mifos/dashboard/DashboardFragment.kt

+23-8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.content.Intent
55

66
import android.os.Bundle
77
import android.view.*
8+
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
89
import kotlinx.android.synthetic.main.fragment_dashboard.*
910
import org.mifos.mobile.cn.data.models.customer.Customer
1011
import org.mifos.mobile.cn.R
@@ -18,10 +19,11 @@ import org.mifos.mobile.cn.ui.mifos.recentTransactions.RecentTransactionsFragmen
1819
import org.mifos.mobile.cn.ui.utils.ConstantKeys
1920

2021

21-
class DashboardFragment : MifosBaseFragment(), View.OnClickListener {
22+
class DashboardFragment : MifosBaseFragment(), View.OnClickListener, SwipeRefreshLayout.OnRefreshListener {
2223

2324
private lateinit var rootView: View
2425
private lateinit var customer: Customer
26+
2527
companion object {
2628

2729
fun newInstance(): DashboardFragment {
@@ -47,13 +49,19 @@ class DashboardFragment : MifosBaseFragment(), View.OnClickListener {
4749
ll_accounts.setOnClickListener(this)
4850
ll_account_overview.setOnClickListener(this)
4951
ll_recent_transactions.setOnClickListener(this)
52+
swipe_home_container.setOnRefreshListener(this)
5053
}
5154

5255
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
5356
inflater.inflate(R.menu.menu_main, menu)
5457
super.onCreateOptionsMenu(menu, inflater)
5558
}
5659

60+
override fun onResume() {
61+
super.onResume()
62+
this.onCreate(null)
63+
}
64+
5765
override fun onClick(view: View) {
5866

5967
when (view.id) {
@@ -81,18 +89,25 @@ class DashboardFragment : MifosBaseFragment(), View.OnClickListener {
8189
private fun openAccount() {
8290
(activity as MifosBaseActivity)
8391
.replaceFragment(CustomerAccountFragment.newInstance(AccountType.DEPOSIT),
84-
true, R.id.container)
92+
true, R.id.container)
8593
}
86-
private fun showCustomerDetails(){
87-
val intent = Intent(activity,CustomerDetailsActivity::class.java)
88-
intent.putExtra(ConstantKeys.CUSTOMER_IDENTIFIER,"customer_identifier")
89-
startActivity(intent)
94+
95+
private fun showCustomerDetails() {
96+
val intent = Intent(activity, CustomerDetailsActivity::class.java)
97+
intent.putExtra(ConstantKeys.CUSTOMER_IDENTIFIER, "customer_identifier")
98+
startActivity(intent)
9099

91100

92101
}
93-
private fun showRecentTransactions(){
102+
103+
private fun showRecentTransactions() {
94104
(activity as MifosBaseActivity)
95105
.replaceFragment(RecentTransactionsFragment.Companion.newInstance(),
96-
true,R.id.container)
106+
true, R.id.container)
107+
}
108+
109+
override fun onRefresh() {
110+
this.onResume()
111+
swipe_home_container.isRefreshing = false
97112
}
98113
}

0 commit comments

Comments
 (0)