Ejemplo n.º 1
0
  private void setupFragmentsFromExtras(Bundle extras) {

    Group group = extras.getParcelable(INTENT_EXTRAS_GROUP);
    Sender sender = extras.getParcelable(INTENT_EXTRAS_SENDER);
    if (group == null) {
      throw new RuntimeException("Group should not be null");
    }
    ActionBar actionBar = getSupportActionBar();
    // we want to always show up arrow due to always having stuff above us
    if (group.getId() == -1) {
      nw_main.setCheckedItem(R.id.navigation_allSenders);
      // if it's not all senders -> show up arrow
    } else if (actionBar != null) {
      actionBar.setHomeAsUpIndicator(0);
    }
    if (sender != null) {
      addFragment(CommandListFragment.newInstance(group, sender), R.id.fl_contentFrame);
    } else {
      addFragment(
          SenderListFragment.newInstance(group),
          R.id.fl_contentFrame,
          SenderListFragment.FRAGMENT_TAG,
          false);
    }
  }
Ejemplo n.º 2
0
 @Override
 public boolean onNavigationItemSelected(MenuItem menuItem) {
   // clear back stack on nav drawer click
   getSupportFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
   switch (menuItem.getItemId()) {
     case R.id.navigation_groups:
       replaceFragment(GroupListFragment.newInstance(), R.id.fl_contentFrame);
       break;
     case R.id.navigation_allSenders:
       replaceFragment(SenderListFragment.newInstance(getAllSendersGroup()), R.id.fl_contentFrame);
       break;
     case R.id.navigation_history:
       replaceFragment(HistoryListFragment.newInstance(), R.id.fl_contentFrame);
       break;
     default:
       return false;
   }
   menuItem.setChecked(true);
   dl_main.closeDrawer(nw_main);
   return true;
 }
Ejemplo n.º 3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_drawer);
    DaggerGroupComponent.builder()
        .applicationComponent(getApplicationComponent())
        .groupModule(new GroupModule(getAllSendersGroup()))
        .build()
        .inject(this);

    ButterKnife.bind(this);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    setupDrawer();

    if (savedInstanceState == null) {
      Bundle extras = getIntent().getExtras();
      // need to check if group not null since there are some weird stuff going on when using the
      // launcher
      if (extras != null && extras.getParcelable(INTENT_EXTRAS_GROUP) != null) {
        setupFragmentsFromExtras(extras);
      } else {
        boolean doesGroupsExists =
            getSharedPreferences(SHARED_PREFS_NAME, 0)
                .getBoolean(SHARED_PREFS_GROUPS_EXISTS_KEY, false);
        if (doesGroupsExists) {
          addFragment(GroupListFragment.newInstance(), R.id.fl_contentFrame);
        } else {
          addFragment(SenderListFragment.newInstance(getAllSendersGroup()), R.id.fl_contentFrame);
          nw_main.setCheckedItem(R.id.navigation_allSenders);
        }
      }

      if (isFirstLaunch()) {
        createAllSendersGroupInteractor.execute(
            new LoggingSubscriber<Long>(), Schedulers.newThread(), AndroidSchedulers.mainThread());
        setFirstLaunchDone();
      }
    }
  }