Skip to content

Commit c81912e

Browse files
committed
Moved View to Presenter class.
1 parent 35ea624 commit c81912e

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/main/kotlin/com/mvcoding/mvp/Presenter.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import rx.Observable
44
import rx.Subscription
55
import rx.subscriptions.CompositeSubscription
66

7-
abstract class Presenter<VIEW : View> {
7+
abstract class Presenter<VIEW : Presenter.View> {
88
private lateinit var viewSubscriptions: CompositeSubscription
99
private var view: View? = null
1010

@@ -44,4 +44,6 @@ abstract class Presenter<VIEW : View> {
4444
else if (this.view != view)
4545
throw IllegalStateException("Trying to detach different view. We have view: ${this.view}. Trying to detach view: $view")
4646
}
47+
48+
interface View
4749
}

src/main/kotlin/com/mvcoding/mvp/View.kt

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/test/kotlin/com/mvcoding/mvp/PresenterTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import rx.Observable.just
88
import kotlin.test.assertFalse
99

1010
class PresenterTest {
11-
val view = mock<View>()
12-
val presenter: Presenter<View> = object : Presenter<View>() {
11+
val view = mock<Presenter.View>()
12+
val presenter: Presenter<Presenter.View> = object : Presenter<Presenter.View>() {
1313
}
1414

1515
@Test(expected = IllegalStateException::class)
@@ -33,7 +33,7 @@ class PresenterTest {
3333
@Test(expected = IllegalStateException::class)
3434
fun throwsIllegalStateExceptionWhenTryingToDetachDifferentView() {
3535
presenter.attach(view)
36-
presenter.detach(mock<View>())
36+
presenter.detach(mock<Presenter.View>())
3737
}
3838

3939
@Test
@@ -50,7 +50,7 @@ class PresenterTest {
5050
assertFalse { isSubscribed }
5151
}
5252

53-
interface ViewForTest : View {
53+
interface ViewForTest : Presenter.View {
5454
fun events(): Observable<Unit>
5555
}
5656

0 commit comments

Comments
 (0)