@Test public void testRemoveScreen () { ScreenManager<IScreen> manager = this.createScreenManager(); manager.removeScreen("not-existent-screen"); assertNull(manager.getScreenByName("not-existent-screen")); manager.addScreen("dummy_screen", new DummyScreen()); assertNotNull(manager.getScreenByName("dummy_screen")); manager.removeScreen("dummy_screen"); assertEquals(true, manager.getScreenByName("dummy_screen") == null); }
@Override public void removeScreen(String name) { if (name == null) { throw new NullPointerException(TAG_NAME_CANNOT_NULL); } if (name.isEmpty()) { throw new IllegalArgumentException(TAG_NAME_CANNOT_EMPTY); } IScreen screen = this.screens.get(name); if (screen != null) { screen.onStop(); this.activeScreens.removeFirst(screen); this.cachedScreenList.removeFirst(screen); } this.screens.remove(name); Gdx.app.debug(TAG_SCREENS, "remove screen: " + name); }
DefaultScreenManager implements ScreenManager<IScreen> { @Override public void removeScreen(String name) { if (name == null) { throw new NullPointerException(TAG_NAME_CANNOT_NULL); } if (name.isEmpty()) { throw new IllegalArgumentException(TAG_NAME_CANNOT_EMPTY); } IScreen screen = this.screens.get(name); if (screen != null) { screen.onStop(); this.activeScreens.removeFirst(screen); this.cachedScreenList.removeFirst(screen); } this.screens.remove(name); Gdx.app.debug(TAG_SCREENS, "remove screen: " + name); } }
DefaultScreenManager implements ScreenManager<IScreen> { @Override public void removeScreen(String name) { if (name == null) { throw new NullPointerException(TAG_NAME_CANNOT_NULL); } if (name.isEmpty()) { throw new IllegalArgumentException(TAG_NAME_CANNOT_EMPTY); } IScreen screen = this.screens.get(name); if (screen != null) { screen.onStop(); this.activeScreens.removeFirst(screen); this.cachedScreenList.removeFirst(screen); } this.screens.remove(name); Gdx.app.debug(TAG_SCREENS, "remove screen: " + name); } DefaultScreenManager(); }
DefaultScreenManager implements ScreenManager<IScreen> { @Override public void removeScreen(String name) { if (name == null) { throw new NullPointerException(TAG_NAME_CANNOT_NULL); } if (name.isEmpty()) { throw new IllegalArgumentException(TAG_NAME_CANNOT_EMPTY); } IScreen screen = this.screens.get(name); if (screen != null) { screen.onStop(); this.activeScreens.removeFirst(screen); this.cachedScreenList.removeFirst(screen); } this.screens.remove(name); Gdx.app.debug(TAG_SCREENS, "remove screen: " + name); } DefaultScreenManager(); @Override void addScreen(String name, IScreen screen); @Override void removeScreen(String name); @Override void push(String name); @Override void leaveAllAndEnter(String name); @Override IScreen pop(); @Override IScreen getScreenByName(String name); @Override ObjectArrayList<IScreen> listScreens(); @Override ObjectArrayList<IScreen> listActiveScreens(); @Override void resize(int width, int height); @Override void update(); @Override void draw(); @Override void dispose(); }
DefaultScreenManager implements ScreenManager<IScreen> { @Override public void removeScreen(String name) { if (name == null) { throw new NullPointerException(TAG_NAME_CANNOT_NULL); } if (name.isEmpty()) { throw new IllegalArgumentException(TAG_NAME_CANNOT_EMPTY); } IScreen screen = this.screens.get(name); if (screen != null) { screen.onStop(); this.activeScreens.removeFirst(screen); this.cachedScreenList.removeFirst(screen); } this.screens.remove(name); Gdx.app.debug(TAG_SCREENS, "remove screen: " + name); } DefaultScreenManager(); @Override void addScreen(String name, IScreen screen); @Override void removeScreen(String name); @Override void push(String name); @Override void leaveAllAndEnter(String name); @Override IScreen pop(); @Override IScreen getScreenByName(String name); @Override ObjectArrayList<IScreen> listScreens(); @Override ObjectArrayList<IScreen> listActiveScreens(); @Override void resize(int width, int height); @Override void update(); @Override void draw(); @Override void dispose();  }