• Rafal

    Rafal

    2 years ago
    Hi! TIL where you are using hilt there is new
    FragmentContextWrapper
    so calling any
    .context
    on any view that is in the fragment returns
    FragmentContextWrapper
    instead of an
    Activity
    . We have a
    Context
    extension:
    fun Context.navigateWithDirections(
        navDirections: NavDirections,
        navOptions: NavOptions? = NavOptions.Builder()
            .setEnterAnim(R.anim.nav_default_enter_anim)
            .setExitAnim(R.anim.nav_default_exit_anim)
            .setPopEnterAnim(R.anim.nav_default_pop_enter_anim)
            .setPopExitAnim(R.anim.nav_default_pop_exit_anim)
            .build()
    ) {
        (this as? Activity)?.findNavController(R.id.nav_host_fragment)?.navigate(navDirections, navOptions)
    }
    and this
    (this as? Activity)?
    check doesn’t pass cause there is
    FragmentContextWrapper
    . In the docs I see
    * Do not use except in Hilt generated code!
    So my question is. Is there any other way I can get the activity context instead of this wrapper?
    Rafal
    s
    +1
    3 replies
    Copy to Clipboard
  • h

    harry.singh

    2 years ago
    Hey! In efforts to providing a single instance of
    Retrofit
    for my application, I'm using the
    Singleton
    scope in my network module which is then included in the
    ApplicationComponent
    with the same
    Singleton
    scope. But in order to do that I've to add network dependencies to my
    app
    module too. Is it possible to keep my retrofit instance singleton across application without adding network dependencies in my app module?
    h
    gildor
    2 replies
    Copy to Clipboard
  • Jovan

    Jovan

    2 years ago
    Hi everyone, just wanted to check what do you think, is Hilt safe for production?
    Jovan
    r
    2 replies
    Copy to Clipboard
  • Daniel

    Daniel

    2 years ago
    Hey everyone, You can check out my project where I used dagger hilt with dynamic feature modules
    Daniel
    Manuel Vivo
    2 replies
    Copy to Clipboard
  • Christian Maier

    Christian Maier

    2 years ago
    Hi everyone, Let’s say I start an activity with some bundled data that I’d need way back in the repository. How can I provide that data using Hilt instead of passing it through several ${place_arch_pattern}-components? How do you solve problems like that?
    Christian Maier
    gildor
    6 replies
    Copy to Clipboard
  • Colton Idle

    Colton Idle

    2 years ago
    Learning more about dagger and I want to sanity check how plausible this sounds. I really want to simplify my app with dependencies and components/scopes. I think I want to have 3 scopes defined. 1. Application scope 2. Logged In User scope 3. Logged Out User scope So in my head I'll have 3 components ApplicationComponent, LoggedInComponent, and LoggedOutComponent. How does that sound at a high level? I feel like it will solve 90% of my problems for me and it'll give me a chance to learn about scopes/components, provides/modules, and how to actually wire that up into my fragments/activities/all other classes.
    Colton Idle
    gildor
    +1
    12 replies
    Copy to Clipboard
  • m

    miqbaldc

    2 years ago
    Is there any alternatives ways to provides a
    viewModelScope
    ? Moved to this issue instead with more details and examples: https://github.com/google/dagger/issues/2004
    m
    gildor
    11 replies
    Copy to Clipboard
  • Colton Idle

    Colton Idle

    2 years ago
    What is it called when my Component exposes some type via a field? Aka, instead of using field injection in Android, I can do X instead. I want to call them provision methods... but that sounds weird? Is that what people say when talking on a team? https://dagger.dev/api/latest/dagger/Component.html#provision-methods
    Colton Idle
    s
    +1
    4 replies
    Copy to Clipboard
  • Kulwinder Singh

    Kulwinder Singh

    2 years ago
    How to provide arguments like this
    Callback
    in Fragment using HILT
    class PostAdapter @Inject constructor(
        @ApplicationContext private val context: Context,
        private val callback: Callback //HOW THIS CAN BE PROVIDED FROM FRAGMENT
    ) : ListAdapter<Post, PostAdapter.Holder>(DIFF) {
    
      /.../
    
       interface Callback {
            fun onClick(post: Post)
        }
    
    }
    Kulwinder Singh
    Rafal
    +3
    25 replies
    Copy to Clipboard
  • Kulwinder Singh

    Kulwinder Singh

    2 years ago
    i mean how i can
    @Inject PostAdapter
    in any fragment ?
    Kulwinder Singh
    ritesh
    3 replies
    Copy to Clipboard