-
Notifications
You must be signed in to change notification settings - Fork 0
Hw 10 coroutines #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Hw 10 coroutines #10
Conversation
AppDatabase::class.java, | ||
"app-db" | ||
).run { | ||
allowMainThreadQueries() |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Аналогично, мог сразу launch(io) написать
No description provided.