Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Conversation

@AleksandrKalevich
Copy link

photo_2022-05-26_13-53-30
photo_2022-05-26_13-53-32

import retrofit2.http.GET
import retrofit2.http.Query

object RetrofitBuilder {
Copy link
Owner

Choose a reason for hiding this comment

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

Синглтон это антипаттерн. Сделай класс (В идеале с интерфейсом) + inject через koin (single)


override fun onCreate() {
super.onCreate()
runBlocking {
Copy link
Owner

Choose a reason for hiding this comment

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

Нужно создать свою coroutineScope, чтобы не вызывать runBlocking и не блокировать main поток.
CoroutineScope(SupervisorJob() + Dispatchers.Main)

class HostFragment: Fragment() {

private lateinit var fragment: HostFragmentBinding
private val albumsFragment = AlbumsFragment()
Copy link
Owner

Choose a reason for hiding this comment

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

Создавать фрагмент нужно только, когда savedInstanceState == null. В другом же случае, фрагмент уже будет и его нужно найти при помощи findFragmentByTag("tag"). Тут при смене конфигурации будет 2 фрагмента в памяти. bundle тоже как глобальную переменную лучше не держать. К ней есть доступ через albumsFragment.arguments

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants