Flipboard/bottomsheet

Add option to keep state between sheet displays

Open

#92 opened on Dec 2, 2015

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Java (609 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (4,540 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Due to the asynchronous handling when dismissing/showing the view it is impossible to have listeners set after re-showing.

First time:

  • add state change listener
  • show view -> listener gets called

Second time:

  • add listener
  • show view (it is already showing) -> calls dismiss and returns
  • gets dismissed -> removes all listeners (including new ones)
  • runnable shows view again -> no listeners

Adding the listeners after calling show also doesn't work (because the runnable to show again is asynchronously called from the dismiss animation callback)

My idea would be to store a local copy of the listeners in the dismiss method and clean the global fields. Then from the animation listener:

  • When it wasn't cancelled call the local listeners.
  • If it was cancelled put the local listeners back into the global fields. (To remain the state before the dismiss)

Contributor guide