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
package com.example | |
import android.content.Context | |
import android.content.Intent | |
import android.os.Bundle | |
import androidx.fragment.app.Fragment | |
import com.example.R | |
import com.example.BaseActivity | |
class FragmentContainerActivity : BaseActivity() { |
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.squareup.inject.assisted.dagger2.AssistedModule | |
import dagger.Module | |
@Component( | |
modules = [ViewModelAssistedFactoriesModule::class] // <--- Add assisted module | |
) | |
interface SampleComponent { | |
fun inject(fragment: SampleFragment) |
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
{ | |
"latest": "1.12.2", | |
"versions": { | |
"1.12.2": "lastSuccessfulBuild", | |
"1.11.2": "1104", | |
"1.10.2": "916", | |
"1.9.4": "773", | |
"1.8.8": "443" | |
} | |
} |
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 ViewModelFactory @Inject constructor( | |
private val providers: Map<Class<out ViewModel>, @JvmSuppressWildcards Provider<ViewModel>> | |
) : ViewModelProvider.Factory { | |
override fun <T : ViewModel> create(modelClass: Class<T>): T { | |
val provider = providers[modelClass] | |
?: providers.asIterable().find { modelClass.isAssignableFrom(it.key) }?.value | |
?: error("Unknown ViewModel class $modelClass") | |
return try { |
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 DetailsFragment : BaseFragment(R.layout.fragment_details) { | |
lateinit val viewModel: DetailsViewModel | |
// ... | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onVewCreated(view, savedInstanceState) | |
// Assumed that viewModel initialized here |
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
/** | |
* Инфлейт ViewBinding заданного типа [T]. | |
* | |
* В качестве родителя используется [ViewGroup], по умолчанию view прикрепляется к корню родителя. | |
* **ВАЖНО!** Для инфлейта вьюх с `merge` в корне нужно использовать только этот метод. | |
*/ | |
inline fun <reified T : ViewBinding> ViewGroup.inflateViewBinding( | |
context: Context = this.context, | |
attachToRoot: Boolean = true | |
): T { |
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
#!/usr/bin/env bash | |
# | |
# Скрипт для работы со стандартным конфигом в папке .idea | |
# | |
# Использование: | |
# ./idea_configs <команда> | |
# | |
# Возможные команды: | |
# u, untrack - Git не будет учитывать изменения в папке .idea | |
# t, track - Git будет учитывать изменения в папке .idea |
This file has been truncated, but you can view the full file.
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 androidx.paging.AsyncPagingDataDiffer | |
import androidx.paging.PagingData | |
import androidx.recyclerview.widget.DiffUtil | |
import androidx.recyclerview.widget.ListUpdateCallback | |
import kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.runBlocking | |
val differ: AsyncPagingDataDiffer<String> by lazy { | |
AsyncPagingDataDiffer( | |
diffCallback = diffCallback, |
OlderNewer