Flipboard / bottomsheet

Android component which presents a dismissible view from the bottom of the screen
BSD 3-Clause "New" or "Revised" License
4.52k stars 595 forks source link

Add option to keep state between sheet displays #92

Open MatFl opened 8 years ago

MatFl commented 8 years ago

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

First time:

Second time:

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:

ZacSweers commented 8 years ago

This is a fair point, and it currently does this on purpose. This was initially sensible, bu we later added the option to dismiss and re-show in a single call, which kind of threw a wrench in things. We'll add something in the future to allow the user to specify keeping listeners

MatFl commented 8 years ago

I'm not sure keeping the whole state (and thus the listeners) is the right way. In my case, each sheet comes with its own listeners. The old listeners are only valid for the old sheet. Keeping all the listeners could turn out really messy.