Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"No services currently exists for key" on restoring History #228

Closed
edenman opened this issue Feb 10, 2017 · 1 comment
Closed

"No services currently exists for key" on restoring History #228

edenman opened this issue Feb 10, 2017 · 1 comment

Comments

@edenman
Copy link
Contributor

edenman commented Feb 10, 2017

I'm using Flow with a custom Dispatcher that supports showing multiple keys/screens at the same time (in my case, an underlying screen and modal(s) on top). When my Dispatcher is restoring History from a stopped state, I figure out which keys/screens need to be inflated, and then I call this helper method:

  private fun inflateNewView(screen: Screen, traversal: Traversal): View {
    val context = traversal.createContext(screen, activity)
    val layoutResId = screen.layoutResId()!!
    val inflated = LayoutInflater.from(context).inflate(layoutResId, screenContainer, false)
    inflated.tag = layoutResId
    val incomingState = traversal.getState(screen)
    incomingState.restore(inflated)
    return inflated
  }

However, it looks like PendingTraversal only sets up a context for the top of the History, so when I try to inflate one of the non-top screens, it blows up:

Caused by: java.lang.IllegalStateException: No services currently exists for key StayScreen(placeID=LaTaqueria)
      at flow.KeyManager.findServices(KeyManager.java:72)
      at flow.Traversal.createContext(Traversal.java:44)
      at mypackage.FlowDispatcher.inflateNewView(FlowDispatcher.kt:295)
      at mypackage.FlowDispatcher.doMainScreenTransition(FlowDispatcher.kt:170)
      at mypackage.FlowDispatcher.dispatch(FlowDispatcher.kt:140)
      at flow.Flow$PendingTraversal.bootstrap(Flow.java:364)
      at flow.Flow$2.doExecute(Flow.java:139)
      at flow.Flow$PendingTraversal.execute(Flow.java:381)
      at flow.Flow.move(Flow.java:270)
      at flow.Flow.setDispatcher(Flow.java:137)
      at flow.InternalLifecycleIntegration.onActivityCreated(InternalLifecycleIntegration.java:141)

I think the fix is probably just to pre-create contexts for the entire History, but I don't know if that should be in bootstrap or dispatch. Or am I just doing this custom Dispatcher wrong?

@edenman
Copy link
Contributor Author

edenman commented Feb 10, 2017

Talked to @loganj offline: the sanctioned way to do this is to use MultiKey. Both KeyManager and KeyDispatcher have custom logic to handle MultiKey and do what i'm currently doing manually.

@edenman edenman closed this as completed Feb 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant