public static <T extends Screen> T fromView(View view) { return Screen.fromScoop(Scoop.fromView(view)); }
public static boolean equals(Screen previous, Screen next) { if (previous == null || next == null) { return false; } return previous.equals(next); }
public View inflateView( Scoop scoop, Screen screen, ViewGroup viewGroup) { View view = scoop.inflate(screen.getLayout(), viewGroup, false); return view; } }
private void swap(RouteChange routeChange) { final Scoop currentScoop = getActiveScoop(routeChange); final ScreenSwap screenSwap = routeChange.toScreenSwap(); Screen previousScreen = screenSwap.previous; Screen nextScreen = screenSwap.next; final View prevView = active; ViewController nextViewController = null; if (active != null && previousScreen != null) { previousScreen.saveViewState(active); } if (nextScreen == null) { active = null; } else if (nextScreen.getController() != null) { nextViewController = getViewControllerInflater().inflateViewController(currentScoop, nextScreen.getController(), this); active = inflateViewFromController(nextViewController, currentScoop); nextScreen.restoreViewState(active); } else { active = inflateLayout(nextScreen, currentScoop); nextScreen.restoreViewState(active); } isTransitioning = true; ScreenTransition transition; if (screenSwap.direction == TransitionDirection.ENTER) { transition = getTransition(nextViewController, screenSwap.direction); } else { transition = getTransition(ViewController.fromView(prevView), screenSwap.direction); } transition.transition(this, prevView, active, this); }
private void swap(RouteChange routeChange) { final Scoop currentScoop = getActiveScoop(routeChange); final ScreenSwap screenSwap = routeChange.toScreenSwap(); Screen previousScreen = screenSwap.previous; Screen nextScreen = screenSwap.next; final View prevView = active; ViewController nextViewController = null; if (active != null && previousScreen != null) { previousScreen.saveViewState(active); } if (nextScreen == null) { active = null; } else if (nextScreen.getController() != null) { nextViewController = getViewControllerInflater().inflateViewController(currentScoop, nextScreen.getController(), this); active = inflateViewFromController(nextViewController, currentScoop); nextScreen.restoreViewState(active); } else { active = inflateLayout(nextScreen, currentScoop); nextScreen.restoreViewState(active); } isTransitioning = true; ScreenTransition transition; if (screenSwap.direction == TransitionDirection.ENTER) { transition = getTransition(nextViewController, screenSwap.direction); } else { transition = getTransition(ViewController.fromView(prevView), screenSwap.direction); } transition.transition(this, prevView, active, this); }
public static boolean equals(Screen previous, Screen next) { if (previous == null || next == null) { return false; } return previous.equals(next); }
private void swap(RouteChange routeChange) { final Scoop currentScoop = getActiveScoop(routeChange); final ScreenSwap screenSwap = routeChange.toScreenSwap(); Screen previousScreen = screenSwap.previous; Screen nextScreen = screenSwap.next; final View prevView = active; ViewController nextViewController = null; if (active != null && previousScreen != null) { previousScreen.saveViewState(active); } if (nextScreen == null) { active = null; } else if (nextScreen.getController() != null) { nextViewController = getViewControllerInflater().inflateViewController(currentScoop, nextScreen.getController(), this); active = inflateViewFromController(nextViewController, currentScoop); nextScreen.restoreViewState(active); } else { active = inflateLayout(nextScreen, currentScoop); nextScreen.restoreViewState(active); } isTransitioning = true; ScreenTransition transition; if (screenSwap.direction == TransitionDirection.ENTER) { transition = getTransition(nextViewController, screenSwap.direction); } else { transition = getTransition(ViewController.fromView(prevView), screenSwap.direction); } transition.transition(this, prevView, active, this); }
public static <T extends Screen> T fromController(ViewController controller) { return Screen.fromScoop(controller.getScoop()); }
public View inflateView( Scoop scoop, Screen screen, ViewGroup viewGroup) { View view = scoop.inflate(screen.getLayout(), viewGroup, false); return view; } }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof Screen)) { return false; } Screen screen = (Screen) o; return equals(screen.getClass(), getClass()); }
public static <T extends Screen> T fromView(View view) { return Screen.fromScoop(Scoop.fromView(view)); }
public View inflateView( Scoop scoop, Screen screen, ViewGroup viewGroup) { View view = scoop.inflate(screen.getLayout(), viewGroup, false); return view; } }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof Screen)) { return false; } Screen screen = (Screen) o; return equals(screen.getClass(), getClass()); }
public static <T extends Screen> T fromController(ViewController controller) { return Screen.fromScoop(controller.getScoop()); }
public Scoop create(Scoop rootScoop, Scoop currentScreenScoop, List<Screen> fromPath, List<Screen> toPath) { Scoop finalScoop = null; List<Scoop> scoops = getCurrentScoops(fromPath, currentScreenScoop); int index = 0; while (index < fromPath.size() && currentScreenScoop != null) { Screen fromScreen = safeElementGet(fromPath, index); Screen toScreen = safeElementGet(toPath, index); Scoop scoop = scoops.get(index); if (Screen.equals(fromScreen, toScreen)) { finalScoop = scoop; } else { scoop.destroy(); break; } index++; } while (index < toPath.size()) { Screen toScreen = safeElementGet(toPath, index); if (finalScoop == null) { finalScoop = rootScoop; } finalScoop = screenScoopFactory.createScreenScoop(toScreen, finalScoop); index++; } return finalScoop; }
public static Scoop extend(final Scoop parentScoop, final Object... modules) { final Screen parentScreen = Screen.fromScoop(parentScoop); final Scoop.Builder scoopBuilder = new Scoop.Builder(parentScreen.getClass().getSimpleName(), parentScoop) .service(Screen.SERVICE_NAME, parentScreen); final DaggerInjector daggerInjector = DaggerInjector.fromScoop(parentScoop).extend(modules); return scoopBuilder .service(DaggerInjector.SERVICE_NAME, daggerInjector).build(); } }
public Scoop create(Scoop rootScoop, Scoop currentScreenScoop, List<Screen> fromPath, List<Screen> toPath) { Scoop finalScoop = null; List<Scoop> scoops = getCurrentScoops(fromPath, currentScreenScoop); int index = 0; while (index < fromPath.size() && currentScreenScoop != null) { Screen fromScreen = safeElementGet(fromPath, index); Screen toScreen = safeElementGet(toPath, index); Scoop scoop = scoops.get(index); if (Screen.equals(fromScreen, toScreen)) { finalScoop = scoop; } else { scoop.destroy(); break; } index++; } while (index < toPath.size()) { Screen toScreen = safeElementGet(toPath, index); if (finalScoop == null) { finalScoop = rootScoop; } finalScoop = screenScoopFactory.createScreenScoop(toScreen, finalScoop); index++; } return finalScoop; }
@Test public void screenAddedToScoop() { ScreenScoopFactory screenScoopFactory = new ScreenScoopFactory(); Scoop parentScoop = new Scoop.Builder("root").build(); Screen screen = new TestScreen(); Scoop childScoop = screenScoopFactory.createScreenScoop(screen, parentScoop); Assert.assertEquals(screen, Screen.fromScoop(childScoop)); }
public void goTo(Screen nextScreen) { if (tryHandleEmptyBackstack(nextScreen)) { return; } List<Screen> fromPath = backStack.asList(); if (Screen.equals(backStack.peek(), nextScreen)) { return; } backStack.push(nextScreen); performRouteChange(fromPath, backStack.asList(), TransitionDirection.ENTER); }
public static <T extends Screen> T fromView(View view) { return Screen.fromScoop(Scoop.fromView(view)); }