Esempio n. 1
0
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    menu.findItem(R.id.publish).setVisible(AppSettings.getFabBtnType() == 1);

    if (OfflineService.getInstance() == null
        || OfflineService.getInstance().getStatus() == OfflineService.OfflineStatus.init
        || OfflineService.getInstance().getStatus() == OfflineService.OfflineStatus.finished) {
      menu.findItem(R.id.toggle_offline).setVisible(true);
      menu.findItem(R.id.stop_offline).setVisible(false);
    } else {
      menu.findItem(R.id.toggle_offline).setVisible(false);
      menu.findItem(R.id.stop_offline).setVisible(true);
    }
    menu.findItem(R.id.notification_settings)
        .setVisible(menuFragment.getSelectedId() == MenuFragment.MENU_NOTIFICATION);

    return super.onPrepareOptionsMenu(menu);
  }
Esempio n. 2
0
  @Override
  protected void onResume() {
    super.onResume();

    // 修复偶尔Fab按钮不见了
    if (menuFragment != null && menuFragment.getSelectedId() == 1) {
      if (fabBtn.getVisibility() != View.VISIBLE) {
        fabBtn.setVisibility(View.VISIBLE);
      }
    }

    if (!AppContext.isLoggedIn()) {
      finish();

      return;
    }

    if (AppContext.getAccount().getAccessToken().isExpired()) {
      requestLogin(this, AppContext.getAccount());
    }

    invalidateOptionsMenu();
  }