com.trello.rxlifecycle2.android.RxLifecycleAndroid Java Examples

The following examples show how to use com.trello.rxlifecycle2.android.RxLifecycleAndroid. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExampleLifecycleActivity.java    From Reactive-Android-Programming with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mock);
    ButterKnife.bind(this);

    Observable.interval(1, TimeUnit.SECONDS)
            .doOnDispose(() -> Log.i("APP", "Disposed"))
            .compose(bindToLifecycle())
            .subscribe();

    Observable.interval(1, TimeUnit.SECONDS)
            .compose(RxLifecycleAndroid.bindActivity(lifecycle()))
            .subscribe();

    Observable.interval(1, TimeUnit.SECONDS)
            .compose(RxLifecycleAndroid.bindView(textView))
            .subscribe();
}
 
Example #2
Source File: RxLifecycleUtils.java    From Aurora with Apache License 2.0 5 votes vote down vote up
public static <T> LifecycleTransformer<T> bindToLifecycle(@NonNull Lifecycleable lifecycleable) {
    Preconditions.checkNotNull(lifecycleable, "lifecycleable == null");
    if (lifecycleable instanceof ActivityLifecycleable) {
        return RxLifecycleAndroid.bindActivity(((ActivityLifecycleable) lifecycleable).provideLifecycleSubject());
    } else if (lifecycleable instanceof FragmentLifecycleable) {
        return RxLifecycleAndroid.bindFragment(((FragmentLifecycleable) lifecycleable).provideLifecycleSubject());
    } else {
        throw new IllegalArgumentException("Lifecycleable not match");
    }
}
 
Example #3
Source File: RxLifecycleUtils.java    From MVPArms with Apache License 2.0 5 votes vote down vote up
public static <T> LifecycleTransformer<T> bindToLifecycle(@NonNull Lifecycleable lifecycleable) {
    Preconditions.checkNotNull(lifecycleable, "lifecycleable == null");
    if (lifecycleable instanceof ActivityLifecycleable) {
        return RxLifecycleAndroid.bindActivity(((ActivityLifecycleable) lifecycleable).provideLifecycleSubject());
    } else if (lifecycleable instanceof FragmentLifecycleable) {
        return RxLifecycleAndroid.bindFragment(((FragmentLifecycleable) lifecycleable).provideLifecycleSubject());
    } else {
        throw new IllegalArgumentException("Lifecycleable not match");
    }
}
 
Example #4
Source File: BaseActivity.java    From QuickDevFramework with Apache License 2.0 4 votes vote down vote up
@Override
@NonNull
@CheckResult
public final <T> LifecycleTransformer<T> bindToLifecycle() {
    return RxLifecycleAndroid.bindActivity(lifecycleSubject);
}
 
Example #5
Source File: BaseDialogFragment.java    From QuickDevFramework with Apache License 2.0 4 votes vote down vote up
@Override
@NonNull
@CheckResult
public final <T> LifecycleTransformer<T> bindToLifecycle() {
    return RxLifecycleAndroid.bindFragment(lifecycleSubject);
}
 
Example #6
Source File: BaseFragment.java    From QuickDevFramework with Apache License 2.0 4 votes vote down vote up
@Override
@NonNull
@CheckResult
public final <T> LifecycleTransformer<T> bindToLifecycle() {
    return RxLifecycleAndroid.bindFragment(lifecycleSubject);
}
 
Example #7
Source File: SuperFragment.java    From AndroidBase with Apache License 2.0 4 votes vote down vote up
@Override
@NonNull
@CheckResult
public final <T> LifecycleTransformer<T> bindToLifecycle() {
    return RxLifecycleAndroid.bindFragment(mLifecycleSubject);
}
 
Example #8
Source File: SuperActivity.java    From AndroidBase with Apache License 2.0 4 votes vote down vote up
@Override
@NonNull
@CheckResult
public final <T> LifecycleTransformer<T> bindToLifecycle() {
    return RxLifecycleAndroid.bindActivity(mLifecycleSubject);
}
 
Example #9
Source File: RxLifecycleProvider.java    From NGA-CLIENT-VER-OPEN-SOURCE with GNU General Public License v2.0 4 votes vote down vote up
@NonNull
@CheckResult
public final <T> LifecycleTransformer<T> bindToLifecycle() {
    return RxLifecycleAndroid.bindFragment(mLifecycleSubject);
}