This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.annotation.MainThread | |
import androidx.lifecycle.MutableLiveData | |
import java.util.LinkedList | |
import java.util.Queue | |
/** | |
* Класс-очередь для обработки временных событий, не являющихся частью View | |
* Например, показ SnackBar с сообщением или ошибкой. | |
*/ | |
class EventsQueue : MutableLiveData<Queue<Event>>() { |
This file contains hidden or 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 android.app.Activity | |
import android.app.Application | |
import android.content.ComponentCallbacks | |
import android.content.Context | |
import android.content.res.Configuration | |
import android.os.Build | |
import android.os.Bundle | |
import java.util.Locale | |
private const val LANGUAGE_RU = "ru" |
This file contains hidden or 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 hidden or 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 hidden or 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 retrofit2.adapter.rxjava2 | |
import io.reactivex.Completable | |
import io.reactivex.Flowable | |
import io.reactivex.Maybe | |
import io.reactivex.Observable | |
import io.reactivex.Single | |
import retrofit2.Call | |
import retrofit2.CallAdapter | |
import retrofit2.Retrofit |
This file contains hidden or 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" | |
} | |
} |
NewerOlder