Search in sources :

Example 1 with SearchAdapter

use of com.kickstarter.ui.adapters.SearchAdapter in project android-oss by kickstarter.

the class SearchActivity method onCreate.

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_layout);
    ButterKnife.bind(this);
    adapter = new SearchAdapter(this);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(adapter);
    paginator = new RecyclerViewPaginator(recyclerView, viewModel.inputs::nextPage);
    RxRecyclerView.scrollEvents(recyclerView).compose(bindToLifecycle()).filter(// Skip scroll events when y is 0, usually indicates new data
    scrollEvent -> scrollEvent.dy() != 0).observeOn(AndroidSchedulers.mainThread()).subscribe(__ -> InputUtils.hideKeyboard(this, getCurrentFocus()));
    viewModel.outputs.popularProjects().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(adapter::loadPopularProjects);
    viewModel.outputs.searchProjects().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(adapter::loadSearchProjects);
}
Also used : RecyclerViewPaginator(com.kickstarter.libs.RecyclerViewPaginator) SearchAdapter(com.kickstarter.ui.adapters.SearchAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerViewPaginator (com.kickstarter.libs.RecyclerViewPaginator)1 SearchAdapter (com.kickstarter.ui.adapters.SearchAdapter)1