| @@ -0,0 +1,39 @@ | ||
| package ru.nekit.android.clean_architecture.data.network; | ||
|
|
||
| import android.support.annotation.NonNull; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import javax.inject.Singleton; | ||
|
|
||
| import dagger.Module; | ||
| import dagger.Provides; | ||
| import okhttp3.Interceptor; | ||
| import ru.nekit.android.clean_architecture.data.network.qualifier.OkHttpInterceptors; | ||
| import ru.nekit.android.clean_architecture.data.network.qualifier.OkHttpNetworkInterceptors; | ||
|
|
||
| import static java.util.Collections.emptyList; | ||
|
|
||
| /** | ||
| * Created by ru.nekit.android on 29.03.16. | ||
| */ | ||
| @Module | ||
| public class OkHttpInterceptorsModule { | ||
|
|
||
| @Singleton | ||
| @Provides | ||
| @NonNull | ||
| @OkHttpInterceptors | ||
| public List<Interceptor> provideOkHttpInterceptors() { | ||
| return emptyList(); | ||
| } | ||
|
|
||
| @Singleton | ||
| @Provides | ||
| @NonNull | ||
| @OkHttpNetworkInterceptors | ||
| public List<Interceptor> provideOkHttpNetworkInterceptors() { | ||
| return emptyList(); | ||
| } | ||
|
|
||
| } |
| @@ -1,4 +1,4 @@ | ||
| package ru.nekit.android.clean_architecture.domain; | ||
|
|
||
| /** | ||
| * Created by MacOS on 17.03.16. | ||
| @@ -1,4 +1,4 @@ | ||
| package ru.nekit.android.clean_architecture.domain.interactors.base; | ||
|
|
||
| import rx.Observable; | ||
|
|
||
| @@ -1,8 +1,8 @@ | ||
| package ru.nekit.android.clean_architecture.domain.repository; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import ru.nekit.android.clean_architecture.domain.Repository; | ||
| import rx.Observable; | ||
|
|
||
| /** | ||
| @@ -1,4 +1,4 @@ | ||
| package ru.nekit.android.clean_architecture; | ||
|
|
||
| import android.app.Application; | ||
| import android.test.ApplicationTestCase; | ||
| @@ -1,10 +1,24 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.developer_settings; | ||
|
|
||
| import android.app.Application; | ||
| import android.support.annotation.NonNull; | ||
|
|
||
| import javax.inject.Singleton; | ||
|
|
||
| import dagger.Module; | ||
| import dagger.Provides; | ||
|
|
||
| /** | ||
| * Created by ru.nekit.android on 29.03.16. | ||
| */ | ||
| @Module | ||
| public class DeveloperSettingsModule { | ||
|
|
||
| @Provides | ||
| @Singleton | ||
| @NonNull | ||
| public ILeakCanaryProxy provideILeakCanaryProxy(@NonNull Application application) { | ||
| return new LeakCanaryProxy(application); | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,35 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.developer_settings; | ||
|
|
||
| import android.app.Application; | ||
| import android.support.annotation.NonNull; | ||
| import android.support.annotation.Nullable; | ||
|
|
||
| import com.squareup.leakcanary.LeakCanary; | ||
| import com.squareup.leakcanary.RefWatcher; | ||
|
|
||
| /** | ||
| * Created by ru.nekit.android on 29.03.16. | ||
| */ | ||
| public class LeakCanaryProxy implements ILeakCanaryProxy { | ||
|
|
||
| @NonNull | ||
| private final Application application; | ||
| @Nullable | ||
| private RefWatcher watcher; | ||
|
|
||
| public LeakCanaryProxy(@NonNull Application application) { | ||
| this.application = application; | ||
| } | ||
|
|
||
| @Override | ||
| public void init() { | ||
| watcher = LeakCanary.install(application); | ||
| } | ||
|
|
||
| @Override | ||
| public void watch(@NonNull Object object) { | ||
| if (watcher != null) { | ||
| watcher.watch(object); | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,47 @@ | ||
| package ru.nekit.android.clean_architecture.presentation; | ||
|
|
||
| import android.app.Application; | ||
| import android.content.Context; | ||
| import android.support.annotation.NonNull; | ||
|
|
||
| import ru.nekit.android.clean_architecture.BuildConfig; | ||
| import ru.nekit.android.clean_architecture.presentation.internal.di.ApplicationComponent; | ||
| import ru.nekit.android.clean_architecture.presentation.internal.di.DaggerApplicationComponent; | ||
| import ru.nekit.android.clean_architecture.presentation.internal.di.modules.ApplicationModule; | ||
| import timber.log.Timber; | ||
|
|
||
| /** | ||
| * Created by ru.nekit.android on 08.03.16. | ||
| */ | ||
| public class GithubApp extends Application { | ||
|
|
||
| @NonNull | ||
| private ApplicationComponent applicationComponent; | ||
|
|
||
| @NonNull | ||
| public static GithubApp get(@NonNull Context context) { | ||
| return (GithubApp) context.getApplicationContext(); | ||
| } | ||
|
|
||
| @NonNull | ||
| public ApplicationComponent getApplicationComponent() { | ||
| return applicationComponent; | ||
| } | ||
|
|
||
| public void onCreate() { | ||
| super.onCreate(); | ||
|
|
||
| applicationComponent = prepareApplicationComponent().build(); | ||
| applicationComponent.inject(this); | ||
|
|
||
| if (BuildConfig.DEBUG) { | ||
| Timber.plant(new Timber.DebugTree()); | ||
| } | ||
| } | ||
|
|
||
| private DaggerApplicationComponent.Builder prepareApplicationComponent() { | ||
| return DaggerApplicationComponent.builder().applicationModule(new ApplicationModule(this)); | ||
| } | ||
|
|
||
|
|
||
| } |
| @@ -0,0 +1,13 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.developer_settings; | ||
|
|
||
| import android.support.annotation.NonNull; | ||
|
|
||
| /** | ||
| * Created by ru.nekit.android on 29.03.16. | ||
| */ | ||
| public interface ILeakCanaryProxy { | ||
|
|
||
| void init(); | ||
|
|
||
| void watch(@NonNull Object object); | ||
| } |
| @@ -0,0 +1,43 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.internal.di; | ||
|
|
||
| import android.support.annotation.NonNull; | ||
|
|
||
| import javax.inject.Singleton; | ||
|
|
||
| import dagger.Component; | ||
| import ru.nekit.android.clean_architecture.data.api.ApiModule; | ||
| import ru.nekit.android.clean_architecture.data.network.NetworkModule; | ||
| import ru.nekit.android.clean_architecture.data.network.OkHttpInterceptorsModule; | ||
| import ru.nekit.android.clean_architecture.presentation.GithubApp; | ||
| import ru.nekit.android.clean_architecture.presentation.developer_settings.DeveloperSettingsModule; | ||
| import ru.nekit.android.clean_architecture.presentation.developer_settings.ILeakCanaryProxy; | ||
| import ru.nekit.android.clean_architecture.presentation.internal.di.modules.ApplicationModule; | ||
| import ru.nekit.android.clean_architecture.presentation.internal.di.modules.DataModule; | ||
| import ru.nekit.android.clean_architecture.presentation.internal.di.modules.DomainModule; | ||
| import ru.nekit.android.clean_architecture.presentation.internal.di.modules.PresentationModule; | ||
| import ru.nekit.android.clean_architecture.presentation.view.fragments.RepositoryListFragment; | ||
|
|
||
| /** | ||
| * Created by ru.nekit.android on 08.03.16. | ||
| */ | ||
| @Singleton | ||
| @Component(modules = { | ||
| ApplicationModule.class, | ||
| PresentationModule.class, | ||
| DomainModule.class, | ||
| DataModule.class, | ||
| ApiModule.class, | ||
| NetworkModule.class, | ||
| OkHttpInterceptorsModule.class, | ||
| DeveloperSettingsModule.class | ||
| }) | ||
| public interface ApplicationComponent { | ||
|
|
||
| void inject(@NonNull RepositoryListFragment value); | ||
|
|
||
| void inject(@NonNull GithubApp value); | ||
|
|
||
| @NonNull | ||
| ILeakCanaryProxy leakCanaryProxy(); | ||
|
|
||
| } |
| @@ -0,0 +1,31 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.internal.di.modules; | ||
|
|
||
| import android.app.Application; | ||
| import android.support.annotation.NonNull; | ||
|
|
||
| import javax.inject.Singleton; | ||
|
|
||
| import dagger.Module; | ||
| import dagger.Provides; | ||
|
|
||
| /** | ||
| * Created by ru.nekit.android on 29.03.16. | ||
| */ | ||
| @Module | ||
| public class ApplicationModule { | ||
|
|
||
| @NonNull | ||
| private final Application application; | ||
|
|
||
| public ApplicationModule(@NonNull Application application) { | ||
| this.application = application; | ||
| } | ||
|
|
||
| @Provides | ||
| @NonNull | ||
| @Singleton | ||
| public Application provideApplication() { | ||
| return application; | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,31 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.internal.di.modules; | ||
|
|
||
| import javax.inject.Singleton; | ||
|
|
||
| import dagger.Module; | ||
| import dagger.Provides; | ||
| import ru.nekit.android.clean_architecture.presentation.model.GithubModel; | ||
| import ru.nekit.android.clean_architecture.presentation.model.IGithubModel; | ||
| import ru.nekit.android.clean_architecture.presentation.presenter.RepositoryListPresenter; | ||
| import ru.nekit.android.clean_architecture.presentation.presenter.mapper.RepositoryToModelMapper; | ||
|
|
||
| /** | ||
| * Created by ru.nekit.android on 08.03.16. | ||
| */ | ||
|
|
||
| @Module | ||
| public class PresentationModule { | ||
|
|
||
| @Singleton | ||
| @Provides | ||
| public RepositoryListPresenter provideRepositoryListPresenter(IGithubModel model, ru.nekit.android.clean_architecture.domain.interactors.ObtainRepositoriesInteractor interactor, RepositoryToModelMapper mapper) { | ||
| return new RepositoryListPresenter(model, interactor, mapper); | ||
| } | ||
|
|
||
| @Singleton | ||
| @Provides | ||
| public IGithubModel provideIGithubModel() { | ||
| return new GithubModel(); | ||
| } | ||
|
|
||
| } |
| @@ -1,4 +1,4 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.model.base; | ||
|
|
||
| /** | ||
| * Created by ru.nekit.android on 02.03.16. | ||
| @@ -1,4 +1,4 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.model.vo; | ||
|
|
||
| import android.os.Parcel; | ||
| import android.os.Parcelable; | ||
| @@ -1,4 +1,4 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.presenter.viewState; | ||
|
|
||
| /** | ||
| * Created by MacOS on 18.03.16. | ||
| @@ -1,4 +1,4 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.presenter.viewState; | ||
|
|
||
| /** | ||
| * Created by ru.nekit.android on 06.03.16. | ||
| @@ -0,0 +1,7 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.presenter.viewState; | ||
|
|
||
| /** | ||
| * Created by MacOS on 18.03.16. | ||
| */ | ||
| interface ViewState { | ||
| } |
| @@ -1,9 +1,7 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.view.adapters.base; | ||
|
|
||
| import android.support.v7.widget.RecyclerView; | ||
| import android.view.View; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @@ -1,4 +1,4 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.view.base; | ||
|
|
||
| /** | ||
| * Created by MacOS on 02.03.16. | ||
| @@ -0,0 +1,18 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.view.fragments; | ||
|
|
||
| import ru.nekit.android.clean_architecture.presentation.model.IGithubModel; | ||
| import ru.nekit.android.clean_architecture.presentation.model.vo.RepositoryVO; | ||
| import ru.nekit.android.clean_architecture.presentation.view.base.ILCEView; | ||
|
|
||
| /** | ||
| * Created by ru.nekit.android on 05.03.16. | ||
| */ | ||
| public interface IRepositoryListView extends ILCEView<IGithubModel, Throwable> { | ||
|
|
||
| String getUserName(); | ||
|
|
||
| void showEmptyList(); | ||
|
|
||
| void showRepository(RepositoryVO repository); | ||
| } | ||
|
|
| @@ -6,6 +6,5 @@ | ||
| <color name="white">#ffffff</color> | ||
| <color name="white_transparent">#75ffffff</color> | ||
| <color name="secondary_text">#727272</color> | ||
| <color name="divider">#cbcbcb</color> | ||
| </resources> | ||
| @@ -1,10 +1,6 @@ | ||
| <resources> | ||
| <!-- Default screen margins, per the Android Design guidelines. --> | ||
| <dimen name="vertical_margin">12dp</dimen> | ||
| <dimen name="vertical_margin_half">6dp</dimen> | ||
| <dimen name="text_size">25sp</dimen> | ||
| </resources> |
| @@ -0,0 +1,22 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.developer_settings; | ||
|
|
||
| import android.support.annotation.NonNull; | ||
|
|
||
| import javax.inject.Singleton; | ||
|
|
||
| import dagger.Module; | ||
| import dagger.Provides; | ||
|
|
||
| /** | ||
| * Created by ru.nekit.android on 29.03.16. | ||
| */ | ||
| @Module | ||
| public class DeveloperSettingsModule { | ||
|
|
||
| @Singleton | ||
| @NonNull | ||
| @Provides | ||
| public ILeakCanaryProxy provideILeakCanaryProxy() { | ||
| return new LeakCanaryProxy(); | ||
| } | ||
| } |
| @@ -0,0 +1,18 @@ | ||
| package ru.nekit.android.clean_architecture.presentation.developer_settings; | ||
|
|
||
| import android.support.annotation.NonNull; | ||
|
|
||
| /** | ||
| * Created by ru.nekit.android on 29.03.16. | ||
| */ | ||
| public class LeakCanaryProxy implements ILeakCanaryProxy { | ||
| @Override | ||
| public void init() { | ||
| //no-op | ||
| } | ||
|
|
||
| @Override | ||
| public void watch(@NonNull Object object) { | ||
| //no-op | ||
| } | ||
| } |
| @@ -1,4 +1,4 @@ | ||
| package ru.nekit.android.clean_architecture; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||