View Provider.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
import com.google.devtools.ksp.symbol.* | |
class IntSummableProcessorProvider : SymbolProcessorProvider { | |
override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor { | |
return IntSummableProcessor( | |
options = environment.options, | |
codeGenerator = environment.codeGenerator, | |
logger = environment.logger | |
) |
View build.gradle.kts
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
plugins { | |
kotlin("jvm") version "1.4.32" | |
} | |
repositories { | |
mavenCentral() | |
google() | |
} | |
dependencies { |
View GeneratedCode.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
public fun FooSummable.sumInts(): Int { | |
val sum = bar + baz | |
return sum | |
} |
View Foo.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
@IntSummable | |
data class Foo( | |
val bar: Int = 234, | |
val baz: Int = 123 | |
) |
View DDDTest.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
class TasksViewModel: ViewModel { | |
val taskItems: LiveData<List<TaskItem>> | |
val _tasksItems: MutableLiveData<List<TaskItem>> | |
fun loadTasks() { | |
val tasks = tasksRepository.getAllTasks() | |
_taskItems.value = tasks.map { it.toTaskItem() } | |
} | |
} |
View TaskItem.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
/** | |
* A presentation-layer item for display in a RecyclerView | |
*/ | |
class TaskItem( | |
val id: String, | |
val title: String, | |
val description: String, | |
val color: @ColorRes Int | |
) |
View TaskWithColor.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
class Task( | |
/* | |
* snip | |
*/ | |
val color: @ColorRes Int | |
) |
View DomainLeakingIntoPresentation.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
class TasksFragment { | |
private lateinit var tasksAdapter: TasksAdapter | |
fun showTasks(tasks: List<Tasks>) { | |
tasksAdapter.setData(tasks) | |
} | |
} | |
// inside tasks adapter |
View Separating.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
// data layer object | |
open class RealmTask constructor( | |
var title: String = "", | |
var description: String, | |
var isCompleted: Boolean, | |
@PrimaryKey var entryId: String | |
): RealmObject() | |
fun RealmTask.toDomain() { | |
return Task( |
View Task.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
// Realm models must be open | |
open class Task constructor( | |
var title: String = "", | |
var description: String, | |
var isCompleted: Boolean, | |
@PrimaryKey var entryId: String | |
): RealmObject() |