Skip to content

Conversation

@Karakurik
Copy link
Owner

No description provided.

AppDatabase::class.java,
"app-db"
).run {
allowMainThreadQueries()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для корутин можно было уже убрать

database = Room.databaseBuilder(
applicationContext,
AppDatabase::class.java,
"app-db"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше добавить расширение .db, и вынести в константу

override fun onCreate() {
super.onCreate()
instance = this
database = Room.databaseBuilder(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше код создание бд оставить внутри класса AppDatabase, чтобы потом можно было в другом месте переиспользовать при необходисомти

override fun submitList(list: MutableList<Task>?) {
super.submitList(
if (list == null) null
else ArrayList(list)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

перенос строки тут не нужен


private suspend fun setTaskEditingView(id: Int) {
val task = scope.async {
withContext(Dispatchers.IO) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в данном случае ты мог написать scope.async(Dispatchers.IO) {}

но а так для рума и в этом нужды нет, под коробкой он генерит код с withContext(IO)

database?.taskDao()?.findById(id)
}
}.await()
binding?.apply {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cемантически здесь будет верно run

calendar?.also {
task.date = it.time
}
scope.launch {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Аналогично, мог сразу launch(io) написать

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants