soundcloud / lightcycle

LightCycle lets self-contained classes respond to Android’s lifecycle events
http://soundcloud.github.io/lightcycle/
Apache License 2.0
705 stars 55 forks source link

Custom Views support #55

Closed cesards closed 7 years ago

cesards commented 8 years ago

Hi guys!

First of all, awesome job! I really think having the change to split the bunch of logic in a Presenter, is the way to go.

I was wondering how do you manage to support custom views. I want to add a "presenter" to a custom view which does an specific logic, so I don't to depend on fragments or activities. If you are not handling view life cycles yet, I could try to have a deeper look and do a PR, but I wanted to ask first.

Thanks in advance again.

glung commented 8 years ago

Hello Cesards,

I guess you want to follow the MVP pattern and have the following flow : Presenter -> View.

In the context of LightCycle :

From this, you may consider your (Activity + custom view) as the V of MVP.

For instance, one approach would be to make your MyFeatureActivity implement a MyFeatureView interface. In this context, your activity is free to proxy any custom view specifics - which then is an implementation detail your presenter does not need to know about.

I hope it answers your Q.