Пример #1
0
  /**
   * Creates a set of {@link ActionBar} navigation items for the given string resource IDs.
   *
   * <p>This implementation employs {@link ActionBar#NAVIGATION_MODE_LIST}.
   *
   * @param navigationResourceIds the array of String resource IDs for the navigation item titles
   * @since 1.1.0
   */
  protected void addNavigationItems(final int... navigationResourceIds) {

    ActionBar actionBar = getActionBar();

    if (actionBar != null) {

      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

      this.navigationResourceIds = navigationResourceIds;
      String[] stringResources = new String[navigationResourceIds.length];

      for (int i = 0; i < navigationResourceIds.length; i++) {

        stringResources[i] = getString(navigationResourceIds[i]);
      }

      ArrayAdapter<String> adapter =
          NavigationAdapter.newInstance(
              actionBar.getThemedContext(),
              R.layout.action_view_title_repo,
              android.R.id.text1,
              android.R.layout.simple_spinner_dropdown_item,
              accountService.getGitHubUsername(this),
              stringResources);

      actionBar.setListNavigationCallbacks(
          adapter,
          new ActionBar.OnNavigationListener() {

            @Override
            public boolean onNavigationItemSelected(int itemPosition, long itemId) {

              onTabSelected(navigationResourceIds[itemPosition]);
              return true;
            }
          });
    }
  }
Пример #2
0
  /**
   * Override this callback to initialize the activity with a custom subtitle.
   *
   * @return the subtitle to be set for this activity; defaults to the user's GitHub username
   * @since 1.1.0
   */
  protected String onInitSubtitle() {

    return accountService.getGitHubUsername(this);
  }