Assisted Inject Annotation Processor

Assisted injection for JSR 330

License

License

Categories

Categories

Square Business Logic Libraries Financial
GroupId

GroupId

com.squareup.inject
ArtifactId

ArtifactId

assisted-inject-processor
Last Version

Last Version

0.8.1
Release Date

Release Date

Type

Type

jar
Description

Description

Assisted Inject Annotation Processor
Assisted injection for JSR 330
Project URL

Project URL

https://github.com/square/AssistedInject/
Source Code Management

Source Code Management

https://github.com/square/AssistedInject/

Download assisted-inject-processor

How to add to project

<!-- https://jarcasting.com/artifacts/com.squareup.inject/assisted-inject-processor/ -->
<dependency>
    <groupId>com.squareup.inject</groupId>
    <artifactId>assisted-inject-processor</artifactId>
    <version>0.8.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.squareup.inject/assisted-inject-processor/
implementation 'com.squareup.inject:assisted-inject-processor:0.8.1'
// https://jarcasting.com/artifacts/com.squareup.inject/assisted-inject-processor/
implementation ("com.squareup.inject:assisted-inject-processor:0.8.1")
'com.squareup.inject:assisted-inject-processor:jar:0.8.1'
<dependency org="com.squareup.inject" name="assisted-inject-processor" rev="0.8.1">
  <artifact name="assisted-inject-processor" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.squareup.inject', module='assisted-inject-processor', version='0.8.1')
)
libraryDependencies += "com.squareup.inject" % "assisted-inject-processor" % "0.8.1"
[com.squareup.inject/assisted-inject-processor "0.8.1"]

Dependencies

compile (1)

Group / Artifact Type Version
com.squareup : javapoet jar 1.11.1

runtime (4)

Group / Artifact Type Version
com.squareup.inject : assisted-inject-annotations jar 0.8.1
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.41
com.google.auto : auto-common jar 0.10
com.google.guava : guava jar 26.0-jre

test (5)

Group / Artifact Type Version
junit : junit jar 4.12
com.google.truth : truth jar 0.42
com.google.testing.compile : compile-testing jar 0.15
javax.inject : javax.inject jar 1
com.google.dagger : dagger jar 2.33

Project Modules

There are no modules declared in this project.

Inflation Injection

Constructor-inject views during XML layout inflation.

Looking for Assisted Inject? It's built in to Dagger now!

Usage

Write your layout XML like normal.

<LinearLayout>
  <com.example.CustomView/>
  <TextView/>
</LinearLayout>

Use @InflationInject in CustomView:

public final class CustomView {
  private final Picasso picasso;
  
  @InflationInject
  public CustomView(
    @Inflated Context context,
    @Inflated AttributeSet attrs,
    Picasso picasso
  ) {
    super(context, attrs);
    this.picasso = picasso;
  }
  
  // ...
}

In order to allow Dagger to create your custom views, add @InflationModule to a Dagger module and add the generated module name to its includes=.

@InflationModule
@Module(includes = InflationInject_PresenterModule.class)
abstract class PresenterModule {}

The annotation processor will generate the InflationInject_PresenterModule for us. It will not be resolved until the processor runs.

Finally, inject InflationInjectFactory and add it to your LayoutInflater.

InflationInjectFactory factory = DaggerMainActivity_MainComponent.create().factory();
getLayoutInflater().setFactory(factory);

setContentView(R.layout.main_view);

Download

repositories {
  mavenCentral()
}
dependencies {
  implementation 'app.cash.inject:inflation-inject:1.0.0'
  annotationProcessor 'app.cash.inject:inflation-inject-processor:1.0.0'
}
Snapshots of the development version are available in Sonatype's snapshots repository.

repositories {
  maven {
    url 'https://oss.sonatype.org/content/repositories/snapshots/'
  }
}
dependencies {
  implementation 'app.cash.inject:inflation-inject:1.1.0-SNAPSHOT'
  annotationProcessor 'app.cash.inject:inflation-inject-processor:1.1.0-SNAPSHOT'
}

License

Copyright 2017 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
com.squareup.inject

Square

Versions

Version
0.8.1
0.8.0
0.7.0
0.6.1
0.6.0
0.5.2
0.5.1
0.5.0
0.4.0
0.3.3
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.2
0.1.1
0.1.0