Skip to content

Commit

Permalink
Merge pull request #43 from ReactiveX/submodules
Browse files Browse the repository at this point in the history
New project structure based on submodules (added samples module)
  • Loading branch information
mttkay committed Nov 11, 2014
2 parents 7079fae + af9f75a commit 7e4b433
Show file tree
Hide file tree
Showing 87 changed files with 1,195 additions and 53 deletions.
10 changes: 0 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so

# Packages #
############
Expand All @@ -15,7 +10,6 @@
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
Expand Down Expand Up @@ -66,10 +60,6 @@ bin/
/.nb-gradle/profiles/private/
.nb-gradle-properties

# Scala build
*.cache
/.nb-gradle/private/

# Android
local.properties

Expand Down
8 changes: 7 additions & 1 deletion .travis.yml
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"
24 changes: 0 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,3 @@ buildscript {
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:1.12.+'
}
}

apply plugin: 'rxjava-project'
apply plugin: 'provided-base'

dependencies {
compile 'io.reactivex:rxjava:1.0.+'
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
}
}
3 changes: 2 additions & 1 deletion gradle.properties
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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Thu Sep 18 17:51:34 CEST 2014
#Wed Oct 22 12:19:29 CEST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
31 changes: 31 additions & 0 deletions library/build.gradle
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

import android.view.View;

import rx.functions.Action1;

import java.lang.ref.WeakReference;

import rx.functions.Action1;

/**
* An {@link Action1} implementation specific for {@link View}s.
*
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;

import rx.subjects.PublishSubject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;

import rx.subjects.PublishSubject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;

import rx.subjects.PublishSubject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@
*/
package rx.android.schedulers;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.concurrent.TimeUnit;
import android.os.Handler;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -31,14 +23,21 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import java.util.concurrent.TimeUnit;

import rx.Observable;
import rx.Scheduler;
import rx.Scheduler.Worker;
import rx.Subscriber;
import rx.Subscription;
import rx.functions.Action0;
import rx.functions.Action1;
import android.os.Handler;

import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@RunWith(RobolectricTestRunner.class)
@Config(manifest=Config.NONE)
Expand Down
14 changes: 14 additions & 0 deletions samples-build-wrapper/build.gradle
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"
}
}
30 changes: 30 additions & 0 deletions samples/app/build.gradle
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"
}
58 changes: 58 additions & 0 deletions samples/app/src/main/AndroidManifest.xml
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>
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);
}
};
}
}
}
}
Loading

0 comments on commit 7e4b433

Please sign in to comment.