private static LocalDevice createLocalDevice() {
    try {
      UPnPFWDevice device = UPnPManager.instance().getUPnPLocalDevice();

      return new LocalDevice(
          device.getIdentity(),
          device.getType(),
          device.getDetails(),
          device.getIcon(),
          device.getServices());
    } catch (Throwable e) {
      throw new RuntimeException(e);
    }
  }
  @Override
  public void refresh() {
    List<Peer> peers = PeerManager.instance().getPeers();
    adapter.updateList(peers);

    refreshUPnPCount++;

    if (refreshUPnPCount % 5 == 0) {
      if (Engine.instance().isStarted()
          && ConfigurationManager.instance().getBoolean(Constants.PREF_KEY_NETWORK_USE_UPNP)) {
        UPnPManager.instance().refreshRemoteDevices();
      }
    }
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    setRetainInstance(true);

    if (Engine.instance().isStarted()
        && ConfigurationManager.instance().getBoolean(Constants.PREF_KEY_NETWORK_USE_UPNP)) {
      UPnPManager.instance().resume();
    }

    setupAdapter();

    if (getActivity() instanceof AbstractActivity) {
      ((AbstractActivity) getActivity()).addRefreshable(this);
    }
  }
  public LibraryMediator() {
    GUIMediator.setSplashScreenString(I18n.tr("Loading Library Window..."));

    idScanned = new HashSet<Integer>();

    getComponent(); // creates MAIN_PANEL

    scrollbarValues = new HashMap<Object, Integer>();

    splitPane =
        new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, getLibraryLeftPanel(), getLibraryRightPanel());
    splitPane.setContinuousLayout(true);
    splitPane.setResizeWeight(0.5);
    splitPane.addPropertyChangeListener(
        JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY,
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            JSplitPane splitPane = (JSplitPane) evt.getSource();
            int current = splitPane.getDividerLocation();
            if (current > LibraryLeftPanel.MAX_WIDTH) {
              splitPane.setDividerLocation(LibraryLeftPanel.MAX_WIDTH);
            } else if (current < LibraryLeftPanel.MIN_WIDTH) {
              splitPane.setDividerLocation(LibraryLeftPanel.MIN_WIDTH);
            }
          }
        });

    DividerLocationSettingUpdater.install(splitPane, UISettings.UI_LIBRARY_MAIN_DIVIDER_LOCATION);

    MAIN_PANEL.add(splitPane);

    httpServerManager = new HttpServerManager();
    httpServerManager.start(Constants.EXTERNAL_CONTROL_LISTENING_PORT);
    ((DesktopUPnPManager) UPnPManager.instance()).start();

    clerk = new DeviceDiscoveryClerk();
  }