-
Notifications
You must be signed in to change notification settings - Fork 729
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Kotlin delegation via annotated interface properties
- Loading branch information
1 parent
c631edb
commit b26b70f
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
epoxy-integrationtest/src/main/java/com/airbnb/epoxy/integrationtest/ViewWithDelegate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.airbnb.epoxy.integrationtest | ||
|
||
import android.content.Context | ||
import android.view.View | ||
import com.airbnb.epoxy.ModelProp | ||
import com.airbnb.epoxy.ModelView | ||
|
||
@ModelView(autoLayout = ModelView.Size.WRAP_WIDTH_MATCH_HEIGHT) | ||
class ViewWithDelegate @JvmOverloads constructor( | ||
context: Context, | ||
implementation: InterfaceImplementation = InterfaceImplementation() | ||
) : View(context), InterfaceWithModelProp by implementation | ||
|
||
interface InterfaceWithModelProp { | ||
|
||
@set:ModelProp | ||
var flag: Boolean | ||
} | ||
|
||
class InterfaceImplementation : InterfaceWithModelProp { | ||
|
||
override var flag: Boolean = false | ||
} |
19 changes: 19 additions & 0 deletions
19
epoxy-integrationtest/src/test/java/com/airbnb/epoxy/ModelViewDelegateTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.airbnb.epoxy | ||
|
||
import com.airbnb.epoxy.integrationtest.BuildConfig | ||
import com.airbnb.epoxy.integrationtest.ViewWithDelegateModel_ | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
import org.robolectric.annotation.Config | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
@Config(constants = BuildConfig::class, sdk = intArrayOf(21)) | ||
class ModelViewDelegateTest { | ||
|
||
@Test | ||
fun propMethodIsOnModel() { | ||
val model = ViewWithDelegateModel_() | ||
model.flag(true) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters