Giter Site home page Giter Site logo

Comments (8)

jaychang0917 avatar jaychang0917 commented on September 25, 2024

I think there my not be a good way to allow dagger to create the view directly as view creation in xml must be created via the inflater factory. But for creating view in code we may create an assisted inject factory to work around this limitation. However, there is no @InflationInject.Factory now, @JakeWharton do you have any idea?

from inflationinject.

JakeWharton avatar JakeWharton commented on September 25, 2024

Where are the Context and AttributeSet supposed to come from in this case?

from inflationinject.

jaychang0917 avatar jaychang0917 commented on September 25, 2024

For example, to create the ProductView programatically, we can pass the Context of ProductListView and no AttributeSet needed, am I right?

from inflationinject.

JakeWharton avatar JakeWharton commented on September 25, 2024

The requested provider comes from Dagger, though. How does the context propagate to the Dagger-provided binding when it never exists in the Dagger graph?

from inflationinject.

jaychang0917 avatar jaychang0917 commented on September 25, 2024

I seems don't get your meaning, for the following code, which part never exists in the Dagger graph?

class ProductView @InflationInject constructor(
    @Assisted context: Context,
    @Assisted attrs: AttributeSet? = null,
    imageLoader: ImageLoader
) {
    @InflationInject.Factory
    interface Factory {
        fun create(context: Context): ProductView
    }
}

class ProductListView @InflationInject constructor(
    @Assisted context: Context,
    @Assisted attrs: AttributeSet? = null,
    productViewFactory: ProductView.Factory
) {
    val productView = productViewFactory.create(context)
}

from inflationinject.

JakeWharton avatar JakeWharton commented on September 25, 2024

Nothing. But that's a very different snippet than the original.

from inflationinject.

jaychang0917 avatar jaychang0917 commented on September 25, 2024

Nothing. But that's a very different snippet than the original.

Sorry for my unclear wording.🙇🏻‍♂️

from inflationinject.

JakeWharton avatar JakeWharton commented on September 25, 2024

I don't think this is something that is in scope of the library. It's either that your views have normal @Inject constructors which means they can be injected or they're @InflationInject constructors which means they can be injected by the LayoutInflater.Factory.

from inflationinject.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.