Ejemplo n.º 1
0
 public static SessionsFragment newInstance(boolean shouldRefresh) {
   SessionsFragment fragment = new SessionsFragment();
   Bundle args = new Bundle();
   args.putBoolean(ARG_SHOULD_REFRESH, shouldRefresh);
   fragment.setArguments(args);
   return fragment;
 }
Ejemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LocaleUtil.initLocale(this);

    boolean shouldRefresh = getIntent().getBooleanExtra(EXTRA_SHOULD_REFRESH, false);

    binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
    DataBindingUtil.bind(binding.navView.getHeaderView(0));

    MainApplication.getComponent(this).inject(this);

    subscription.add(
        brokerProvider
            .get()
            .observe()
            .subscribe(
                page -> {
                  toggleToolbarElevation(page.shouldToggleToolbar());
                  changePage(page.getTitleResId(), page.createFragment());
                  binding.navView.setCheckedItem(page.getMenuId());
                }));

    initView();
    AppUtil.setTaskDescription(
        this, getString(R.string.all_sessions), AppUtil.getThemeColorPrimary(this));

    if (savedInstanceState == null) {
      replaceFragment(SessionsFragment.newInstance(shouldRefresh));
    } else {
      binding.toolbar.setTitle(savedInstanceState.getString(EXTRA_TITLE));
    }
    getSupportFragmentManager().addOnBackStackChangedListener(this);
  }