@Override
  public void onBackPressed() {
    if (mNavigationDrawerFragment.isDrawerOpen()) {
      mNavigationDrawerFragment.closeDrawer();
      return;
    }

    if ((System.currentTimeMillis() - exitTime) > 2000) {
      Toast.makeText(this, "再按一次退出V2EX", Toast.LENGTH_LONG).show();
      exitTime = System.currentTimeMillis();
    } else {
      finish();
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    UmengUpdateAgent.setDefault();
    UmengUpdateAgent.update(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mDrawerLayout = (ViewGroup) findViewById(R.id.drawer_layout);
    mNavigationDrawerFragment =
        (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.left_drawer);
    mTitle = getTitle();

    mFavoriteTabTitles = getResources().getStringArray(R.array.v2ex_favorite_tab_titles);
    mFavoriteTabPaths = getResources().getStringArray(R.array.v2ex_favorite_tab_paths);
    mMainTitles = getResources().getStringArray(R.array.v2ex_nav_main_titles);

    mSpinnerAdapter = new SpinnerAdapter(this, mFavoriteTabTitles);

    ActionBar supportActionBar = getSupportActionBar();
    supportActionBar.setCustomView(R.layout.actionbar_custom_spinner);
    mActionbarCustom = supportActionBar.getCustomView();
    Spinner spinner = (Spinner) supportActionBar.getCustomView().findViewById(R.id.spinner);
    spinner.setAdapter(mSpinnerAdapter);
    //        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
    //            @Override
    //            public void onItemSelected(AdapterView<?> parent, View view, int position, long
    // id) {
    //                TopicsFragment fragment = new TopicsFragment();
    //                Bundle bundle = new Bundle();
    //                mSpinnerAdapter.setCheckPos(position);
    //                bundle.putString("tab", mFavoriteTabPaths[position]);
    //                bundle.putBoolean("attach_main", true);
    //                bundle.putBoolean("show_menu", false);
    //                fragment.setArguments(bundle);
    //
    //                FragmentTransaction fragmentTransaction =
    // getFragmentManager().beginTransaction();
    //                fragmentTransaction.replace(R.id.container, fragment,
    // mFavoriteTabTitles[position]).commit();
    //            }
    //
    //            @Override
    //            public void onNothingSelected(AdapterView<?> parent) {
    //
    //            }
    //        });

    // Set up the drawer.
    mNavigationDrawerFragment.setUp(
        R.id.left_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));

    // ActionBar actionBar = getSupportActionBar();
    // actionBar.setDisplayHomeAsUpEnabled(true);
    // actionBar.setHomeButtonEnabled(true);
    // actionBar.setDisplayShowTitleEnabled(true);

    if (mIsLogin) initAccount();
  }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   if (!mNavigationDrawerFragment.isDrawerOpen()) {
     restoreActionBar();
     return true;
   }
   return super.onCreateOptionsMenu(menu);
 }
  // 刷新用户资料:包括节点收藏,话题收藏等
  public void initAccount() {
    if (mNavigationDrawerFragment.getCurrentSelectedPosition() != 4)
      AccountUtils.refreshFavoriteNodes(this, null);

    AccountUtils.refreshNotificationCount(
        this,
        new AccountUtils.OnAccountNotificationCountListener() {
          @Override
          public void onAccountNotificationCount(int count) {
            MessageUtils.showMiddleToast(MainActivity.this, "你有 " + count + " 条未读提醒");
          }
        });
  }