@Override
 public void setVisibility(final int visibility) {
   if (visibility == View.VISIBLE) {
     profile = TouchManager.topProfile();
   } else {
     profile = null;
   }
   super.setVisibility(visibility);
 }
  /**
   * {@inheritDoc}
   *
   * @see org.emdev.ui.AbstractActivityController#beforeRecreate(android.app.Activity)
   */
  @Override
  public void beforeRecreate(final ViewerActivity activity) {
    final AppSettings newSettings = AppSettings.current();

    activity.setRequestedOrientation(newSettings.rotation.getOrientation());
    IUIManager.instance.setTitleVisible(activity, newSettings.showTitle, true);

    TouchManager.loadFromSettings(newSettings);
    KeyBindingsManager.loadFromSettings(newSettings);
  }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.ebookdroid.common.settings.listeners.IAppSettingsChangeListener#onAppSettingsChanged(org.ebookdroid.common.settings.AppSettings,
   *     org.ebookdroid.common.settings.AppSettings,
   *     org.ebookdroid.common.settings.AppSettings.Diff)
   */
  @Override
  public void onAppSettingsChanged(
      final AppSettings oldSettings, final AppSettings newSettings, final AppSettings.Diff diff) {
    final ViewerActivity activity = getManagedComponent();
    if (diff.isRotationChanged()) {
      if (bookSettings != null) {
        activity.setRequestedOrientation(bookSettings.getOrientation(newSettings));
      } else {
        activity.setRequestedOrientation(newSettings.rotation.getOrientation());
      }
    }

    if (diff.isFullScreenChanged()) {
      IUIManager.instance.setFullScreenMode(
          activity, activity.view.getView(), newSettings.fullScreen);
    }

    if (!diff.isFirstTime() && diff.isShowTitleChanged()) {
      IUIManager.instance.setTitleVisible(activity, newSettings.showTitle, false);
    }

    if (diff.isKeepScreenOnChanged()) {
      activity.view.getView().setKeepScreenOn(newSettings.keepScreenOn);
    }

    if (diff.isTapConfigChanged()) {
      TouchManager.loadFromSettings(newSettings);
    }

    if (diff.isKeyBindingChanged()) {
      KeyBindingsManager.loadFromSettings(newSettings);
    }

    if (diff.isPagesInMemoryChanged()) {
      getDocumentController().updateMemorySettings();
    }

    IUIManager.instance.invalidateOptionsMenu(getManagedComponent());
  }