Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
Remove assisted inject
Browse files Browse the repository at this point in the history
It has been upstreamed into Dagger. This project will now only host inflation inject.
  • Loading branch information
JakeWharton committed Mar 26, 2021
1 parent 45dd245 commit a1309fc
Show file tree
Hide file tree
Showing 48 changed files with 158 additions and 3,803 deletions.
26 changes: 0 additions & 26 deletions .buildscript/deploy_snapshot.sh

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: build

on: [push, pull_request]

env:
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false -Dkotlin.incremental=false"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: gradle/wrapper-validation-action@v1

- uses: actions/setup-java@v1
with:
java-version: 1.8

- run: ./gradlew build

- run: ./gradlew uploadArchives
if: github.ref == 'refs/heads/master'
env:
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

87 changes: 42 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,72 @@
Assisted Injection for JSR 330
==============================
# Inflation Injection

Manually injected dependencies for your JSR 330 configuration. More about assisted injections in
the [Guice wiki](https://github.com/google/guice/wiki/AssistedInject).
Constructor-inject views during XML layout inflation.

Looking for Assisted Inject? It's [built in to Dagger now](https://dagger.dev/dev-guide/assisted-injection.html)!

Usage
-----

```java
class MyPresenter {
@AssistedInject
MyPresenter(Long foo, @Assisted String bar) {}

@AssistedInject.Factory
interface Factory {
MyPresenter create(String bar);
}
}
```
## Usage

This will generate the following:
Write your layout XML like normal.

```java
public final class MyPresenter_AssistedFactory implements MyPresenter.Factory {
private final Provider<Long> foo;
```xml
<LinearLayout>
<com.example.CustomView/>
<TextView/>
</LinearLayout>
```

@Inject public MyPresenter_AssistedFactory(Provider<Long> foo) {
this.foo = foo;
}
Use `@InflationInject` in `CustomView`:

@Override public MyPresenter create(String bar) {
return new MyPresenter(foo.get(), bar);
```java
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;
}

// ...
}
```


Usage with Dagger 2
-------------------

In order to allow Dagger to use the generated factory, define an assisted dagger module anywhere in
the same gradle module:
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=`.

```java
@AssistedModule
@Module(includes = AssistedInject_PresenterModule.class)
@InflationModule
@Module(includes = InflationInject_PresenterModule.class)
abstract class PresenterModule {}
```

The library will generate the `AssistedInject_PresenterModule` for us.
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`.

Download
--------
```java
InflationInjectFactory factory = DaggerMainActivity_MainComponent.create().factory();
getLayoutInflater().setFactory(factory);

```groovy
compileOnly 'com.squareup.inject:assisted-inject-annotations:0.8.1'
annotationProcessor 'com.squareup.inject:assisted-inject-processor:0.8.1'
setContentView(R.layout.main_view);
```

With Dagger 2:

## Download

```groovy
compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.8.1'
annotationProcessor 'com.squareup.inject:assisted-inject-processor-dagger2:0.8.1'
implementation 'com.squareup.inject:inflation-inject:0.9.0'
annotationProcessor 'com.squareup.inject:inflation-inject-processor:0.9.0'
```


License
=======
# License

Copyright 2017 Square, Inc.

Expand Down
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Releasing
========

1. Change the version in `gradle.properties` to a non-SNAPSHOT verson.
1. Change the version in `gradle.properties` to a non-SNAPSHOT version.
2. Update the `CHANGELOG.md` for the impending release.
3. Update the `README.md` with the new version.
4. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version)
Expand Down
10 changes: 0 additions & 10 deletions assisted-inject-annotations-dagger2/build.gradle

This file was deleted.

3 changes: 0 additions & 3 deletions assisted-inject-annotations-dagger2/gradle.properties

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions assisted-inject-annotations/build.gradle

This file was deleted.

3 changes: 0 additions & 3 deletions assisted-inject-annotations/gradle.properties

This file was deleted.

This file was deleted.

This file was deleted.

32 changes: 0 additions & 32 deletions assisted-inject-processor-dagger2/build.gradle

This file was deleted.

3 changes: 0 additions & 3 deletions assisted-inject-processor-dagger2/gradle.properties

This file was deleted.

Loading

0 comments on commit a1309fc

Please sign in to comment.