Skip to content

Commit 7e4b433

Browse files
committed
Merge pull request #43 from ReactiveX/submodules
New project structure based on submodules (added samples module)
2 parents 7079fae + af9f75a commit 7e4b433

File tree

87 files changed

+1195
-53
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1195
-53
lines changed

.gitignore

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
# Compiled source #
22
###################
3-
*.com
43
*.class
5-
*.dll
6-
*.exe
7-
*.o
8-
*.so
94

105
# Packages #
116
############
@@ -15,7 +10,6 @@
1510
*.dmg
1611
*.gz
1712
*.iso
18-
*.jar
1913
*.rar
2014
*.tar
2115
*.zip
@@ -66,10 +60,6 @@ bin/
6660
/.nb-gradle/profiles/private/
6761
.nb-gradle-properties
6862

69-
# Scala build
70-
*.cache
71-
/.nb-gradle/private/
72-
7363
# Android
7464
local.properties
7565

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
language: java
1+
language: android
22

33
jdk:
44
- oraclejdk7
5+
6+
android:
7+
components:
8+
- android-20
9+
10+
script: "./gradlew build"

build.gradle

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,3 @@ buildscript {
55
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:1.12.+'
66
}
77
}
8-
9-
apply plugin: 'rxjava-project'
10-
apply plugin: 'provided-base'
11-
12-
dependencies {
13-
compile 'io.reactivex:rxjava:1.0.+'
14-
provided 'com.google.android:android:4.0.1.2'
15-
provided 'com.google.android:support-v4:r7'
16-
17-
// testing
18-
testCompile 'junit:junit-dep:4.10'
19-
testCompile 'org.mockito:mockito-core:1.8.5'
20-
testCompile('org.robolectric:robolectric:2.3') {
21-
exclude group: 'com.android.support'
22-
}
23-
}
24-
25-
test {
26-
testLogging {
27-
exceptionFormat "full"
28-
events "started"
29-
displayGranularity 2
30-
}
31-
}

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
version=1.0.0-RC1-SNAPSHOT
1+
rxJavaVersion=1.0.0-rc.9
2+
version=0.22.0

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Thu Sep 18 17:51:34 CEST 2014
1+
#Wed Oct 22 12:19:29 CEST 2014
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME

library/build.gradle

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
buildscript {
2+
repositories { jcenter() }
3+
dependencies {
4+
classpath 'com.netflix.nebula:gradle-rxjava-project-plugin:1.12.+'
5+
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:1.12.+'
6+
}
7+
}
8+
9+
apply plugin: 'rxjava-project'
10+
apply plugin: 'provided-base'
11+
12+
dependencies {
13+
compile "io.reactivex:rxjava:$rxJavaVersion"
14+
provided 'com.google.android:android:4.0.1.2'
15+
provided 'com.google.android:support-v4:r7'
16+
17+
// testing
18+
testCompile 'junit:junit-dep:4.10'
19+
testCompile 'org.mockito:mockito-core:1.8.5'
20+
testCompile('org.robolectric:robolectric:2.3') {
21+
exclude group: 'com.android.support'
22+
}
23+
}
24+
25+
test {
26+
testLogging {
27+
exceptionFormat "full"
28+
events "started"
29+
displayGranularity 2
30+
}
31+
}

src/main/java/rx/functions/ViewAction1.java renamed to library/src/main/java/rx/android/functions/ViewAction1.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515

1616
import android.view.View;
1717

18-
import rx.functions.Action1;
19-
2018
import java.lang.ref.WeakReference;
2119

20+
import rx.functions.Action1;
21+
2222
/**
2323
* An {@link Action1} implementation specific for {@link View}s.
2424
*

src/test/java/rx/functions/ViewAction1Test.java renamed to library/src/test/java/rx/android/functions/ViewAction1Test.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import org.junit.Test;
1919
import org.junit.runner.RunWith;
20-
import org.robolectric.Robolectric;
2120
import org.robolectric.RobolectricTestRunner;
2221

2322
import rx.subjects.PublishSubject;

src/test/java/rx/functions/ViewActionSetActivatedTest.java renamed to library/src/test/java/rx/android/functions/ViewActionSetActivatedTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import org.junit.Test;
1919
import org.junit.runner.RunWith;
20-
import org.robolectric.Robolectric;
2120
import org.robolectric.RobolectricTestRunner;
2221

2322
import rx.subjects.PublishSubject;

src/test/java/rx/functions/ViewActionSetClickableTest.java renamed to library/src/test/java/rx/android/functions/ViewActionSetClickableTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import org.junit.Test;
1919
import org.junit.runner.RunWith;
20-
import org.robolectric.Robolectric;
2120
import org.robolectric.RobolectricTestRunner;
2221

2322
import rx.subjects.PublishSubject;

src/test/java/rx/android/schedulers/HandlerThreadSchedulerTest.java renamed to library/src/test/java/rx/android/schedulers/HandlerThreadSchedulerTest.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,7 @@
1313
*/
1414
package rx.android.schedulers;
1515

16-
import static org.mockito.Matchers.any;
17-
import static org.mockito.Matchers.eq;
18-
import static org.mockito.Mockito.mock;
19-
import static org.mockito.Mockito.never;
20-
import static org.mockito.Mockito.spy;
21-
import static org.mockito.Mockito.verify;
22-
import static org.mockito.Mockito.when;
23-
24-
import java.util.concurrent.TimeUnit;
16+
import android.os.Handler;
2517

2618
import org.junit.Test;
2719
import org.junit.runner.RunWith;
@@ -31,14 +23,21 @@
3123
import org.robolectric.RobolectricTestRunner;
3224
import org.robolectric.annotation.Config;
3325

26+
import java.util.concurrent.TimeUnit;
27+
3428
import rx.Observable;
3529
import rx.Scheduler;
3630
import rx.Scheduler.Worker;
3731
import rx.Subscriber;
3832
import rx.Subscription;
3933
import rx.functions.Action0;
40-
import rx.functions.Action1;
41-
import android.os.Handler;
34+
35+
import static org.mockito.Matchers.eq;
36+
import static org.mockito.Mockito.mock;
37+
import static org.mockito.Mockito.never;
38+
import static org.mockito.Mockito.spy;
39+
import static org.mockito.Mockito.verify;
40+
import static org.mockito.Mockito.when;
4241

4342
@RunWith(RobolectricTestRunner.class)
4443
@Config(manifest=Config.NONE)

samples-build-wrapper/build.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apply plugin: 'java'
2+
3+
tasks.assemble.doLast {
4+
def androidHome = System.getenv("ANDROID_HOME")
5+
if (androidHome) {
6+
println "Found ANDROID_HOME at $androidHome"
7+
} else {
8+
throw new Exception("ANDROID_HOME not found")
9+
}
10+
project.exec {
11+
workingDir '../samples'
12+
commandLine "./gradlew", "clean", "packageDebug"
13+
}
14+
}

samples/app/build.gradle

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 20
5+
buildToolsVersion "20"
6+
7+
defaultConfig {
8+
minSdkVersion 14
9+
targetSdkVersion 20
10+
versionCode 1
11+
versionName "1.0"
12+
}
13+
buildTypes {
14+
release {
15+
runProguard false
16+
}
17+
}
18+
}
19+
20+
// make sure we always compile against the latest version of RxAndroid
21+
def rootProjectProperties = new Properties()
22+
file("../../gradle.properties").withReader { reader ->
23+
rootProjectProperties.load(reader)
24+
properties.putAll(rootProjectProperties)
25+
}
26+
27+
dependencies {
28+
def version = rootProjectProperties.get("version")
29+
compile "io.reactivex:rxandroid:$version"
30+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="rx.android.samples" >
4+
5+
<application
6+
android:name=".SamplesApplication"
7+
android:allowBackup="true"
8+
android:icon="@drawable/ic_launcher"
9+
android:theme="@style/AppTheme"
10+
android:label="@string/app_name">
11+
<activity
12+
android:name=".UIBindingActivity">
13+
14+
<intent-filter>
15+
<category android:name="android.intent.category.LAUNCHER"/>
16+
<category android:name="android.intent.category.DEFAULT"/>
17+
<action android:name="android.intent.action.MAIN"/>
18+
</intent-filter>
19+
</activity>
20+
<activity
21+
android:name=".RetainedFragmentActivity">
22+
23+
<intent-filter>
24+
<category android:name="android.intent.category.LAUNCHER"/>
25+
<category android:name="android.intent.category.DEFAULT"/>
26+
<action android:name="android.intent.action.MAIN"/>
27+
</intent-filter>
28+
</activity>
29+
<activity
30+
android:name=".ListeningFragmentActivity">
31+
32+
<intent-filter>
33+
<category android:name="android.intent.category.LAUNCHER"/>
34+
<category android:name="android.intent.category.DEFAULT"/>
35+
<action android:name="android.intent.action.MAIN"/>
36+
</intent-filter>
37+
</activity>
38+
<activity
39+
android:name=".ListFragmentActivity">
40+
41+
<intent-filter>
42+
<category android:name="android.intent.category.LAUNCHER"/>
43+
<category android:name="android.intent.category.DEFAULT"/>
44+
<action android:name="android.intent.action.MAIN"/>
45+
</intent-filter>
46+
</activity>
47+
<activity
48+
android:name=".ListenInOutActivity">
49+
50+
<intent-filter>
51+
<category android:name="android.intent.category.LAUNCHER"/>
52+
<category android:name="android.intent.category.DEFAULT"/>
53+
<action android:name="android.intent.action.MAIN"/>
54+
</intent-filter>
55+
</activity>
56+
</application>
57+
58+
</manifest>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package rx.android.samples;
2+
3+
import android.app.Activity;
4+
import android.app.ListFragment;
5+
import android.os.Bundle;
6+
import android.widget.ArrayAdapter;
7+
8+
import rx.Observable;
9+
import rx.Subscriber;
10+
11+
import static rx.android.schedulers.AndroidSchedulers.mainThread;
12+
13+
/**
14+
* Problem:
15+
* You have an asynchronous sequence that emits items to be displayed in a list. You want the data
16+
* to survive rotation changes.
17+
* <p/>
18+
* Solution:
19+
* Combine {@link android.app.Fragment#setRetainInstance(boolean)} in a ListFragment with
20+
* {@link rx.android.schedulers.AndroidSchedulers#mainThread()} and an {@link rx.Observable.Operator}
21+
* that binds to the list adapter.
22+
*/
23+
public class ListFragmentActivity extends Activity {
24+
25+
@Override
26+
protected void onCreate(Bundle savedInstanceState) {
27+
super.onCreate(savedInstanceState);
28+
setTitle("Lists");
29+
setContentView(R.layout.list_fragment_activity);
30+
}
31+
32+
@SuppressWarnings("ConstantConditions")
33+
public static class RetainedListFragment extends ListFragment {
34+
35+
private ArrayAdapter<String> adapter;
36+
37+
public RetainedListFragment() {
38+
setRetainInstance(true);
39+
}
40+
41+
@Override
42+
public void onCreate(Bundle savedInstanceState) {
43+
super.onCreate(savedInstanceState);
44+
45+
adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1);
46+
setListAdapter(adapter);
47+
SampleObservables.numberStrings(1, 20, 250)
48+
.observeOn(mainThread())
49+
.lift(new BindAdapter())
50+
.subscribe();
51+
}
52+
53+
private final class BindAdapter implements Observable.Operator<String, String> {
54+
@Override
55+
public Subscriber<? super String> call(Subscriber<? super String> subscriber) {
56+
return new Subscriber<String>() {
57+
@Override
58+
public void onCompleted() {
59+
adapter.notifyDataSetChanged();
60+
}
61+
62+
@Override
63+
public void onError(Throwable throwable) {
64+
65+
}
66+
67+
@Override
68+
public void onNext(String strings) {
69+
adapter.add(strings);
70+
}
71+
};
72+
}
73+
}
74+
}
75+
}

0 commit comments

Comments
 (0)