Skip to content

Commit

Permalink
improve code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jedsada committed Apr 26, 2017
1 parent faaedad commit ed87f5f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ android {
ext {
supportVersion = "25.3.1"
butterknifeVersion = "8.5.1"
dagger2Version = "2.9"
dagger2Version = "2.10"
rxVersion = "2.0.5"
rxAndroidVersion = "2.0.1"
retrofitVersion = "2.1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.wisdomlanna.www.dagger2_mvp_example;

import java.lang.annotation.Retention;

import javax.inject.Qualifier;

import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Qualifier
@Retention(RUNTIME)
public @interface ForApplication {

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ public void onCreate() {
if (BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree());
}

public ApplicationComponent getComponent() {
return component;
}

private void initDependencyInjection() {
component = DaggerApplicationComponent.builder()
.androidModule(new AndroidModule(this))
.utilModule(new UtilModule())
.networkModule(new NetworkModule())
.apiModule(new ApiModule())
.build();
getComponent().inject(this);
component().inject(this);
}

public ApplicationComponent component() {
return component;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (layoutToInflate() == 0) throw new MvpNotSetLayoutException();
setContentView(layoutToInflate());
doInjection(((MyApplication) getApplication()).getComponent());
doInjection(((MyApplication) getApplication()).component());
ButterKnife.bind(this);
presenter.attachView(this);
bindView();
Expand Down

0 comments on commit ed87f5f

Please sign in to comment.