Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moe sync #603

Merged
merged 4 commits into from
Mar 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 9 additions & 16 deletions compiler/src/main/java/dagger/internal/codegen/CodeBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,8 @@ final class CodeBlocks {
* use as type parameters or javadoc method arguments.
*/
static Collector<TypeName, ?, CodeBlock> toTypeNamesCodeBlock() {
return typeNamesIntoCodeBlock(CodeBlock.builder());
}

/**
* Adds {@link TypeName} instances to the given {@link CodeBlock.Builder} in a comma-separated
* list for use as type parameters or javadoc method arguments.
*/
static Collector<TypeName, ?, CodeBlock> typeNamesIntoCodeBlock(CodeBlock.Builder builder) {
return Collector.of(
() -> new CodeBlockJoiner(", ", builder),
() -> new CodeBlockJoiner(", ", CodeBlock.builder()),
CodeBlockJoiner::addTypeName,
CodeBlockJoiner::merge,
CodeBlockJoiner::join);
Expand Down Expand Up @@ -164,13 +156,14 @@ static CodeBlock javadocLinkTo(ExecutableElement executableElement) {
throw new AssertionError(executableElement.toString());
}
builder.add("(");
executableElement
.getParameters()
.stream()
.map(VariableElement::asType)
.map(TypeName::get)
.map(TypeNames::rawTypeName)
.collect(typeNamesIntoCodeBlock(builder));
builder.add(
executableElement
.getParameters()
.stream()
.map(VariableElement::asType)
.map(TypeName::get)
.map(TypeNames::rawTypeName)
.collect(toTypeNamesCodeBlock()));
return builder.add(")}").build();
}

Expand Down
2 changes: 1 addition & 1 deletion java/dagger/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dagger.android">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="24" />
<uses-sdk android:minSdkVersion="14" />
</manifest>
2 changes: 1 addition & 1 deletion java/dagger/android/DaggerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public abstract class DaggerActivity extends Activity implements HasDispatchingF

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidInjection.inject(this);
super.onCreate(savedInstanceState);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion java/dagger/android/DaggerFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public abstract class DaggerFragment extends Fragment implements HasDispatchingF

@Override
public void onAttach(Context context) {
super.onAttach(context);
AndroidInjection.inject(this);
super.onAttach(context);
}

@Override
Expand Down
5 changes: 1 addition & 4 deletions java/dagger/android/support/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,5 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dagger.android.support">

<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="24"/>
<uses-sdk android:minSdkVersion="14" />
</manifest>
2 changes: 1 addition & 1 deletion java/dagger/android/support/DaggerAppCompatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public abstract class DaggerAppCompatActivity extends AppCompatActivity

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidInjection.inject(this);
super.onCreate(savedInstanceState);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion java/dagger/android/support/DaggerFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public abstract class DaggerFragment extends Fragment implements

@Override
public void onAttach(Context context) {
super.onAttach(context);
AndroidSupportInjection.inject(this);
super.onAttach(context);
}

@Override
Expand Down
22 changes: 21 additions & 1 deletion javatests/dagger/android/support/functional/InjectorsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,30 @@

import static com.google.common.truth.Truth.assertThat;

import android.content.res.Configuration;
import org.robolectric.RobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
public class InjectorsTest {
private static final String MANIFEST =
"//javatests/dagger/android/support/functional"
+ ":functional/AndroidManifest.xml";

private ActivityController<TestActivity> activityController;
private TestActivity activity;
private TestParentFragment parentFragment;
private TestChildFragment childFragment;

@Before
public void setUp() {
activity = Robolectric.setupActivity(TestActivity.class);
activityController = Robolectric.buildActivity(TestActivity.class);
activity = activityController.setup().get();
parentFragment =
(TestParentFragment)
activity.getSupportFragmentManager().findFragmentByTag("parent-fragment");
Expand Down Expand Up @@ -72,6 +77,8 @@ public void componentStructureFollowsControllerStructure() {
.ActivitySubcomponent.ParentFragmentSubcomponent.class,
ComponentStructureFollowsControllerStructureApplication.ApplicationComponent
.ActivitySubcomponent.ParentFragmentSubcomponent.ChildFragmentSubcomponent.class);

changeConfiguration();
}

@Test
Expand All @@ -92,5 +99,18 @@ public void AllControllersAreDirectChildrenOfApplication() {
AllControllersAreDirectChildrenOfApplication.ApplicationComponent.class,
AllControllersAreDirectChildrenOfApplication.ApplicationComponent
.ChildFragmentSubcomponent.class);

changeConfiguration();
}

// https://github.com/google/dagger/issues/598
private void changeConfiguration() {
Configuration oldConfiguration = activity.getResources().getConfiguration();
Configuration newConfiguration = new Configuration(oldConfiguration);
newConfiguration.orientation =
oldConfiguration.orientation == Configuration.ORIENTATION_LANDSCAPE
? Configuration.ORIENTATION_PORTRAIT
: Configuration.ORIENTATION_LANDSCAPE;
activityController.configurationChange(newConfiguration);
}
}
3 changes: 2 additions & 1 deletion util/execute-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ python $(dirname $0)/maven/generate_poms.py $VERSION_NAME \
//compiler:compiler \
//producers:producers \
//java/dagger/android:android \
//java/dagger/android/support:support
//java/dagger/android/support:support \
//java/dagger/android/processor:processor

library_output_file() {
library=$1
Expand Down