Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
fix 279: Filter results retain in all activities
Browse files Browse the repository at this point in the history
  • Loading branch information
PatelVatsalB21 committed Mar 17, 2021
1 parent 592099e commit 4d82e66
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class AccountsFragment : FineractBaseFragment(), AccountContract.View, SwipeRefr

lateinit var accountList : List<Account>

private var searchView: SearchView? = null

companion object {
fun newInstance() = AccountsFragment()
}
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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()
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,6 +36,8 @@ class LedgerFragment : FineractBaseFragment(), LedgerContract.View,

lateinit var ledgerList: List<Ledger>

private var searchView: SearchView? = null

companion object {
fun newInstance(): LedgerFragment = LedgerFragment()
}
Expand Down Expand Up @@ -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<Ledger>) {
Expand All @@ -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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
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;
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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -63,6 +65,7 @@ public class IdentificationsFragment extends FineractBaseFragment implements

private List<Identification> identifications;
private String customerIdentifier;
private SearchView searchView;

public static IdentificationsFragment newInstance(String identifier) {
IdentificationsFragment fragment = new IdentificationsFragment();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -63,6 +65,7 @@ public class LoanAccountsFragment extends FineractBaseFragment implements LoanAc

private String customerIdentifier;
private List<LoanAccount> loanAccounts;
private SearchView searchView;

public static LoanAccountsFragment newInstance(String customerIdentifier) {
LoanAccountsFragment fragment = new LoanAccountsFragment();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,6 +30,8 @@ class TellerFragment : FineractBaseFragment(), TellerContract.View, SwipeRefresh

lateinit var tellerList: List<Teller>

private var searchView: SearchView? = null

companion object {
fun newInstance(): TellerFragment = TellerFragment().apply {
val args = Bundle()
Expand Down Expand Up @@ -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() {
Expand All @@ -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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,6 +33,8 @@ class ProductFragment : FineractBaseFragment(), ProductContract.View,

lateinit var productList: List<Product>

private var searchView: SearchView? = null

companion object {
fun newInstance() = ProductFragment().apply {
val args = Bundle()
Expand Down Expand Up @@ -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<Product>) {
Expand All @@ -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))

Expand Down

0 comments on commit 4d82e66

Please sign in to comment.