bluelinelabs / Conductor

A small, yet full-featured framework that allows building View-based Android applications
Apache License 2.0
3.9k stars 344 forks source link

Workflow custom animation question - trigger animation start #161

Open MFlisar opened 7 years ago

MFlisar commented 7 years ago

I've implemented following workflow to start animations as soon as my view is ready:

This works, but it looks ugly. It forces me to use a custom view (because the ChangeHandler only get's the from and the to View and I must use something offered by those Views).

Is there any more beautiful way to do that? Or is this really the default way and wanted so by design? I think something like following would look nicer:

I think it would really make sense to pass on the controllers to ChangeHandler.performChange so that the controllers can be used inside the ChangeHandler. Does anything speak against this?

EricKuck commented 7 years ago

I think the way you're doing it makes lots of sense. Having a few views that implement an IsReady interface of some kind, then creating ControllerChangeHandlers that handle those should work very well.

If you're looking to separate business logic from your views and want to keep the isDataReady-type calls out of the views, you can always do this from your controllers. There's an onChangeStarted callback that passes in the ControllerChangeHandler being used. Perhaps you could use this method to pass a listener to your change handler.

MFlisar commented 7 years ago

That's an interesting idea, instead of passing the Controller to the ChangeHandler the controller could pass data to it via the onChangeStarted. I did not think about that yet...

But still, I don't see anything that speaks against passing the controller to the ChangeHandler as well... or to keep the interface untouched, extend the ChangeHandler base class to have a function like setController(controller) which sets and unsets the controller appropriately, so that I can access the controller from within the ChangeHandler.

This could be used to have direct access to a DataBinding object that is in the controller as well (as I was suggesting something about that in another issue).

I don't like to split my code between Controller and ChangeHandler too much, having access to the controller would make this easier...