forked from evant/gradle-retrolambda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
255 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<TextView | ||
android:id="@+id/text" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" | ||
tools:text="Hello, retrolambda!"/> | ||
|
||
<TextView | ||
android:id="@+id/text_lib" | ||
<data> | ||
|
||
<variable | ||
name="fun" | ||
type="me.tatarka.retrolambda.sample.lib.Function" /> | ||
</data> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" | ||
tools:text="Hello, retrolambda (from lib)!"/> | ||
</LinearLayout> | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/text" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" | ||
tools:text="Hello, retrolambda!" /> | ||
|
||
<TextView | ||
android:id="@+id/text_lib" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" | ||
tools:text="Hello, retrolambda (from lib)!" /> | ||
|
||
<TextView | ||
android:id="@+id/text_databinding" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="16dp" | ||
android:text="@{fun}" | ||
tools:text="Hello, retrolambda (from databinding)!" /> | ||
</LinearLayout> | ||
</layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
sample-android-lib/src/main/java/me/tatarka/retrolambda/sample/lib/BindingAdapters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package me.tatarka.retrolambda.sample.lib; | ||
|
||
import android.databinding.BindingAdapter; | ||
import android.widget.TextView; | ||
|
||
public class BindingAdapters { | ||
@BindingAdapter("android:text") | ||
public static void setTextFunction(TextView textView, Function function) { | ||
String value = function.run(); | ||
textView.setText(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
src/test/groovy/me/tatarka/RetrolambdaAndroidPluginTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package me.tatarka | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.testfixtures.ProjectBuilder | ||
import org.junit.Test | ||
|
||
import static org.junit.Assert.assertNotNull | ||
|
||
class RetrolambdaAndroidPluginTest { | ||
@Test | ||
void testCreateTask() { | ||
Project project = ProjectBuilder.builder().build() | ||
project.apply plugin: 'com.android.application' | ||
project.apply plugin: 'me.tatarka.retrolambda' | ||
project.android { | ||
compileSdkVersion 19 | ||
buildToolsVersion "19.1" | ||
|
||
defaultConfig { | ||
minSdkVersion 14 | ||
targetSdkVersion 19 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
} | ||
project.evaluate() | ||
assertNotNull project.tasks.findByName('compileRetrolambdaDebug') | ||
} | ||
|
||
@Test | ||
void testCreateBuildTypeTask() { | ||
Project project = ProjectBuilder.builder().build() | ||
project.apply plugin: 'com.android.application' | ||
project.apply plugin: 'me.tatarka.retrolambda' | ||
project.android { | ||
compileSdkVersion 19 | ||
buildToolsVersion "19.1" | ||
|
||
defaultConfig { | ||
minSdkVersion 14 | ||
targetSdkVersion 19 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
|
||
buildTypes { | ||
other | ||
} | ||
} | ||
project.evaluate() | ||
assertNotNull project.tasks.findByName('compileRetrolambdaOther') | ||
} | ||
|
||
@Test | ||
void testCreateFlavorTask() { | ||
Project project = ProjectBuilder.builder().build() | ||
project.apply plugin: 'com.android.application' | ||
project.apply plugin: 'me.tatarka.retrolambda' | ||
project.android { | ||
compileSdkVersion 19 | ||
buildToolsVersion "19.1" | ||
|
||
defaultConfig { | ||
minSdkVersion 14 | ||
targetSdkVersion 19 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
|
||
productFlavors { | ||
other | ||
} | ||
} | ||
project.evaluate() | ||
assertNotNull project.tasks.findByName('compileRetrolambdaOtherDebug') | ||
} | ||
|
||
@Test | ||
void testAptCompatibility() { | ||
Project project = ProjectBuilder.builder().build() | ||
project.apply plugin: 'com.android.application' | ||
project.apply plugin: 'com.neenbedankt.android-apt' | ||
project.apply plugin: 'me.tatarka.retrolambda' | ||
project.android { | ||
compileSdkVersion 19 | ||
buildToolsVersion "19.1" | ||
|
||
defaultConfig { | ||
minSdkVersion 14 | ||
targetSdkVersion 19 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
} | ||
project.repositories { | ||
mavenCentral() | ||
} | ||
project.dependencies { | ||
apt 'com.google.dagger:dagger-compiler:2.0' | ||
} | ||
project.evaluate() | ||
//TODO: what exactly should I be looking for? | ||
} | ||
} |
Oops, something went wrong.