Skip to content

Mojtaba-Shafaei/AndroidRxSearchList

Repository files navigation

AndroidRxSearchList

ListView to show List of data and search inside it.

  • List refresh as changing the query text.
  • The changed texts(queries) emmit through an Observable.

sample AndroidToolbarBadgeButton image sample AndroidToolbarBadgeButton image

Methods

Base class name "RxSearchList"

  • public static RxSearchList create(...)
  • public RxSearchList setShowLogo(boolean visible)
  • public RxSearchList show(FragmentManager manager)
  • public RxSearchList showWithQuery(FragmentManager manager, String defaultQuery)
  • public Observable<Item> results()
  • public Observable<Boolean> onCancel()
  • public Observable<Boolean> onDismiss()
  • public void setState(Lce itemsObservable)

Sample

With using of RxBinding

  • Declare an instance of "RxSearchList" in onCreate() method of your Activity.
    rxSearchList = RxSearchList.create("the hint od search view", "the text of search view", false, null);

  • Bind click in onStart() method of your Activity.
    Use filter() to prevent performing duplicate queries at the first launch.

RxView.clicks(btnShowList)
    .map(t -> rxSearchList.setShowLogo(true))
    .map(t -> rxSearchList.showWithQuery(getSupportFragmentManager(), "job with code = 20"))
    .switchMap(t -> Observable.just("").filter(ss -> true))
    .mergeWith(rxSearchList.getQueryIntent())
    .switchMap(DataMocker::getList) // get query results from API/Local
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(rxSearchList::setState)

Be careful to dispose above Disposable in onPause() method.

Install

allprojects {
   repositories {
	...
	maven { url 'https://jitpack.io' }
   }
}
dependencies {
  implementation 'com.github.Mojtaba-Shafaei:AndroidRxSearchList:1.0.1'
}

Android Arsenal