-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Homework 6 #4
base: develop
Are you sure you want to change the base?
Homework 6 #4
Conversation
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.
Есть замечания оставил комментарии в github, в целом хорошо.
|
||
class MainActivity : MvpAppCompatActivity(), MainView { | ||
|
||
private lateinit var viewBinding: ActivityMainBinding |
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.
Использование lateinit
является очень плохой практикой, и допускается только для внедрения зависимостей в компоненты Android (Activity, Fragment и тд) с использованием Dagger 2
. Для всех (любых) случаев это абсолютно неприемлемая практика от которой нужно отказаться.
btnCounter2.setOnClickListener(listener) | ||
btnCounter3.setOnClickListener(listener) | ||
} | ||
viewBinding = ActivityMainBinding.inflate(layoutInflater) |
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.
Удобно использовать https://github.com/kirich1409/ViewBindingPropertyDelegate. См. последний пример с разбором ДЗ урока 2.
|
||
interface IImageCache { | ||
fun saveImage(url: String, bytes: ByteArray): Completable | ||
fun getCachedImage(url: String): Maybe<ByteArray?> |
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.
RxJava не работает null типами. если в цепочке будет null ссылка то будет фатал.
it.userId | ||
) | ||
} | ||
}.subscribeOn(Schedulers.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.
Планировщик потоков нужно передавать в конструкторе в виде зависимости (помним про Dependency Injection
и Dependency Inversion
), иначе его не заменить из вне.
) | ||
} | ||
database.repositoryDao.insert(roomRepos) | ||
}.subscribeOn(Schedulers.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.
Планировщик потоков нужно передавать в конструкторе в виде зависимости (помним про Dependency Injection
и Dependency Inversion
), иначе его не заменить из вне.
): IGithubUsersCache { | ||
|
||
override fun getUsers() = Single.fromCallable { | ||
database.userDao.getAll().map { roomUser -> |
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.
Хорошей практикой написания реактивных цепочек является написание их в каждой новой строке, это улучшает читаемость.
import moxy.MvpPresenter | ||
|
||
|
||
class MainPresenter( |
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.
Форматирование кода конечно страдает. Такой код сложнее воспринимать. Используй Ctrl+Alt+L
.
Урок 6. - Room и хранение данных