Closed kboyarshinov closed 9 years ago
To be honest, I wasn't even going to put an abstract behind it. I was just going to inject the DrawerLayer
directly.
The ActivityConnector
indirection isn't needed here because we are a view and already have a reference to the activity in the form of its Context
.
Thats true. For single activity binding ActivityConnector
brings no benefit. It was initially created to bind multiple activities and store the top most or current for user.
What DrawerLayer
do you mean?
Doing like ((MainActivity) context).getDrawerLayout().openDrawer(Gravity.START)
seems very coupled code.
I meant DrawerLayout
. We'd add it to an activity-specific object graph so it could simply be @Inject
ed.
Ahh, ok, I see. I can do that if you don't mind?
Sure. We have a semi-clever way of obtaining the injector that I'd like to introduce. Let me see if I can get it done here quickly.
On Thu, Apr 2, 2015 at 11:52 PM Kirill Boyarshinov notifications@github.com wrote:
Ahh, ok, I see. I can do that if you don't mind?
— Reply to this email directly or view it on GitHub https://github.com/JakeWharton/u2020/issues/126#issuecomment-89151606.
Ok. I'm interested what this way is. I was playing around several ways of doing this: using custom system service, or even Mortar. In dagger2, however, obtaining specific component is not so obvious, and I'm still looking for more clean way.
Heh, I did the system service. I think it's the best for this situation in terms of complexity vs. desired result: https://github.com/JakeWharton/u2020/pull/128.
:+1: fair enough
It's merged. Go nuts!
Done. #131
From
TrendingView.java
:How are you guys planning to implement this binding with
MainActivity.drawerLayout
?Typically I'm doing this the following way:
ActivityConnector
binds to Activity livecycle with attach/detach (e.g. called from onStart/onStop), holds reference to some object in Activity. Simply it looks like this:More robust implementation can be found here.
This approach can be used to bind
drawerLayout
:in
TrendingView.java
:What do you think about that?