示例#1
0
  @Override
  public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
      if (!mSlidingMenu.isMenuShowing()) {
        Fragment category = getFragmentManager().findFragmentByTag(SettingsFragment.CATEGORY_TAG);
        if (category != null) {
          getFragmentManager()
              .beginTransaction()
              .replace(R.id.content_frame, SettingsFragment.newInstance(R.xml.settings_main))
              .commit();
        } else {
          mSlidingMenu.showMenu();
        }
        return true;
      } else {
        if (mConversationList.isShowingBlocked()) {
          mConversationList.setShowingBlocked(false);
        } else {
          finish();
        }
      }
    }

    return false;
  }
示例#2
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    menu.clear();

    if (mSlidingMenu.isMenuShowing() || mContent == null) {
      showBackButton(false);
      mConversationList.inflateToolbar(menu, inflater, this);
    } else {
      showBackButton(true);
      mContent.inflateToolbar(menu, inflater, this);
    }

    return super.onPrepareOptionsMenu(menu);
  }