Skip to content

Commit 487f849

Browse files
committed
Fix compilation with generic presenter
1 parent 949bb3e commit 487f849

7 files changed

Lines changed: 8 additions & 8 deletions

File tree

app/src/main/java/com/omegar/mvp/BasePresenter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ package com.omegar.mvp
55
* Created by Anton Knyazev on 09.06.2023.
66
* Copyright (c) 2023 Omega https://omega-r.com
77
*/
8-
open class BasePresenter<T: Number, VIEW: BaseView>: MvpPresenter<VIEW>() {
8+
open class BasePresenter<T: Number, M, VIEW: BaseView<M>>: MvpPresenter<VIEW>() {
99
}

app/src/main/java/com/omegar/mvp/BaseView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package com.omegar.mvp
55
* Created by Anton Knyazev on 09.06.2023.
66
* Copyright (c) 2023 Omega https://omega-r.com
77
*/
8-
interface BaseView: MvpView {
8+
interface BaseView<M>: MvpView {
99

1010
fun base() {}
1111

app/src/main/java/com/omegar/mvp/MoxyActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import android.widget.Toast
55
import kotlin.time.Duration
66
import kotlin.time.Duration.Companion.seconds
77

8-
class MoxyActivity: MvpAppCompatActivity(R.layout.activity_moxy), MoxyView {
8+
class MoxyActivity: MvpAppCompatActivity(R.layout.activity_moxy), MoxyView<Int> {
99

1010
companion object {
1111
var first: Boolean = true

app/src/main/java/com/omegar/mvp/MoxyFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import android.widget.Toast
55
import kotlin.time.Duration
66
import kotlin.time.Duration.Companion.seconds
77

8-
class MoxyFragment : MvpAppCompatFragment(R.layout.activity_moxy), MoxyView {
8+
class MoxyFragment : MvpAppCompatFragment(R.layout.activity_moxy), MoxyView<Int> {
99

1010
private val presenter: MoxyPresenter by providePresenter {
1111
MoxyPresenter()

app/src/main/java/com/omegar/mvp/MoxyPresenter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.omegar.mvp
22

33
import kotlin.time.Duration
44

5-
class MoxyPresenter : BasePresenter<Long, MoxyView>() {
5+
class MoxyPresenter : BasePresenter<Long, Int, MoxyView<Int>>() {
66

77
init {
88
viewState.showToast("Hello World!")

app/src/main/java/com/omegar/mvp/MoxyView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import com.omegar.mvp.viewstate.strategy.MoxyViewCommand
44
import com.omegar.mvp.viewstate.strategy.StrategyType.ONE_EXECUTION
55
import kotlin.time.Duration
66

7-
interface MoxyView: Addon<Long>, BaseView {
7+
interface MoxyView<M>: Addon<Long>, BaseView<M> {
88

99

1010
var duration: Duration

moxy/compiler/src/main/java/com/omegar/mvp/compiler/ksp/KspViewParser.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class KspViewParser(
8181
val newView = if (oldViewStateDeclaration != null) {
8282
View(
8383
className = viewClassName,
84-
presenterClassParamsMap = mutableMapOf(presenterDeclaration.toClassName() to presenterDeclaration.typeParameters.map { it.toTypeVariableName() }),
84+
presenterClassParamsMap = mutableMapOf(presenterDeclaration.toClassName() to presenterDeclaration.typeParameters.map { it.toTypeVariableName(presenterDeclaration.typeParameters.toTypeParameterResolver()) }),
8585
methods = emptyList(),
8686
viewTypeParams = emptyList(),
8787
parent = null,
@@ -97,7 +97,7 @@ class KspViewParser(
9797
View(
9898
className = viewClassName,
9999
presenterClassParamsMap = mutableMapOf(
100-
presenterDeclaration.toClassName() to presenterDeclaration.typeParameters.map { it.toTypeVariableName() }
100+
presenterDeclaration.toClassName() to presenterDeclaration.typeParameters.map { it.toTypeVariableName(presenterDeclaration.typeParameters.toTypeParameterResolver()) }
101101
),
102102
methods = viewDeclaration.getMethods(declarations, superView),
103103
viewTypeResolvedParams = superView?.viewTypePresenterParams?.get(superPresenter.toClassName()).orEmpty(),

0 commit comments

Comments
 (0)