diff --git a/app/src/main/java/org/apache/fineract/ui/online/accounting/accounts/AccountsFragment.kt b/app/src/main/java/org/apache/fineract/ui/online/accounting/accounts/AccountsFragment.kt index 67c27d8a..e2181cb1 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/accounting/accounts/AccountsFragment.kt +++ b/app/src/main/java/org/apache/fineract/ui/online/accounting/accounts/AccountsFragment.kt @@ -30,6 +30,8 @@ class AccountsFragment : FineractBaseFragment(), AccountContract.View, SwipeRefr lateinit var accountList : List + private var searchView: SearchView? = null + companion object { fun newInstance() = AccountsFragment() } @@ -87,7 +89,7 @@ class AccountsFragment : FineractBaseFragment(), AccountContract.View, SwipeRefr private fun setUpSearchInterface(menu: Menu?) { val searchManager = activity?.getSystemService(Context.SEARCH_SERVICE) as? SearchManager - val searchView = menu?.findItem(R.id.account_search)?.actionView as? SearchView + searchView = menu?.findItem(R.id.account_search)?.actionView as? SearchView searchView?.setSearchableInfo(searchManager?.getSearchableInfo(activity?.componentName)) @@ -115,7 +117,12 @@ class AccountsFragment : FineractBaseFragment(), AccountContract.View, SwipeRefr } override fun onRefresh() { - accountsPresenter.getAccountsPage() + if (searchView!!.query.toString().isEmpty()) { + accountsPresenter.getAccountsPage() + } else { + accountsPresenter.searchAccount(accountList, searchView!!.query.toString()) + } + hideProgressbar() } diff --git a/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/LedgerFragment.kt b/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/LedgerFragment.kt index 75c50be5..89234e08 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/LedgerFragment.kt +++ b/app/src/main/java/org/apache/fineract/ui/online/accounting/ledgers/LedgerFragment.kt @@ -10,7 +10,10 @@ import androidx.appcompat.widget.SearchView import android.text.TextUtils import android.view.* import androidx.recyclerview.widget.RecyclerView +import kotlinx.android.synthetic.main.fragment_accounts.* import kotlinx.android.synthetic.main.fragment_ledger.* +import kotlinx.android.synthetic.main.fragment_ledger.layoutError +import kotlinx.android.synthetic.main.fragment_ledger.swipeContainer import kotlinx.android.synthetic.main.layout_exception_handler.* import org.apache.fineract.R import org.apache.fineract.data.models.accounts.Ledger @@ -33,6 +36,8 @@ class LedgerFragment : FineractBaseFragment(), LedgerContract.View, lateinit var ledgerList: List + private var searchView: SearchView? = null + companion object { fun newInstance(): LedgerFragment = LedgerFragment() } @@ -82,7 +87,12 @@ class LedgerFragment : FineractBaseFragment(), LedgerContract.View, } override fun onRefresh() { - ledgerPresenter.getLedgersPage() + if (searchView!!.query.toString().isEmpty()) { + ledgerPresenter.getLedgersPage() + } else { + ledgerPresenter.searchLedger(ledgerList, searchView!!.query.toString()) + } + hideProgressbar() } override fun showLedgers(ledgers: List) { @@ -106,7 +116,7 @@ class LedgerFragment : FineractBaseFragment(), LedgerContract.View, private fun setUpSearchInterface(menu: Menu?) { val searchManager = activity?.getSystemService(Context.SEARCH_SERVICE) as? SearchManager - val searchView = menu?.findItem(R.id.ledger_search)?.actionView as? SearchView + searchView = menu?.findItem(R.id.ledger_search)?.actionView as? SearchView searchView?.setSearchableInfo(searchManager?.getSearchableInfo(activity?.componentName)) diff --git a/app/src/main/java/org/apache/fineract/ui/online/customers/customerlist/CustomersFragment.java b/app/src/main/java/org/apache/fineract/ui/online/customers/customerlist/CustomersFragment.java index b4d80d1f..9c265688 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/customers/customerlist/CustomersFragment.java +++ b/app/src/main/java/org/apache/fineract/ui/online/customers/customerlist/CustomersFragment.java @@ -6,6 +6,7 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; + import androidx.annotation.Nullable; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.transition.TransitionManager; @@ -13,6 +14,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.appcompat.widget.SearchView; + import android.text.TextUtils; import android.view.LayoutInflater; import android.view.Menu; @@ -96,6 +98,7 @@ public class CustomersFragment extends FineractBaseFragment implements Customers private Integer detailsCustomerPosition; private boolean isNewCustomer = false; private SweetUIErrorHandler sweetUIErrorHandler; + private SearchView searchView; public static CustomersFragment newInstance() { CustomersFragment fragment = new CustomersFragment(); @@ -143,8 +146,13 @@ public void onResume() { @Override public void onRefresh() { - customerPresenter.fetchCustomers(0, false); sweetUIErrorHandler.hideSweetErrorLayoutUI(rvCustomers, layoutError); + if (llSearch.getVisibility() == View.VISIBLE) { + findCustomer(searchView.getQuery().toString()); + } else { + customerPresenter.fetchCustomers(0, false); + } + hideProgressbar(); } @OnClick(R.id.btn_try_again) @@ -264,7 +272,7 @@ private void setUpSearchInterface(Menu menu) { SearchManager manager = (SearchManager) getActivity(). getSystemService(Context.SEARCH_SERVICE); - SearchView searchView = (SearchView) menu.findItem( + searchView = (SearchView) menu.findItem( R.id.menu_customer_search).getActionView(); searchView.setSearchableInfo(manager.getSearchableInfo(getActivity().getComponentName())); diff --git a/app/src/main/java/org/apache/fineract/ui/online/identification/identificationlist/IdentificationsFragment.java b/app/src/main/java/org/apache/fineract/ui/online/identification/identificationlist/IdentificationsFragment.java index 733b6883..84792e08 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/identification/identificationlist/IdentificationsFragment.java +++ b/app/src/main/java/org/apache/fineract/ui/online/identification/identificationlist/IdentificationsFragment.java @@ -4,11 +4,13 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; + import androidx.annotation.Nullable; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.appcompat.widget.SearchView; + import android.text.TextUtils; import android.view.LayoutInflater; import android.view.Menu; @@ -63,6 +65,7 @@ public class IdentificationsFragment extends FineractBaseFragment implements private List identifications; private String customerIdentifier; + private SearchView searchView; public static IdentificationsFragment newInstance(String identifier) { IdentificationsFragment fragment = new IdentificationsFragment(); @@ -114,7 +117,13 @@ public void onResume() { @Override public void onRefresh() { - identificationsPresenter.fetchIdentifications(customerIdentifier); + if (searchView.getQuery().toString().isEmpty()) { + identificationsPresenter.fetchIdentifications(customerIdentifier); + } else { + identificationsPresenter.searchIdentifications(identifications, + searchView.getQuery().toString()); + } + hideProgressbar(); } @Override @@ -201,7 +210,7 @@ private void setUpSearchInterface(Menu menu) { SearchManager manager = (SearchManager) getActivity(). getSystemService(Context.SEARCH_SERVICE); - final SearchView searchView = (SearchView) menu.findItem( + searchView = (SearchView) menu.findItem( R.id.identification_search).getActionView(); searchView.setSearchableInfo(manager.getSearchableInfo(getActivity().getComponentName())); diff --git a/app/src/main/java/org/apache/fineract/ui/online/loanaccounts/loanaccountlist/LoanAccountsFragment.java b/app/src/main/java/org/apache/fineract/ui/online/loanaccounts/loanaccountlist/LoanAccountsFragment.java index 7862fca1..42cb7bb0 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/loanaccounts/loanaccountlist/LoanAccountsFragment.java +++ b/app/src/main/java/org/apache/fineract/ui/online/loanaccounts/loanaccountlist/LoanAccountsFragment.java @@ -4,11 +4,13 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; + import androidx.annotation.Nullable; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import androidx.appcompat.widget.SearchView; + import android.text.TextUtils; import android.view.LayoutInflater; import android.view.Menu; @@ -63,6 +65,7 @@ public class LoanAccountsFragment extends FineractBaseFragment implements LoanAc private String customerIdentifier; private List loanAccounts; + private SearchView searchView; public static LoanAccountsFragment newInstance(String customerIdentifier) { LoanAccountsFragment fragment = new LoanAccountsFragment(); @@ -105,7 +108,13 @@ public void onResume() { @Override public void onRefresh() { - customerLoansPresenter.fetchCustomerLoanAccounts(customerIdentifier, 0, false); + if (searchView.getQuery().toString().isEmpty()) { + customerLoansPresenter.fetchCustomerLoanAccounts(customerIdentifier, 0, false); + } else { + customerLoansPresenter.searchLoanAccounts(loanAccounts, + searchView.getQuery().toString()); + } + hideProgressbar(); } @OnClick(R.id.btn_try_again) @@ -232,7 +241,7 @@ private void setUpSearchInterface(Menu menu) { SearchManager searchManager = (SearchManager) getActivity(). getSystemService(Context.SEARCH_SERVICE); - SearchView searchView = (SearchView) menu.findItem(R.id.loan_account_search) + searchView = (SearchView) menu.findItem(R.id.loan_account_search) .getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity() .getComponentName())); diff --git a/app/src/main/java/org/apache/fineract/ui/online/teller/TellerFragment.kt b/app/src/main/java/org/apache/fineract/ui/online/teller/TellerFragment.kt index 9a889297..9196a7cd 100644 --- a/app/src/main/java/org/apache/fineract/ui/online/teller/TellerFragment.kt +++ b/app/src/main/java/org/apache/fineract/ui/online/teller/TellerFragment.kt @@ -3,12 +3,12 @@ package org.apache.fineract.ui.online.teller import android.app.SearchManager import android.content.Context import android.os.Bundle -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.appcompat.widget.SearchView import android.text.TextUtils import android.view.* +import androidx.appcompat.widget.SearchView +import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import kotlinx.android.synthetic.main.fragment_teller.* import kotlinx.android.synthetic.main.layout_exception_handler.* import org.apache.fineract.R @@ -30,6 +30,8 @@ class TellerFragment : FineractBaseFragment(), TellerContract.View, SwipeRefresh lateinit var tellerList: List + private var searchView: SearchView? = null + companion object { fun newInstance(): TellerFragment = TellerFragment().apply { val args = Bundle() @@ -88,7 +90,12 @@ class TellerFragment : FineractBaseFragment(), TellerContract.View, SwipeRefresh } override fun onRefresh() { - tellPresenter.fetchTellers() + if (searchView!!.query.toString().isEmpty()) { + tellPresenter.fetchTellers() + } else { + tellPresenter.searchTeller(tellerList, searchView!!.query.toString()) + } + hideProgressbar() } override fun showEmptyTellers() { @@ -106,7 +113,7 @@ class TellerFragment : FineractBaseFragment(), TellerContract.View, SwipeRefresh private fun setUpSearchInterface(menu: Menu?) { val searchManager = activity?.getSystemService(Context.SEARCH_SERVICE) as? SearchManager - val searchView = menu?.findItem(R.id.teller_search)?.actionView as? SearchView + searchView = menu?.findItem(R.id.teller_search)?.actionView as? SearchView searchView?.setSearchableInfo(searchManager?.getSearchableInfo(activity?.componentName)) diff --git a/app/src/main/java/org/apache/fineract/ui/product/ProductFragment.kt b/app/src/main/java/org/apache/fineract/ui/product/ProductFragment.kt index aa46396c..704197f2 100644 --- a/app/src/main/java/org/apache/fineract/ui/product/ProductFragment.kt +++ b/app/src/main/java/org/apache/fineract/ui/product/ProductFragment.kt @@ -10,6 +10,8 @@ import android.text.TextUtils import android.view.* import androidx.recyclerview.widget.RecyclerView import kotlinx.android.synthetic.main.fragment_product.* +import kotlinx.android.synthetic.main.fragment_product.layoutError +import kotlinx.android.synthetic.main.fragment_product.swipeContainer import kotlinx.android.synthetic.main.layout_exception_handler.* import org.apache.fineract.R import org.apache.fineract.data.models.product.Product @@ -31,6 +33,8 @@ class ProductFragment : FineractBaseFragment(), ProductContract.View, lateinit var productList: List + private var searchView: SearchView? = null + companion object { fun newInstance() = ProductFragment().apply { val args = Bundle() @@ -83,7 +87,12 @@ class ProductFragment : FineractBaseFragment(), ProductContract.View, } override fun onRefresh() { - productPresenter.getProductsPage() + if (searchView!!.query.toString().isEmpty()) { + productPresenter.getProductsPage() + } else { + productPresenter.searchProduct(productList, searchView!!.query.toString()) + } + hideProgressbar() } override fun showProduct(products: List) { @@ -102,7 +111,7 @@ class ProductFragment : FineractBaseFragment(), ProductContract.View, private fun setUpSearchInterface(menu: Menu?) { val searchManager = activity?.getSystemService(Context.SEARCH_SERVICE) as? SearchManager - val searchView = menu?.findItem(R.id.product_search)?.actionView as? SearchView + searchView = menu?.findItem(R.id.product_search)?.actionView as? SearchView searchView?.setSearchableInfo(searchManager?.getSearchableInfo(activity?.componentName))