Exemplo n.º 1
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    MenuItem item = menu.findItem(R.id.share_repo);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      item.setIcon(getResources().getDrawable(R.drawable.abc_ic_menu_share_mtrl_alpha, getTheme()));
    } else {
      item.setIcon(getResources().getDrawable(R.drawable.abc_ic_menu_share_mtrl_alpha));
    }

    if (currentRepo == null || currentRepo.parent == null) {
      MenuItem parentItem = menu.findItem(R.id.action_show_parent);
      if (parentItem != null) {
        menu.removeItem(parentItem.getItemId());
      }
    }

    if (repoStarred != null) {
      MenuItem starredItem = menu.findItem(R.id.action_repo_star);
      if (starredItem != null) {
        starredItem.setTitle(repoStarred ? R.string.menu_unstar : R.string.menu_star);
      }
    }

    if (repoWatched != null) {
      MenuItem watchedItem = menu.findItem(R.id.action_repo_watch);
      if (watchedItem != null) {
        watchedItem.setTitle(repoWatched ? R.string.menu_unwatch : R.string.menu_watch);
      }
    }

    MenuItem menuChangeBranch = menu.findItem(R.id.action_repo_change_branch);

    Drawable changeBranch =
        new IconicsDrawable(this, Octicons.Icon.oct_git_branch).actionBar().colorRes(R.color.white);

    if (menuChangeBranch != null) {
      menuChangeBranch.setIcon(changeBranch);
    }

    return true;
  }