Skip to content

Commit 0893101

Browse files
committed
Merge pull request ReactiveX#66 from omo/reorg
Android-centric package reorganization (ReactiveX#65)
2 parents 769917c + 4a6334d commit 0893101

File tree

50 files changed

+237
-266
lines changed

Some content is hidden

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

50 files changed

+237
-266
lines changed

rxandroid/src/main/java/rx/android/subscriptions/AndroidSubscriptions.java renamed to rxandroid/src/main/java/rx/android/AndroidSubscriptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.subscriptions;
14+
package rx.android;
1515

1616
import rx.Scheduler.Worker;
1717
import rx.Subscription;

rxandroid/src/main/java/rx/android/observables/AndroidObservable.java renamed to rxandroid/src/main/java/rx/android/content/ContentObservable.java

Lines changed: 17 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
/**
2-
* Licensed under the Apache License, Version 2.0 (the "License");
3-
* you may not use this file except in compliance with the License.
4-
* You may obtain a copy of the License at
5-
*
6-
* http://www.apache.org/licenses/LICENSE-2.0
7-
*
8-
* Unless required by applicable law or agreed to in writing, software
9-
* distributed under the License is distributed on an "AS IS" BASIS,
10-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11-
* See the License for the specific language governing permissions and
12-
* limitations under the License.
13-
*/
14-
package rx.android.observables;
1+
package rx.android.content;
152

163
import android.app.Activity;
174
import android.app.Fragment;
@@ -21,47 +8,26 @@
218
import android.content.SharedPreferences;
229
import android.os.Build;
2310
import android.os.Handler;
24-
import android.view.View;
2511

2612
import rx.Observable;
27-
import rx.android.operators.OperatorBroadcastRegister;
28-
import rx.android.operators.OperatorConditionalBinding;
29-
import rx.android.operators.OperatorLocalBroadcastRegister;
30-
import rx.android.operators.OperatorSharedPreferenceChange;
31-
import rx.android.operators.OperatorViewDetachedFromWindowFirst;
13+
import rx.android.internal.Assertions;
3214
import rx.functions.Func1;
3315

3416
import static rx.android.schedulers.AndroidSchedulers.mainThread;
3517

36-
37-
public final class AndroidObservable {
38-
39-
private static final boolean USES_SUPPORT_FRAGMENTS;
40-
41-
static {
42-
boolean supportFragmentsAvailable = false;
43-
try {
44-
Class.forName("android.support.v4.app.Fragment");
45-
supportFragmentsAvailable = true;
46-
} catch (ClassNotFoundException e) {
47-
}
48-
USES_SUPPORT_FRAGMENTS = supportFragmentsAvailable;
49-
}
50-
18+
public final class ContentObservable {
5119
private static final Func1<Activity, Boolean> ACTIVITY_VALIDATOR = new Func1<Activity, Boolean>() {
5220
@Override
5321
public Boolean call(Activity activity) {
5422
return !activity.isFinishing();
5523
}
5624
};
57-
5825
private static final Func1<Fragment, Boolean> FRAGMENT_VALIDATOR = new Func1<Fragment, Boolean>() {
5926
@Override
6027
public Boolean call(Fragment fragment) {
6128
return fragment.isAdded() && !fragment.getActivity().isFinishing();
6229
}
6330
};
64-
6531
private static final Func1<android.support.v4.app.Fragment, Boolean> FRAGMENTV4_VALIDATOR =
6632
new Func1<android.support.v4.app.Fragment, Boolean>() {
6733
@Override
@@ -70,7 +36,17 @@ public Boolean call(android.support.v4.app.Fragment fragment) {
7036
}
7137
};
7238

73-
private AndroidObservable() {
39+
private static final boolean USES_SUPPORT_FRAGMENTS;
40+
41+
static {
42+
boolean supportFragmentsAvailable = false;
43+
try {
44+
Class.forName("android.support.v4.app.Fragment");
45+
supportFragmentsAvailable = true;
46+
} catch (ClassNotFoundException e) {
47+
}
48+
49+
USES_SUPPORT_FRAGMENTS = supportFragmentsAvailable;
7450
}
7551

7652
/**
@@ -120,27 +96,6 @@ public static <T> Observable<T> bindFragment(Object fragment, Observable<T> sour
12096
}
12197
}
12298

123-
/**
124-
* Binds the given source sequence to the view.
125-
* <p>
126-
* This helper will schedule the given sequence to be observed on the main UI thread and ensure
127-
* that no notifications will be forwarded to the view in case it gets detached from its the window.
128-
* <p>
129-
* Unlike {@link #bindActivity} or {@link #bindFragment}, you don't have to unsubscribe the returned {@code Observable}
130-
* on the detachment. {@link #bindView} does it automatically.
131-
* That means that the subscriber doesn't see further sequence even if the view is recycled and
132-
* attached again.
133-
*
134-
* @param view the view to bind the source sequence to
135-
* @param source the source sequence
136-
*/
137-
public static <T> Observable<T> bindView(View view, Observable<T> source) {
138-
if (view == null || source == null)
139-
throw new IllegalArgumentException("View and Observable must be given");
140-
Assertions.assertUiThread();
141-
return source.takeUntil(Observable.create(new OperatorViewDetachedFromWindowFirst(view))).observeOn(mainThread());
142-
}
143-
14499
/**
145100
* Create Observable that wraps BroadcastReceiver and emmit received intents.
146101
*
@@ -182,4 +137,7 @@ public static Observable<Intent> fromLocalBroadcast(Context context, IntentFilte
182137
public static Observable<String> fromSharedPreferencesChanges(SharedPreferences sharedPreferences){
183138
return Observable.create(new OperatorSharedPreferenceChange(sharedPreferences));
184139
}
140+
141+
private ContentObservable() {
142+
}
185143
}

rxandroid/src/main/java/rx/android/operators/OperatorBroadcastRegister.java renamed to rxandroid/src/main/java/rx/android/content/OperatorBroadcastRegister.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.operators;
14+
package rx.android.content;
1515

1616
import android.content.BroadcastReceiver;
1717
import android.content.Context;
@@ -25,7 +25,7 @@
2525
import rx.functions.Action0;
2626
import rx.subscriptions.Subscriptions;
2727

28-
public class OperatorBroadcastRegister implements Observable.OnSubscribe<Intent> {
28+
class OperatorBroadcastRegister implements Observable.OnSubscribe<Intent> {
2929

3030
private final Context context;
3131
private final IntentFilter intentFilter;

rxandroid/src/main/java/rx/android/operators/OperatorConditionalBinding.java renamed to rxandroid/src/main/java/rx/android/content/OperatorConditionalBinding.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.operators;
14+
package rx.android.content;
1515

1616
import rx.Observable;
1717
import rx.Subscriber;
@@ -30,7 +30,7 @@
3030
* @param <T> the type of the objects emitted to a subscriber
3131
* @param <R> the type of the target object to bind to
3232
*/
33-
public final class OperatorConditionalBinding<T, R> implements Observable.Operator<T, T> {
33+
final class OperatorConditionalBinding<T, R> implements Observable.Operator<T, T> {
3434

3535
private static final String LOG_TAG = "ConditionalBinding";
3636

rxandroid/src/main/java/rx/android/operators/OperatorLocalBroadcastRegister.java renamed to rxandroid/src/main/java/rx/android/content/OperatorLocalBroadcastRegister.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.operators;
14+
package rx.android.content;
1515

1616
import android.content.BroadcastReceiver;
1717
import android.content.Context;
@@ -25,7 +25,7 @@
2525
import rx.functions.Action0;
2626
import rx.subscriptions.Subscriptions;
2727

28-
public class OperatorLocalBroadcastRegister implements Observable.OnSubscribe<Intent> {
28+
class OperatorLocalBroadcastRegister implements Observable.OnSubscribe<Intent> {
2929

3030
private final Context context;
3131
private final IntentFilter intentFilter;

rxandroid/src/main/java/rx/android/operators/OperatorSharedPreferenceChange.java renamed to rxandroid/src/main/java/rx/android/content/OperatorSharedPreferenceChange.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.operators;
14+
package rx.android.content;
1515

1616
import android.content.SharedPreferences;
1717
import rx.Observable;
1818
import rx.Subscriber;
1919
import rx.functions.Action0;
2020
import rx.subscriptions.Subscriptions;
2121

22-
public class OperatorSharedPreferenceChange implements Observable.OnSubscribe<String>{
22+
class OperatorSharedPreferenceChange implements Observable.OnSubscribe<String>{
2323

2424
private final SharedPreferences sharedPreferences;
2525

rxandroid/src/main/java/rx/android/observables/Assertions.java renamed to rxandroid/src/main/java/rx/android/internal/Assertions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.observables;
14+
package rx.android.internal;
1515

1616
import android.os.Looper;
1717

rxandroid/src/main/java/rx/android/observables/ViewObservable.java

Lines changed: 0 additions & 73 deletions
This file was deleted.

rxandroid/src/main/java/rx/android/events/OnCheckedChangeEvent.java renamed to rxandroid/src/main/java/rx/android/view/OnCheckedChangeEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.events;
14+
package rx.android.view;
1515

1616
import android.widget.CompoundButton;
1717

rxandroid/src/main/java/rx/android/events/OnClickEvent.java renamed to rxandroid/src/main/java/rx/android/view/OnClickEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.events;
14+
package rx.android.view;
1515

1616
import android.view.View;
1717

rxandroid/src/main/java/rx/android/operators/OperatorViewClick.java renamed to rxandroid/src/main/java/rx/android/view/OperatorViewClick.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,22 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.operators;
14+
package rx.android.view;
1515

1616
import android.view.View;
1717
import rx.Observable;
1818
import rx.Subscriber;
1919
import rx.Subscription;
20-
import rx.android.events.OnClickEvent;
21-
import rx.android.observables.Assertions;
22-
import rx.android.subscriptions.AndroidSubscriptions;
20+
import rx.android.internal.Assertions;
21+
import rx.android.AndroidSubscriptions;
2322
import rx.functions.Action0;
2423

2524
import java.util.ArrayList;
2625
import java.util.List;
2726
import java.util.Map;
2827
import java.util.WeakHashMap;
2928

30-
public final class OperatorViewClick implements Observable.OnSubscribe<OnClickEvent> {
29+
final class OperatorViewClick implements Observable.OnSubscribe<OnClickEvent> {
3130
private final boolean emitInitialValue;
3231
private final View view;
3332

rxandroid/src/main/java/rx/android/operators/OperatorViewDetachedFromWindowFirst.java renamed to rxandroid/src/main/java/rx/android/view/OperatorViewDetachedFromWindowFirst.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.operators;
14+
package rx.android.view;
1515

1616
import android.view.View;
1717

@@ -20,10 +20,10 @@
2020
import rx.Subscription;
2121

2222
/**
23-
* An internal class that is used from #{@link rx.android.observables.AndroidObservable#bindView}.
23+
* An internal class that is used from #{@link ViewObservable#bindView}.
2424
* This emits an event when the given #{@code View} is detached from the window for the first time.
2525
*/
26-
public class OperatorViewDetachedFromWindowFirst implements Observable.OnSubscribe<View> {
26+
final class OperatorViewDetachedFromWindowFirst implements Observable.OnSubscribe<View> {
2727
private final View view;
2828

2929
public OperatorViewDetachedFromWindowFirst(View view) {

rxandroid/src/main/java/rx/android/functions/ViewAction1.java renamed to rxandroid/src/main/java/rx/android/view/ViewAction1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.functions;
14+
package rx.android.view;
1515

1616
import android.view.View;
1717

rxandroid/src/main/java/rx/android/functions/ViewActionSetActivated.java renamed to rxandroid/src/main/java/rx/android/view/ViewActionSetActivated.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.functions;
14+
package rx.android.view;
1515

1616
import android.view.View;
1717

rxandroid/src/main/java/rx/android/functions/ViewActionSetClickable.java renamed to rxandroid/src/main/java/rx/android/view/ViewActionSetClickable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.functions;
14+
package rx.android.view;
1515

1616
import android.view.View;
1717

rxandroid/src/main/java/rx/android/functions/ViewActionSetEnabled.java renamed to rxandroid/src/main/java/rx/android/view/ViewActionSetEnabled.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* See the License for the specific language governing permissions and
1212
* limitations under the License.
1313
*/
14-
package rx.android.functions;
14+
package rx.android.view;
1515

1616
import android.view.View;
1717

0 commit comments

Comments
 (0)