-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from ReactiveX/submodules
New project structure based on submodules (added samples module)
- Loading branch information
Showing
87 changed files
with
1,195 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
language: java | ||
language: android | ||
|
||
jdk: | ||
- oraclejdk7 | ||
|
||
android: | ||
components: | ||
- android-20 | ||
|
||
script: "./gradlew build" |
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 +1,2 @@ | ||
version=1.0.0-RC1-SNAPSHOT | ||
rxJavaVersion=1.0.0-rc.9 | ||
version=0.22.0 |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
buildscript { | ||
repositories { jcenter() } | ||
dependencies { | ||
classpath 'com.netflix.nebula:gradle-rxjava-project-plugin:1.12.+' | ||
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:1.12.+' | ||
} | ||
} | ||
|
||
apply plugin: 'rxjava-project' | ||
apply plugin: 'provided-base' | ||
|
||
dependencies { | ||
compile "io.reactivex:rxjava:$rxJavaVersion" | ||
provided 'com.google.android:android:4.0.1.2' | ||
provided 'com.google.android:support-v4:r7' | ||
|
||
// testing | ||
testCompile 'junit:junit-dep:4.10' | ||
testCompile 'org.mockito:mockito-core:1.8.5' | ||
testCompile('org.robolectric:robolectric:2.3') { | ||
exclude group: 'com.android.support' | ||
} | ||
} | ||
|
||
test { | ||
testLogging { | ||
exceptionFormat "full" | ||
events "started" | ||
displayGranularity 2 | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apply plugin: 'java' | ||
|
||
tasks.assemble.doLast { | ||
def androidHome = System.getenv("ANDROID_HOME") | ||
if (androidHome) { | ||
println "Found ANDROID_HOME at $androidHome" | ||
} else { | ||
throw new Exception("ANDROID_HOME not found") | ||
} | ||
project.exec { | ||
workingDir '../samples' | ||
commandLine "./gradlew", "clean", "packageDebug" | ||
} | ||
} |
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,30 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 20 | ||
buildToolsVersion "20" | ||
|
||
defaultConfig { | ||
minSdkVersion 14 | ||
targetSdkVersion 20 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
runProguard false | ||
} | ||
} | ||
} | ||
|
||
// make sure we always compile against the latest version of RxAndroid | ||
def rootProjectProperties = new Properties() | ||
file("../../gradle.properties").withReader { reader -> | ||
rootProjectProperties.load(reader) | ||
properties.putAll(rootProjectProperties) | ||
} | ||
|
||
dependencies { | ||
def version = rootProjectProperties.get("version") | ||
compile "io.reactivex:rxandroid:$version" | ||
} |
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,58 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="rx.android.samples" > | ||
|
||
<application | ||
android:name=".SamplesApplication" | ||
android:allowBackup="true" | ||
android:icon="@drawable/ic_launcher" | ||
android:theme="@style/AppTheme" | ||
android:label="@string/app_name"> | ||
<activity | ||
android:name=".UIBindingActivity"> | ||
|
||
<intent-filter> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
<category android:name="android.intent.category.DEFAULT"/> | ||
<action android:name="android.intent.action.MAIN"/> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".RetainedFragmentActivity"> | ||
|
||
<intent-filter> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
<category android:name="android.intent.category.DEFAULT"/> | ||
<action android:name="android.intent.action.MAIN"/> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".ListeningFragmentActivity"> | ||
|
||
<intent-filter> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
<category android:name="android.intent.category.DEFAULT"/> | ||
<action android:name="android.intent.action.MAIN"/> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".ListFragmentActivity"> | ||
|
||
<intent-filter> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
<category android:name="android.intent.category.DEFAULT"/> | ||
<action android:name="android.intent.action.MAIN"/> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".ListenInOutActivity"> | ||
|
||
<intent-filter> | ||
<category android:name="android.intent.category.LAUNCHER"/> | ||
<category android:name="android.intent.category.DEFAULT"/> | ||
<action android:name="android.intent.action.MAIN"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
75 changes: 75 additions & 0 deletions
75
samples/app/src/main/java/rx/android/samples/ListFragmentActivity.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,75 @@ | ||
package rx.android.samples; | ||
|
||
import android.app.Activity; | ||
import android.app.ListFragment; | ||
import android.os.Bundle; | ||
import android.widget.ArrayAdapter; | ||
|
||
import rx.Observable; | ||
import rx.Subscriber; | ||
|
||
import static rx.android.schedulers.AndroidSchedulers.mainThread; | ||
|
||
/** | ||
* Problem: | ||
* You have an asynchronous sequence that emits items to be displayed in a list. You want the data | ||
* to survive rotation changes. | ||
* <p/> | ||
* Solution: | ||
* Combine {@link android.app.Fragment#setRetainInstance(boolean)} in a ListFragment with | ||
* {@link rx.android.schedulers.AndroidSchedulers#mainThread()} and an {@link rx.Observable.Operator} | ||
* that binds to the list adapter. | ||
*/ | ||
public class ListFragmentActivity extends Activity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setTitle("Lists"); | ||
setContentView(R.layout.list_fragment_activity); | ||
} | ||
|
||
@SuppressWarnings("ConstantConditions") | ||
public static class RetainedListFragment extends ListFragment { | ||
|
||
private ArrayAdapter<String> adapter; | ||
|
||
public RetainedListFragment() { | ||
setRetainInstance(true); | ||
} | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1); | ||
setListAdapter(adapter); | ||
SampleObservables.numberStrings(1, 20, 250) | ||
.observeOn(mainThread()) | ||
.lift(new BindAdapter()) | ||
.subscribe(); | ||
} | ||
|
||
private final class BindAdapter implements Observable.Operator<String, String> { | ||
@Override | ||
public Subscriber<? super String> call(Subscriber<? super String> subscriber) { | ||
return new Subscriber<String>() { | ||
@Override | ||
public void onCompleted() { | ||
adapter.notifyDataSetChanged(); | ||
} | ||
|
||
@Override | ||
public void onError(Throwable throwable) { | ||
|
||
} | ||
|
||
@Override | ||
public void onNext(String strings) { | ||
adapter.add(strings); | ||
} | ||
}; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.