Skip to content

Commit b4811d0

Browse files
authored
Merge pull request #498 from google/moe_sync_11/15/2016
Moe sync 11/15/2016
2 parents e20517e + 5abbc82 commit b4811d0

23 files changed

+1762
-621
lines changed

.travis.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ jdk:
55

66
android:
77
components:
8-
- build-tools-23.0.0
9-
- android-23
10-
licenses:
11-
- android-sdk-license-5be876d5
8+
- tools
9+
- tools # Duplicated as per https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943
10+
- build-tools-25.0.0
11+
- android-25
12+
- platform-tools
13+
- extra-android-m2repository
1214

1315
before_install:
1416
- sudo rm -f /etc/mavenrc
@@ -38,3 +40,7 @@ branches:
3840
only:
3941
- master
4042
- /^release.*$/
43+
44+
cache:
45+
directories:
46+
- $HOME/.m2

android/pom.xml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (C) 2016 Google, Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
18+
<modelVersion>4.0.0</modelVersion>
19+
20+
<parent>
21+
<groupId>com.google.dagger</groupId>
22+
<artifactId>dagger-parent</artifactId>
23+
<version>HEAD-SNAPSHOT</version>
24+
</parent>
25+
26+
<artifactId>dagger-android</artifactId>
27+
<name>Dagger for Android</name>
28+
29+
<packaging>aar</packaging>
30+
31+
<properties>
32+
<java.version>1.6</java.version>
33+
</properties>
34+
35+
<repositories>
36+
<repository>
37+
<id>android-support</id>
38+
<url>file://${env.ANDROID_HOME}/extras/android/m2repository</url>
39+
</repository>
40+
</repositories>
41+
42+
<dependencies>
43+
<dependency>
44+
<groupId>com.google.dagger</groupId>
45+
<artifactId>dagger</artifactId>
46+
<version>${project.version}</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>com.google.android</groupId>
50+
<artifactId>android</artifactId>
51+
<scope>provided</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>com.android.support</groupId>
55+
<artifactId>support-v4</artifactId>
56+
<type>aar</type>
57+
</dependency>
58+
<dependency>
59+
<groupId>com.android.support</groupId>
60+
<artifactId>support-annotations</artifactId>
61+
</dependency>
62+
</dependencies>
63+
64+
<build>
65+
<plugins>
66+
<plugin>
67+
<groupId>com.simpligility.maven.plugins</groupId>
68+
<artifactId>android-maven-plugin</artifactId>
69+
<extensions>true</extensions>
70+
<configuration>
71+
<sdk>
72+
<platform>${android.latest.version}</platform>
73+
<path>${env.ANDROID_HOME}</path>
74+
</sdk>
75+
</configuration>
76+
</plugin>
77+
</plugins>
78+
</build>
79+
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) 2016 The Dagger Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package test.android;
18+
19+
import java.lang.annotation.Annotation;
20+
import javax.inject.Qualifier;
21+
22+
@Qualifier
23+
@interface InScope {
24+
Class<? extends Annotation> value();
25+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (C) 2016 The Dagger Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package test.android;
18+
19+
import static android.content.ComponentCallbacks2.TRIM_MEMORY_MODERATE;
20+
import static java.lang.annotation.ElementType.METHOD;
21+
import static java.lang.annotation.ElementType.TYPE;
22+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
23+
24+
import dagger.android.ReleaseReferencesAt;
25+
import java.lang.annotation.Documented;
26+
import java.lang.annotation.Retention;
27+
import java.lang.annotation.Target;
28+
import javax.inject.Scope;
29+
30+
@Documented
31+
@Retention(RUNTIME)
32+
@Target({TYPE, METHOD})
33+
@ReleaseReferencesAt(TRIM_MEMORY_MODERATE)
34+
@Scope
35+
@interface ReleaseWhenModerate {}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (C) 2016 The Dagger Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package test.android;
18+
19+
import static android.content.ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN;
20+
import static java.lang.annotation.ElementType.METHOD;
21+
import static java.lang.annotation.ElementType.TYPE;
22+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
23+
24+
import dagger.android.ReleaseReferencesAt;
25+
import java.lang.annotation.Documented;
26+
import java.lang.annotation.Retention;
27+
import java.lang.annotation.Target;
28+
import javax.inject.Scope;
29+
30+
@Documented
31+
@Retention(RUNTIME)
32+
@Target({TYPE, METHOD})
33+
@ReleaseReferencesAt(TRIM_MEMORY_UI_HIDDEN)
34+
@Scope
35+
@interface ReleaseWhenUiHidden {}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (C) 2016 The Dagger Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package test.android;
18+
19+
import dagger.Component;
20+
import dagger.android.AndroidMemorySensitiveReferenceManager;
21+
import javax.inject.Singleton;
22+
23+
@Singleton
24+
@ReleaseWhenUiHidden
25+
@ReleaseWhenModerate
26+
@Component(modules = TestModule.class)
27+
interface TestComponent {
28+
AndroidMemorySensitiveReferenceManager manager();
29+
30+
@InScope(ReleaseWhenUiHidden.class)
31+
Object releasedWhenUiHidden();
32+
33+
@InScope(ReleaseWhenModerate.class)
34+
Object releasedWhenModerate();
35+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (C) 2016 The Dagger Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package test.android;
18+
19+
import dagger.Module;
20+
import dagger.Provides;
21+
22+
@Module
23+
class TestModule {
24+
int releasedWhenUiHiddenCalls;
25+
int releasedWhenModerateCalls;
26+
27+
@Provides
28+
@ReleaseWhenUiHidden
29+
@InScope(ReleaseWhenUiHidden.class)
30+
Object releasedWhenUiHidden() {
31+
++releasedWhenUiHiddenCalls;
32+
return new Object();
33+
}
34+
35+
@Provides
36+
@ReleaseWhenModerate
37+
@InScope(ReleaseWhenModerate.class)
38+
Object releasedWhenModerate() {
39+
++releasedWhenModerateCalls;
40+
return new Object();
41+
}
42+
}

0 commit comments

Comments
 (0)