Search in sources :

Example 1 with DiscoveryDrawerAdapter

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

the class DiscoveryActivity method onCreate.

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.discovery_layout);
    ButterKnife.bind(this);
    ((KSApplication) getApplication()).component().inject(this);
    drawerLayoutManager = new LinearLayoutManager(this);
    drawerRecyclerView.setLayoutManager(drawerLayoutManager);
    drawerAdapter = new DiscoveryDrawerAdapter(viewModel.inputs);
    drawerRecyclerView.setAdapter(drawerAdapter);
    final List<String> viewPagerTitles = Arrays.asList(homeString, popularString, newestString, endingSoonString, mostFundedString);
    pagerAdapter = new DiscoveryPagerAdapter(getSupportFragmentManager(), viewPagerTitles, viewModel.inputs);
    sortViewPager.setAdapter(pagerAdapter);
    sortTabLayout.setupWithViewPager(sortViewPager);
    viewModel.outputs.expandSortTabLayout().compose(bindToLifecycle()).compose(observeForUI()).subscribe(sortAppBarLayout::setExpanded);
    viewModel.outputs.updateToolbarWithParams().compose(bindToLifecycle()).compose(observeForUI()).subscribe(discoveryToolbar::loadParams);
    viewModel.outputs.updateParamsForPage().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(pagerAdapter::takeParams);
    viewModel.outputs.clearPages().compose(bindToLifecycle()).compose(observeForUI()).subscribe(pagerAdapter::clearPages);
    viewModel.outputs.rootCategoriesAndPosition().compose(bindToLifecycle()).observeOn(AndroidSchedulers.mainThread()).subscribe(cp -> pagerAdapter.takeCategoriesForPosition(cp.first, cp.second));
    viewModel.outputs.showBuildCheckAlert().compose(bindToLifecycle()).compose(observeForUI()).subscribe(this::showBuildAlert);
    viewModel.outputs.showInternalTools().compose(bindToLifecycle()).compose(observeForUI()).subscribe(__ -> internalTools.maybeStartInternalToolsActivity(this));
    viewModel.outputs.showLoginTout().compose(bindToLifecycle()).compose(observeForUI()).subscribe(__ -> this.startLoginToutActivity());
    viewModel.outputs.showProfile().compose(bindToLifecycle()).compose(observeForUI()).subscribe(__ -> this.startProfileActivity());
    viewModel.outputs.showSettings().compose(bindToLifecycle()).compose(observeForUI()).subscribe(__ -> this.startSettingsActivity());
    viewModel.outputs.navigationDrawerData().compose(bindToLifecycle()).compose(observeForUI()).subscribe(drawerAdapter::takeData);
    viewModel.outputs.drawerIsOpen().compose(bindToLifecycle()).compose(observeForUI()).subscribe(RxDrawerLayout.open(discoveryLayout, GravityCompat.START));
    RxDrawerLayout.drawerOpen(discoveryLayout, GravityCompat.START).skip(1).compose(bindToLifecycle()).compose(observeForUI()).subscribe(viewModel.inputs::openDrawer);
}
Also used : DiscoveryDrawerAdapter(com.kickstarter.ui.adapters.DiscoveryDrawerAdapter) DiscoveryPagerAdapter(com.kickstarter.ui.adapters.DiscoveryPagerAdapter) BindString(butterknife.BindString) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 BindString (butterknife.BindString)1 DiscoveryDrawerAdapter (com.kickstarter.ui.adapters.DiscoveryDrawerAdapter)1 DiscoveryPagerAdapter (com.kickstarter.ui.adapters.DiscoveryPagerAdapter)1