Skip to content

Commit

Permalink
updated scanner example
Browse files Browse the repository at this point in the history
  • Loading branch information
matzuk committed Aug 22, 2018
1 parent f003b15 commit 3d4fb4f
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 17 deletions.
2 changes: 0 additions & 2 deletions feature-scanner-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ dependencies {
implementation project(':feature-purchase-api')
implementation project(':core-utils')
implementation project(':core-network-api')
implementation project(':core-network-impl')
implementation project(':core-db-api')
implementation project(':core-db-impl')

implementation fileTree(dir: 'libs', include: ['*.jar'])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import com.arellomobile.mvp.RegisterMoxyReflectorPackages;
import com.example.core.di.app.CoreUtilsComponent;
import com.example.core_db_impl.di.CoreDbComponent;
import com.example.core_network_impl.di.CoreNetworkComponent;
import com.example.scanner.di.ScannerFeatureComponent;
import com.example.scanner_example.di.ScannerFeatureDependenciesFakeComponent;

Expand All @@ -18,9 +16,7 @@ public void onCreate() {
// component
ScannerFeatureComponent.init(
ScannerFeatureDependenciesFakeComponent.create(
CoreUtilsComponent.createOnce(),
CoreNetworkComponent.createOnce(),
CoreDbComponent.createOnce()
CoreUtilsComponent.createOnce()
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.example.core.di.app.CoreUtilsApi;
import com.example.core.di.general.PerFeature;
import com.example.core_db_api.di.CoreDbApi;
import com.example.core_network_api.di.CoreNetworkApi;
import com.example.scanner.di.ScannerFeatureDependencies;

import dagger.Component;
Expand All @@ -12,17 +10,13 @@
modules = {
ScannerFeatureDependenciesFakeModule.class
}, dependencies = {
CoreUtilsApi.class,
CoreNetworkApi.class,
CoreDbApi.class
CoreUtilsApi.class
})
@PerFeature
public abstract class ScannerFeatureDependenciesFakeComponent implements ScannerFeatureDependencies {

public static ScannerFeatureDependencies create(CoreUtilsApi coreUtilsApi, CoreNetworkApi coreNetworkApi, CoreDbApi coreDbApi) {
public static ScannerFeatureDependencies create(CoreUtilsApi coreUtilsApi) {
return DaggerScannerFeatureDependenciesFakeComponent.builder()
.coreDbApi(coreDbApi)
.coreNetworkApi(coreNetworkApi)
.coreUtilsApi(coreUtilsApi)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
package com.example.scanner_example.di;

import com.example.core.di.general.PerFeature;
import com.example.core_db_api.data.DbClientApi;
import com.example.core_network_api.data.HttpClientApi;
import com.example.purchase_api.domain.PurchaseInteractor;
import com.example.scanner_example.fake.DbClientFake;
import com.example.scanner_example.fake.HttpClientFake;
import com.example.scanner_example.fake.PurchaseInteractorFake;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;

@Module
public class ScannerFeatureDependenciesFakeModule {
public abstract class ScannerFeatureDependenciesFakeModule {

@Provides
@PerFeature
public PurchaseInteractor purchaseInteractor() {
public static PurchaseInteractor purchaseInteractor() {
return new PurchaseInteractorFake();
}

@PerFeature
@Binds
public abstract DbClientApi provideDbClientApi(DbClientFake dbClient);

@PerFeature
@Binds
public abstract HttpClientApi provideHttpClientApi(HttpClientFake httpClientFake);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.scanner_example.fake;

import com.example.core_db_api.data.DbClientApi;

import javax.inject.Inject;

public class DbClientFake implements DbClientApi {

@Inject
public DbClientFake() {
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.scanner_example.fake;

import com.example.core_network_api.data.HttpClientApi;

import javax.inject.Inject;

import io.reactivex.Single;

public class HttpClientFake implements HttpClientApi {

@Inject
public HttpClientFake() {
}

@Override
public Single<Object> doAnyRequest() {
return Single.just(new Object());
}

}

0 comments on commit 3d4fb4f

Please sign in to comment.