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 | |
) |
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") | |
id("com.google.devtools.ksp") version "1.5.31-1.0.0" | |
} | |
repositories { | |
mavenCentral() | |
google() | |
} |
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 | |
} |
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 | |
) |
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() } | |
} | |
} |
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 | |
) |
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 | |
) |
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 |
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( |
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() |