Search in sources :

Example 1 with DiscoveryAdapter

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

the class DiscoveryFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    recyclerView = (RecyclerView) inflater.inflate(R.layout.discovery_recycler_view, container, false);
    final DiscoveryAdapter adapter = new DiscoveryAdapter(viewModel.inputs);
    recyclerView.setAdapter(adapter);
    final LinearLayoutManager layoutManager = new LinearLayoutManager(recyclerView.getContext());
    recyclerView.setLayoutManager(layoutManager);
    recyclerViewPaginator = new RecyclerViewPaginator(recyclerView, viewModel.inputs::nextPage);
    viewModel.outputs.activity().compose(bindToLifecycle()).compose(observeForUI()).subscribe(adapter::takeActivity);
    viewModel.outputs.projects().compose(bindToLifecycle()).compose(observeForUI()).subscribe(adapter::takeProjects);
    viewModel.outputs.shouldShowOnboardingView().compose(bindToLifecycle()).compose(observeForUI()).subscribe(adapter::setShouldShowOnboardingView);
    viewModel.outputs.showActivityFeed().compose(bindToLifecycle()).compose(observeForUI()).subscribe(__ -> startActivityFeedActivity());
    viewModel.outputs.showActivityUpdate().compose(bindToLifecycle()).compose(observeForUI()).subscribe(this::startActivityUpdateActivity);
    viewModel.outputs.showProject().compose(bindToLifecycle()).compose(observeForUI()).subscribe(projectAndRefTag -> this.startProjectActivity(projectAndRefTag.first, projectAndRefTag.second));
    viewModel.outputs.showLoginTout().compose(bindToLifecycle()).compose(observeForUI()).subscribe(__ -> this.startLoginToutActivity());
    return recyclerView;
}
Also used : RecyclerViewPaginator(com.kickstarter.libs.RecyclerViewPaginator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DiscoveryAdapter(com.kickstarter.ui.adapters.DiscoveryAdapter) Nullable(android.support.annotation.Nullable)

Aggregations

Nullable (android.support.annotation.Nullable)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerViewPaginator (com.kickstarter.libs.RecyclerViewPaginator)1 DiscoveryAdapter (com.kickstarter.ui.adapters.DiscoveryAdapter)1