Exemplo n.º 1
0
 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
   super.onPostCreate(savedInstanceState);
   if (mDrawerToggle != null) {
     mDrawerToggle.syncState();
   }
   /// M: Google update activity title to actionbar in L in this callback, we need update
   /// actionbar again to correct it, if show in ACTION_MANAGE we need skip when
   /// not load out current root(get current as recent).
   RootInfo root = getCurrentRoot();
   if (!(mState.action == ACTION_MANAGE && root.isRecents())) {
     updateActionBar();
   }
 }
Exemplo n.º 2
0
  public void updateActionBar() {
    if (mRootsToolbar != null) {
      if (mState.action == ACTION_OPEN
          || mState.action == ACTION_GET_CONTENT
          || mState.action == ACTION_OPEN_TREE) {
        mRootsToolbar.setTitle(R.string.title_open);
      } else if (mState.action == ACTION_CREATE) {
        mRootsToolbar.setTitle(R.string.title_save);
      }
    }

    final RootInfo root = getCurrentRoot();
    final boolean showRootIcon = mShowAsDialog || (mState.action == ACTION_MANAGE);
    if (showRootIcon) {
      mToolbar.setNavigationIcon(root != null ? root.loadToolbarIcon(mToolbar.getContext()) : null);
      mToolbar.setNavigationContentDescription(R.string.drawer_open);
      mToolbar.setNavigationOnClickListener(null);
    } else {
      mToolbar.setNavigationIcon(R.drawable.ic_hamburger);
      mToolbar.setNavigationContentDescription(R.string.drawer_open);
      mToolbar.setNavigationOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              setRootsDrawerOpen(true);
            }
          });
    }

    if (mSearchExpanded) {
      mToolbar.setTitle(null);
      mToolbarStack.setVisibility(View.GONE);
      mToolbarStack.setAdapter(null);
    } else {
      if (mState.stack.size() <= 1) {
        mToolbar.setTitle(root.title);
        mToolbarStack.setVisibility(View.GONE);
        mToolbarStack.setAdapter(null);
      } else {
        mToolbar.setTitle(null);
        mToolbarStack.setVisibility(View.VISIBLE);
        mToolbarStack.setAdapter(mStackAdapter);

        mIgnoreNextNavigation = true;
        mToolbarStack.setSelection(mStackAdapter.getCount() - 1);
      }
    }
  }