You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by ra...@apache.org on 2019/05/31 17:22:04 UTC
[fineract-cn-mobile] 04/05: FINCN-151 : Filters fixed in
Identification Cards
This is an automated email from the ASF dual-hosted git repository.
rajanmaurya154 pushed a commit to branch development
in repository https://gitbox.apache.org/repos/asf/fineract-cn-mobile.git
commit bca0f71d05357c68a2947981abdd34e4702349bf
Author: miPlodder <ac...@gmail.com>
AuthorDate: Sun May 5 15:21:45 2019 +0530
FINCN-151 : Filters fixed in Identification Cards
---
.../IdentificationsContract.java | 4 +--
.../IdentificationsFragment.java | 9 +++---
.../IdentificationsPresenter.java | 32 ++++++----------------
3 files changed, 14 insertions(+), 31 deletions(-)
diff --git a/app/src/main/java/org/apache/fineract/ui/online/identification/identificationlist/IdentificationsContract.java b/app/src/main/java/org/apache/fineract/ui/online/identification/identificationlist/IdentificationsContract.java
index 5127e53..4812a3f 100644
--- a/app/src/main/java/org/apache/fineract/ui/online/identification/identificationlist/IdentificationsContract.java
+++ b/app/src/main/java/org/apache/fineract/ui/online/identification/identificationlist/IdentificationsContract.java
@@ -27,13 +27,13 @@ public interface IdentificationsContract {
void showMessage(String message);
- void searchIdentificationList(Identification identification);
+ void searchedIdentifications(List<Identification> identification);
}
interface Presenter {
void fetchIdentifications(String customerIdentifier);
- void searchIdentifications(String identifier, String number);
+ void searchIdentifications(List<Identification> identificationList, String query);
}
}
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 fa7613e..c9e2193 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
@@ -29,7 +29,6 @@ import org.apache.fineract.ui.online.identification.identificationdetails.Identi
import org.apache.fineract.utils.ConstantKeys;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import javax.inject.Inject;
@@ -175,8 +174,8 @@ public class IdentificationsFragment extends FineractBaseFragment implements
}
@Override
- public void searchIdentificationList(Identification identification) {
- identificationAdapter.setIdentifications(Collections.singletonList(identification));
+ public void searchedIdentifications(List<Identification> identification) {
+ identificationAdapter.setIdentifications(identification);
}
@Override
@@ -209,7 +208,7 @@ public class IdentificationsFragment extends FineractBaseFragment implements
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
- identificationsPresenter.searchIdentifications(customerIdentifier, query);
+ identificationsPresenter.searchIdentifications(identifications, query);
return false;
}
@@ -218,7 +217,7 @@ public class IdentificationsFragment extends FineractBaseFragment implements
if (TextUtils.isEmpty(newText)) {
identificationAdapter.setIdentifications(identifications);
}
-
+ identificationsPresenter.searchIdentifications(identifications, newText);
return false;
}
});
diff --git a/app/src/main/java/org/apache/fineract/ui/online/identification/identificationlist/IdentificationsPresenter.java b/app/src/main/java/org/apache/fineract/ui/online/identification/identificationlist/IdentificationsPresenter.java
index ed7d8e2..dd7f3b6 100644
--- a/app/src/main/java/org/apache/fineract/ui/online/identification/identificationlist/IdentificationsPresenter.java
+++ b/app/src/main/java/org/apache/fineract/ui/online/identification/identificationlist/IdentificationsPresenter.java
@@ -13,8 +13,10 @@ import java.util.List;
import javax.inject.Inject;
+import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
+import io.reactivex.functions.Predicate;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
@@ -83,33 +85,15 @@ public class IdentificationsPresenter extends BasePresenter<IdentificationsContr
}
@Override
- public void searchIdentifications(String identifier, String number) {
+ public void searchIdentifications(List<Identification> identificationList, final String query) {
checkViewAttached();
- getMvpView().showProgressbar();
-
- compositeDisposable.add(dataManagerCustomer.searchIdentifications(identifier, number)
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribeWith(new DisposableObserver<Identification>() {
-
+ getMvpView().searchedIdentifications(Observable.fromIterable(identificationList).
+ filter(new Predicate<Identification>() {
@Override
- public void onNext(Identification identification) {
- getMvpView().hideProgressbar();
- getMvpView().searchIdentificationList(identification);
+ public boolean test(Identification identification) {
+ return identification.getType().toLowerCase().contains(query.toLowerCase());
}
-
- @Override
- public void onError(Throwable e) {
- showExceptionError(e, context.getString
- (R.string.error_finding_identification));
- }
-
- @Override
- public void onComplete() {
-
- }
-
- }));
+ }).toList().blockingGet());
}