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
inline fun <reified T : ViewModel> Fragment.hiltNavGraphViewModels(@IdRes navGraphIdRes: Int) = | |
viewModels<T>( | |
ownerProducer = { findNavController().getBackStackEntry(navGraphIdRes) }, | |
factoryProducer = { defaultViewModelProviderFactory } // TODO: FIX THIS. THIS ISN'T SUFFICIENT!!! | |
) |
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
@AndroidEntryPoint | |
class LoginFragment : Fragment(R.layout.login_fragment) { | |
private val viewModel by viewModels<LoginViewModel>() |
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
// dagger | |
implementation 'com.google.dagger:dagger:2.28' | |
kapt 'com.google.dagger:dagger-compiler:2.28' | |
// hilt | |
implementation 'com.google.dagger:hilt-android:2.28-alpha' | |
kapt 'com.google.dagger:hilt-android-compiler:2.28-alpha' | |
kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.28-alpha' | |
kaptTest 'com.google.dagger:hilt-android-compiler:2.28-alpha' | |
implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha01' |
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
<?xml version="1.0" encoding="utf-8"?> | |
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:id="@+id/root" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<androidx.fragment.app.FragmentContainerView | |
android:id="@+id/nav_host" | |
android:name="androidx.navigation.fragment.NavHostFragment" |
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 CreateLoginCredentialsFragment : KeyedFragment(R.layout.create_login_credentials_fragment) { | |
private val viewModel by lazy { lookup<RegistrationViewModel>() } | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
val binding = CreateLoginCredentialsFragmentBinding.bind(view) | |
// ... | |
} | |
} |
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
@Singleton | |
class MyClass @Inject constructor(private val factory: D.Factory) |
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
@Singleton | |
@Component(modules = [ | |
AppModule::class, | |
AssistedInjectionModule::class | |
]) | |
interface SingletonComponent { | |
} |
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
@AssistedModule | |
@Module(includes = {AssistedInject_AssistedInjectionModule.class}) | |
public class AssistedInjectionModule {} |