lukaspili / Mortar-Flow-Dagger2-demo

Android demo application with Mortar / Flow / Dagger2. Up to date with latest versions.
MIT License
53 stars 10 forks source link

Calling specific callbacks that take Activity as parameter #4

Open leonardo2204 opened 8 years ago

leonardo2204 commented 8 years ago

Hi Lukas,

First of all, thanks for the outstanding job that you have been doing ! I have a question, I've checked out this example and I'm trying to login using FB login. The problem is, inside my view I have a button callback that must call 'LoginManager.getInstance().logInWithReadPermissions(activity, permissions);'

How can I accomplish this ? Thanks for your time !

lukaspili commented 8 years ago

Hi! You need to create a link between the activity and the views/presenters. The class that represents that link, which could be called ActivityPresenter or ActivityOwner, will be linked to the activity on the activity's onCreate() and unlinked in the activity's onDestroy(). You can then pass that activity owner to the views/presenters, either by adding it as a service of the mortar scope, or by dagger2.

You can find more info on that SO post: http://stackoverflow.com/questions/21927990/mortar-flow-with-third-party-libraries-hooked-to-activity-lifecycle