Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
IVIanuu committed Dec 31, 2017
0 parents commit 42d4cdb
Show file tree
Hide file tree
Showing 76 changed files with 2,441 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
6 changes: 6 additions & 0 deletions .idea/copyright/apache_v2.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2017 Manuel Wrage
*
* 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.
*/

buildscript {

ext {
androidPlugin = 'com.android.tools.build:gradle:3.0.1'
minSdkVersion = 14
minSdkVersionConductor = 16
compileSdkVersion = 27
targetSdkVersion = 27
buildToolsVersion = '26.0.2'

mavenPlugin = 'com.github.dcendents:android-maven-gradle-plugin:2.0'

conductor = 'com.bluelinelabs:conductor:2.1.4'

daggerVersion = '2.13'
dagger = "com.google.dagger:dagger:$daggerVersion"
daggerCompiler = "com.google.dagger:dagger-compiler:$daggerVersion"
daggerAndroid = "com.google.dagger:dagger-android:$daggerVersion"
daggerAndroidProcessor = "com.google.dagger:dagger-android-processor:$daggerVersion"

supportVersion = '27.0.1'
supportAnnotations = "com.android.support:support-annotations:$supportVersion"
supportAppCompat = "com.android.support:appcompat-v7:$supportVersion"

autoCommon = 'com.google.auto:auto-common:0.8'
autoService = 'com.google.auto.service:auto-service:1.0-rc2'

autoValue = 'com.google.auto.value:auto-value:1.2'

javaPoet = 'com.squareup:javapoet:1.9.0'
}

repositories {
jcenter()
google()
}
dependencies {
classpath rootProject.ext.androidPlugin
classpath rootProject.ext.mavenPlugin
}
}

allprojects {
repositories {
jcenter()
google()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
1 change: 1 addition & 0 deletions contributer-annotations/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
7 changes: 7 additions & 0 deletions contributer-annotations/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apply plugin: 'java-library'
apply plugin: 'com.github.dcendents.android-maven'

group='com.github.ivianuu'

sourceCompatibility = "1.8"
targetCompatibility = "1.8"
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2017 Manuel Wrage
*
* 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.
*/

package com.ivianuu.contributer.annotations;

import java.lang.annotation.Annotation;

/**
* Android injector key registry
*/
public @interface AndroidInjectorKeyRegistry {
/**
* The map keys which should be accepted on ContributesAndroidInjector annotations
*/
Class<? extends Annotation>[] keys() default {};
}
1 change: 1 addition & 0 deletions contributer-conductor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
55 changes: 55 additions & 0 deletions contributer-conductor/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

group='com.github.ivianuu'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersionConductor
targetSdkVersion rootProject.ext.targetSdkVersion
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
// Annotations
api project(':contributer-annotations')

// Conductor
api rootProject.ext.conductor

// Dagger
api rootProject.ext.dagger
api rootProject.ext.daggerAndroid
}

// build a jar with source files
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

task javadoc(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
}

// build a jar with javadoc
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives sourcesJar
archives javadocJar
}
21 changes: 21 additions & 0 deletions contributer-conductor/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
17 changes: 17 additions & 0 deletions contributer-conductor/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--
~ Copyright 2017 Manuel Wrage
~
~ 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.
-->

<manifest package="com.ivianuu.contributer.conductor" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.ivianuu.contributer.conductor;

import android.app.Activity;

import com.bluelinelabs.conductor.Controller;

import dagger.android.DispatchingAndroidInjector;
import dagger.internal.Preconditions;

/**
* Conductor injection
*/
public final class ConductorInjection {

private ConductorInjection() {
}

public static void inject(Controller controller) {
Preconditions.checkNotNull(controller, "controller");
HasControllerInjector hasDispatchingControllerInjector = findHasControllerInjector(controller);
DispatchingAndroidInjector<Controller> controllerInjector = hasDispatchingControllerInjector.controllerInjector();
Preconditions.checkNotNull(controllerInjector, "%s.controllerInjector() returned null",
hasDispatchingControllerInjector.getClass().getCanonicalName());
controllerInjector.inject(controller);
}

private static HasControllerInjector findHasControllerInjector(Controller controller) {
Controller parentController = controller;

do {
if ((parentController = parentController.getParentController()) == null) {
Activity activity = controller.getActivity();
if (activity instanceof HasControllerInjector) {
return (HasControllerInjector) activity;
}

if (activity.getApplication() instanceof HasControllerInjector) {
return (HasControllerInjector) activity.getApplication();
}

throw new IllegalArgumentException(
String.format("No injector was found for %s", controller.getClass().getCanonicalName()));
}
} while (!(parentController instanceof HasControllerInjector));

return (HasControllerInjector) parentController;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.ivianuu.contributer.conductor;

import android.app.Activity;

import com.bluelinelabs.conductor.Controller;

import java.util.Map;

import dagger.Module;
import dagger.android.AndroidInjector;
import dagger.multibindings.Multibinds;

/**
* Conductor injection module
*/
@Module
public abstract class ConductorInjectionModule {

@Multibinds
abstract Map<Class<? extends Controller>, AndroidInjector.Factory<? extends Controller>>
controllerInjectorFactories();
}
Loading

0 comments on commit 42d4cdb

Please sign in to comment.