From 5ec2445e68b1e990025fed8a44d040382dfbc3a4 Mon Sep 17 00:00:00 2001 From: Mantas Varnagiris Date: Mon, 5 Mar 2018 21:33:35 +0000 Subject: [PATCH] Moved Views into a package. --- src/main/kotlin/com/mvcoding/mvp/DataView.kt | 13 ------------- .../kotlin/com/mvcoding/mvp/views/DataView.kt | 18 ++++++++++++++++++ .../com/mvcoding/mvp/{ => views}/ErrorView.kt | 7 ++++++- .../mvcoding/mvp/{ => views}/LoadingView.kt | 7 ++++++- .../mvp/{ => views}/RefreshableView.kt | 5 ++++- .../kotlin/com/mvcoding/mvp/BehavioursTest.kt | 1 + .../mvcoding/mvp/{ => views}/DataViewTest.kt | 3 ++- .../mvcoding/mvp/{ => views}/ErrorViewTest.kt | 3 ++- .../mvp/{ => views}/LoadingViewTest.kt | 3 ++- .../mvp/{ => views}/RefreshableViewTest.kt | 3 ++- 10 files changed, 43 insertions(+), 20 deletions(-) delete mode 100644 src/main/kotlin/com/mvcoding/mvp/DataView.kt create mode 100644 src/main/kotlin/com/mvcoding/mvp/views/DataView.kt rename src/main/kotlin/com/mvcoding/mvp/{ => views}/ErrorView.kt (72%) rename src/main/kotlin/com/mvcoding/mvp/{ => views}/LoadingView.kt (74%) rename src/main/kotlin/com/mvcoding/mvp/{ => views}/RefreshableView.kt (72%) rename src/test/kotlin/com/mvcoding/mvp/{ => views}/DataViewTest.kt (91%) rename src/test/kotlin/com/mvcoding/mvp/{ => views}/ErrorViewTest.kt (92%) rename src/test/kotlin/com/mvcoding/mvp/{ => views}/LoadingViewTest.kt (95%) rename src/test/kotlin/com/mvcoding/mvp/{ => views}/RefreshableViewTest.kt (92%) diff --git a/src/main/kotlin/com/mvcoding/mvp/DataView.kt b/src/main/kotlin/com/mvcoding/mvp/DataView.kt deleted file mode 100644 index 81bbb4f..0000000 --- a/src/main/kotlin/com/mvcoding/mvp/DataView.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.mvcoding.mvp - - -interface DataView : Presenter.View { - fun showData(data: T) -} - -fun > O.loadData(view: VIEW, - dataSource: (INPUT) -> O, - schedulers: RxSchedulers = trampolines): O = - switchMap { dataSource(it).subscribeOn(schedulers.io) } - .observeOn(schedulers.main) - .doOnNext { view.showData(it) } \ No newline at end of file diff --git a/src/main/kotlin/com/mvcoding/mvp/views/DataView.kt b/src/main/kotlin/com/mvcoding/mvp/views/DataView.kt new file mode 100644 index 0000000..376f692 --- /dev/null +++ b/src/main/kotlin/com/mvcoding/mvp/views/DataView.kt @@ -0,0 +1,18 @@ +package com.mvcoding.mvp.views + +import com.mvcoding.mvp.O +import com.mvcoding.mvp.Presenter +import com.mvcoding.mvp.RxSchedulers +import com.mvcoding.mvp.trampolines + + +interface DataView : Presenter.View { + fun showData(data: T) +} + +fun > O.loadData(view: VIEW, + dataSource: (INPUT) -> O, + schedulers: RxSchedulers = trampolines): O = + switchMap { dataSource(it).subscribeOn(schedulers.io) } + .observeOn(schedulers.main) + .doOnNext { view.showData(it) } \ No newline at end of file diff --git a/src/main/kotlin/com/mvcoding/mvp/ErrorView.kt b/src/main/kotlin/com/mvcoding/mvp/views/ErrorView.kt similarity index 72% rename from src/main/kotlin/com/mvcoding/mvp/ErrorView.kt rename to src/main/kotlin/com/mvcoding/mvp/views/ErrorView.kt index 88d2862..a603329 100644 --- a/src/main/kotlin/com/mvcoding/mvp/ErrorView.kt +++ b/src/main/kotlin/com/mvcoding/mvp/views/ErrorView.kt @@ -1,4 +1,9 @@ -package com.mvcoding.mvp +package com.mvcoding.mvp.views + +import com.mvcoding.mvp.O +import com.mvcoding.mvp.Presenter +import com.mvcoding.mvp.RxSchedulers +import com.mvcoding.mvp.trampolines interface ErrorView : Presenter.View { fun showError(error: ERROR) diff --git a/src/main/kotlin/com/mvcoding/mvp/LoadingView.kt b/src/main/kotlin/com/mvcoding/mvp/views/LoadingView.kt similarity index 74% rename from src/main/kotlin/com/mvcoding/mvp/LoadingView.kt rename to src/main/kotlin/com/mvcoding/mvp/views/LoadingView.kt index 034d25c..a94a77e 100644 --- a/src/main/kotlin/com/mvcoding/mvp/LoadingView.kt +++ b/src/main/kotlin/com/mvcoding/mvp/views/LoadingView.kt @@ -1,4 +1,9 @@ -package com.mvcoding.mvp +package com.mvcoding.mvp.views + +import com.mvcoding.mvp.O +import com.mvcoding.mvp.Presenter +import com.mvcoding.mvp.RxSchedulers +import com.mvcoding.mvp.trampolines interface LoadingView : Presenter.View { fun showLoading() diff --git a/src/main/kotlin/com/mvcoding/mvp/RefreshableView.kt b/src/main/kotlin/com/mvcoding/mvp/views/RefreshableView.kt similarity index 72% rename from src/main/kotlin/com/mvcoding/mvp/RefreshableView.kt rename to src/main/kotlin/com/mvcoding/mvp/views/RefreshableView.kt index cb29b45..7791348 100644 --- a/src/main/kotlin/com/mvcoding/mvp/RefreshableView.kt +++ b/src/main/kotlin/com/mvcoding/mvp/views/RefreshableView.kt @@ -1,5 +1,8 @@ -package com.mvcoding.mvp +package com.mvcoding.mvp.views +import com.mvcoding.mvp.O +import com.mvcoding.mvp.RxSchedulers +import com.mvcoding.mvp.trampolines import io.reactivex.Observable interface RefreshableView { diff --git a/src/test/kotlin/com/mvcoding/mvp/BehavioursTest.kt b/src/test/kotlin/com/mvcoding/mvp/BehavioursTest.kt index 3450d86..4d00c27 100644 --- a/src/test/kotlin/com/mvcoding/mvp/BehavioursTest.kt +++ b/src/test/kotlin/com/mvcoding/mvp/BehavioursTest.kt @@ -1,5 +1,6 @@ package com.mvcoding.mvp +import com.mvcoding.mvp.views.* import com.nhaarman.mockitokotlin2.* import io.reactivex.Observable import io.reactivex.subjects.PublishSubject diff --git a/src/test/kotlin/com/mvcoding/mvp/DataViewTest.kt b/src/test/kotlin/com/mvcoding/mvp/views/DataViewTest.kt similarity index 91% rename from src/test/kotlin/com/mvcoding/mvp/DataViewTest.kt rename to src/test/kotlin/com/mvcoding/mvp/views/DataViewTest.kt index cd51216..526072e 100644 --- a/src/test/kotlin/com/mvcoding/mvp/DataViewTest.kt +++ b/src/test/kotlin/com/mvcoding/mvp/views/DataViewTest.kt @@ -1,5 +1,6 @@ -package com.mvcoding.mvp +package com.mvcoding.mvp.views +import com.mvcoding.mvp.O import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.verify diff --git a/src/test/kotlin/com/mvcoding/mvp/ErrorViewTest.kt b/src/test/kotlin/com/mvcoding/mvp/views/ErrorViewTest.kt similarity index 92% rename from src/test/kotlin/com/mvcoding/mvp/ErrorViewTest.kt rename to src/test/kotlin/com/mvcoding/mvp/views/ErrorViewTest.kt index 70a19ea..eadbec2 100644 --- a/src/test/kotlin/com/mvcoding/mvp/ErrorViewTest.kt +++ b/src/test/kotlin/com/mvcoding/mvp/views/ErrorViewTest.kt @@ -1,5 +1,6 @@ -package com.mvcoding.mvp +package com.mvcoding.mvp.views +import com.mvcoding.mvp.O import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.verify import io.reactivex.observers.TestObserver diff --git a/src/test/kotlin/com/mvcoding/mvp/LoadingViewTest.kt b/src/test/kotlin/com/mvcoding/mvp/views/LoadingViewTest.kt similarity index 95% rename from src/test/kotlin/com/mvcoding/mvp/LoadingViewTest.kt rename to src/test/kotlin/com/mvcoding/mvp/views/LoadingViewTest.kt index c40b351..addccc7 100644 --- a/src/test/kotlin/com/mvcoding/mvp/LoadingViewTest.kt +++ b/src/test/kotlin/com/mvcoding/mvp/views/LoadingViewTest.kt @@ -1,5 +1,6 @@ -package com.mvcoding.mvp +package com.mvcoding.mvp.views +import com.mvcoding.mvp.O import com.nhaarman.mockitokotlin2.inOrder import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.verify diff --git a/src/test/kotlin/com/mvcoding/mvp/RefreshableViewTest.kt b/src/test/kotlin/com/mvcoding/mvp/views/RefreshableViewTest.kt similarity index 92% rename from src/test/kotlin/com/mvcoding/mvp/RefreshableViewTest.kt rename to src/test/kotlin/com/mvcoding/mvp/views/RefreshableViewTest.kt index a311b07..ac70b91 100644 --- a/src/test/kotlin/com/mvcoding/mvp/RefreshableViewTest.kt +++ b/src/test/kotlin/com/mvcoding/mvp/views/RefreshableViewTest.kt @@ -1,5 +1,6 @@ -package com.mvcoding.mvp +package com.mvcoding.mvp.views +import com.mvcoding.mvp.O import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.whenever import io.reactivex.observers.TestObserver