Compare commits
19 Commits
master-kot
...
master
| Author | SHA1 | Date |
|---|---|---|
|
|
e6dd2c5bcd | |
|
|
13441b3563 | |
|
|
2f0799ae21 | |
|
|
096a2643a0 | |
|
|
8a892136f0 | |
|
|
31973bf99e | |
|
|
7bd7137b82 | |
|
|
848e4ec287 | |
|
|
38358cf999 | |
|
|
e33827ee36 | |
|
|
b1103f61d8 | |
|
|
ef733a5d87 | |
|
|
795c3b698a | |
|
|
cb919c65b1 | |
|
|
77957b2346 | |
|
|
78786250d3 | |
|
|
89dff2e1f5 | |
|
|
93142fdae1 | |
|
|
379e0f0cad |
|
|
@ -17,9 +17,8 @@ dependencies {
|
||||||
api project(':libraries:core')
|
api project(':libraries:core')
|
||||||
|
|
||||||
compileOnly "com.android.support:appcompat-v7:$supportLibraryVersion"
|
compileOnly "com.android.support:appcompat-v7:$supportLibraryVersion"
|
||||||
compileOnly "com.android.support:design:$supportLibraryVersion"
|
|
||||||
compileOnly "com.android.support:recyclerview-v7:$supportLibraryVersion"
|
compileOnly "com.android.support:recyclerview-v7:$supportLibraryVersion"
|
||||||
|
|
||||||
compileOnly "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
|
compileOnly "io.reactivex:rxandroid:$rxAndroidVersion"
|
||||||
compileOnly "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
|
compileOnly "io.reactivex:rxjava:$rxJavaVersion"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,14 @@ package ru.touchin.roboswag.components.adapters;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import io.reactivex.Completable;
|
|
||||||
import io.reactivex.Maybe;
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.Single;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
import io.reactivex.functions.Action;
|
|
||||||
import io.reactivex.functions.Consumer;
|
|
||||||
import ru.touchin.roboswag.components.utils.LifecycleBindable;
|
import ru.touchin.roboswag.components.utils.LifecycleBindable;
|
||||||
import ru.touchin.roboswag.components.utils.UiUtils;
|
import ru.touchin.roboswag.components.utils.UiUtils;
|
||||||
|
import rx.Completable;
|
||||||
|
import rx.Observable;
|
||||||
|
import rx.Single;
|
||||||
|
import rx.Subscription;
|
||||||
|
import rx.functions.Action0;
|
||||||
|
import rx.functions.Action1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Objects of such class controls creation and binding of specific type of RecyclerView's ViewHolders.
|
* Objects of such class controls creation and binding of specific type of RecyclerView's ViewHolders.
|
||||||
|
|
@ -83,180 +82,140 @@ public abstract class AdapterDelegate<TViewHolder extends BindableViewHolder> im
|
||||||
//CPD: it is same as in other implementation based on BaseLifecycleBindable
|
//CPD: it is same as in other implementation based on BaseLifecycleBindable
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable) {
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable) {
|
||||||
return parentLifecycleBindable.untilStop(observable);
|
return parentLifecycleBindable.untilStop(observable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable, @NonNull final Consumer<T> onNextAction) {
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable, @NonNull final Action1<T> onNextAction) {
|
||||||
return parentLifecycleBindable.untilStop(observable, onNextAction);
|
return parentLifecycleBindable.untilStop(observable, onNextAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable,
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return parentLifecycleBindable.untilStop(observable, onNextAction, onErrorAction);
|
return parentLifecycleBindable.untilStop(observable, onNextAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable,
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction,
|
@NonNull final Action1<Throwable> onErrorAction,
|
||||||
@NonNull final Action onCompletedAction) {
|
@NonNull final Action0 onCompletedAction) {
|
||||||
return parentLifecycleBindable.untilStop(observable, onNextAction, onErrorAction, onCompletedAction);
|
return parentLifecycleBindable.untilStop(observable, onNextAction, onErrorAction, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single) {
|
public <T> Subscription untilStop(@NonNull final Single<T> single) {
|
||||||
return parentLifecycleBindable.untilStop(single);
|
return parentLifecycleBindable.untilStop(single);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilStop(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||||
return parentLifecycleBindable.untilStop(single, onSuccessAction);
|
return parentLifecycleBindable.untilStop(single, onSuccessAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single,
|
public <T> Subscription untilStop(@NonNull final Single<T> single,
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
@NonNull final Action1<T> onSuccessAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return parentLifecycleBindable.untilStop(single, onSuccessAction, onErrorAction);
|
return parentLifecycleBindable.untilStop(single, onSuccessAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable) {
|
public Subscription untilStop(@NonNull final Completable completable) {
|
||||||
return parentLifecycleBindable.untilStop(completable);
|
return parentLifecycleBindable.untilStop(completable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable, @NonNull final Action onCompletedAction) {
|
public Subscription untilStop(@NonNull final Completable completable, @NonNull final Action0 onCompletedAction) {
|
||||||
return parentLifecycleBindable.untilStop(completable, onCompletedAction);
|
return parentLifecycleBindable.untilStop(completable, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable,
|
public Subscription untilStop(@NonNull final Completable completable,
|
||||||
@NonNull final Action onCompletedAction,
|
@NonNull final Action0 onCompletedAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return parentLifecycleBindable.untilStop(completable, onCompletedAction, onErrorAction);
|
return parentLifecycleBindable.untilStop(completable, onCompletedAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe) {
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable) {
|
||||||
return parentLifecycleBindable.untilStop(maybe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe, @NonNull final Consumer<T> onSuccessAction) {
|
|
||||||
return parentLifecycleBindable.untilStop(maybe, onSuccessAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe,
|
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
|
||||||
return parentLifecycleBindable.untilStop(maybe, onSuccessAction, onErrorAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable) {
|
|
||||||
return parentLifecycleBindable.untilDestroy(observable);
|
return parentLifecycleBindable.untilDestroy(observable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable, @NonNull final Consumer<T> onNextAction) {
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable, @NonNull final Action1<T> onNextAction) {
|
||||||
return parentLifecycleBindable.untilDestroy(observable, onNextAction);
|
return parentLifecycleBindable.untilDestroy(observable, onNextAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable,
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return parentLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction);
|
return parentLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable,
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction,
|
@NonNull final Action1<Throwable> onErrorAction,
|
||||||
@NonNull final Action onCompletedAction) {
|
@NonNull final Action0 onCompletedAction) {
|
||||||
return parentLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction, onCompletedAction);
|
return parentLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single) {
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single) {
|
||||||
return parentLifecycleBindable.untilDestroy(single);
|
return parentLifecycleBindable.untilDestroy(single);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||||
return parentLifecycleBindable.untilDestroy(single, onSuccessAction);
|
return parentLifecycleBindable.untilDestroy(single, onSuccessAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single,
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single,
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
@NonNull final Action1<T> onSuccessAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return parentLifecycleBindable.untilDestroy(single, onSuccessAction, onErrorAction);
|
return parentLifecycleBindable.untilDestroy(single, onSuccessAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable) {
|
public Subscription untilDestroy(@NonNull final Completable completable) {
|
||||||
return parentLifecycleBindable.untilDestroy(completable);
|
return parentLifecycleBindable.untilDestroy(completable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable, @NonNull final Action onCompletedAction) {
|
public Subscription untilDestroy(@NonNull final Completable completable, @NonNull final Action0 onCompletedAction) {
|
||||||
return parentLifecycleBindable.untilDestroy(completable, onCompletedAction);
|
return parentLifecycleBindable.untilDestroy(completable, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable,
|
public Subscription untilDestroy(@NonNull final Completable completable,
|
||||||
@NonNull final Action onCompletedAction,
|
@NonNull final Action0 onCompletedAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return parentLifecycleBindable.untilDestroy(completable, onCompletedAction, onErrorAction);
|
return parentLifecycleBindable.untilDestroy(completable, onCompletedAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe) {
|
|
||||||
return parentLifecycleBindable.untilDestroy(maybe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe, @NonNull final Consumer<T> onSuccessAction) {
|
|
||||||
return parentLifecycleBindable.untilDestroy(maybe, onSuccessAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe,
|
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
|
||||||
return parentLifecycleBindable.untilDestroy(maybe, onSuccessAction, onErrorAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,14 @@ import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import io.reactivex.Completable;
|
|
||||||
import io.reactivex.Maybe;
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.Single;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
import io.reactivex.functions.Action;
|
|
||||||
import io.reactivex.functions.Consumer;
|
|
||||||
import ru.touchin.roboswag.components.utils.LifecycleBindable;
|
import ru.touchin.roboswag.components.utils.LifecycleBindable;
|
||||||
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
||||||
|
import rx.Completable;
|
||||||
|
import rx.Observable;
|
||||||
|
import rx.Single;
|
||||||
|
import rx.Subscription;
|
||||||
|
import rx.functions.Action0;
|
||||||
|
import rx.functions.Action1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 12/8/2016.
|
* Created by Gavriil Sitnikov on 12/8/2016.
|
||||||
|
|
@ -123,185 +122,142 @@ public class BindableViewHolder extends RecyclerView.ViewHolder implements Lifec
|
||||||
return ContextCompat.getDrawable(itemView.getContext(), resId);
|
return ContextCompat.getDrawable(itemView.getContext(), resId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("CPD-START")
|
|
||||||
//CPD: it's ok as it's LifecycleBindable
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable) {
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable) {
|
||||||
return baseLifecycleBindable.untilStop(observable);
|
return baseLifecycleBindable.untilStop(observable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable, @NonNull final Consumer<T> onNextAction) {
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable, @NonNull final Action1<T> onNextAction) {
|
||||||
return baseLifecycleBindable.untilStop(observable, onNextAction);
|
return baseLifecycleBindable.untilStop(observable, onNextAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable,
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction);
|
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable,
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction,
|
@NonNull final Action1<Throwable> onErrorAction,
|
||||||
@NonNull final Action onCompletedAction) {
|
@NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction, onCompletedAction);
|
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single) {
|
public <T> Subscription untilStop(@NonNull final Single<T> single) {
|
||||||
return baseLifecycleBindable.untilStop(single);
|
return baseLifecycleBindable.untilStop(single);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilStop(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||||
return baseLifecycleBindable.untilStop(single, onSuccessAction);
|
return baseLifecycleBindable.untilStop(single, onSuccessAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single,
|
public <T> Subscription untilStop(@NonNull final Single<T> single,
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
@NonNull final Action1<T> onSuccessAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilStop(single, onSuccessAction, onErrorAction);
|
return baseLifecycleBindable.untilStop(single, onSuccessAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable) {
|
public Subscription untilStop(@NonNull final Completable completable) {
|
||||||
return baseLifecycleBindable.untilStop(completable);
|
return baseLifecycleBindable.untilStop(completable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable, @NonNull final Action onCompletedAction) {
|
public Subscription untilStop(@NonNull final Completable completable, @NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilStop(completable, onCompletedAction);
|
return baseLifecycleBindable.untilStop(completable, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable,
|
public Subscription untilStop(@NonNull final Completable completable,
|
||||||
@NonNull final Action onCompletedAction,
|
@NonNull final Action0 onCompletedAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilStop(completable, onCompletedAction, onErrorAction);
|
return baseLifecycleBindable.untilStop(completable, onCompletedAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe) {
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable) {
|
||||||
return baseLifecycleBindable.untilStop(maybe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe, @NonNull final Consumer<T> onSuccessAction) {
|
|
||||||
return baseLifecycleBindable.untilStop(maybe, onSuccessAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe,
|
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
|
||||||
return baseLifecycleBindable.untilStop(maybe, onSuccessAction, onErrorAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(observable);
|
return baseLifecycleBindable.untilDestroy(observable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable, @NonNull final Consumer<T> onNextAction) {
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable, @NonNull final Action1<T> onNextAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(observable, onNextAction);
|
return baseLifecycleBindable.untilDestroy(observable, onNextAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable,
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction);
|
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable,
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction,
|
@NonNull final Action1<Throwable> onErrorAction,
|
||||||
@NonNull final Action onCompletedAction) {
|
@NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction, onCompletedAction);
|
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single) {
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single) {
|
||||||
return baseLifecycleBindable.untilDestroy(single);
|
return baseLifecycleBindable.untilDestroy(single);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(single, onSuccessAction);
|
return baseLifecycleBindable.untilDestroy(single, onSuccessAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single,
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single,
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
@NonNull final Action1<T> onSuccessAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(single, onSuccessAction, onErrorAction);
|
return baseLifecycleBindable.untilDestroy(single, onSuccessAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable) {
|
public Subscription untilDestroy(@NonNull final Completable completable) {
|
||||||
return baseLifecycleBindable.untilDestroy(completable);
|
return baseLifecycleBindable.untilDestroy(completable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable, @NonNull final Action onCompletedAction) {
|
public Subscription untilDestroy(@NonNull final Completable completable, @NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction);
|
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable,
|
public Subscription untilDestroy(@NonNull final Completable completable,
|
||||||
@NonNull final Action onCompletedAction,
|
@NonNull final Action0 onCompletedAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction, onErrorAction);
|
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(maybe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe, @NonNull final Consumer<T> onSuccessAction) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(maybe, onSuccessAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("CPD-END")
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe,
|
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(maybe, onSuccessAction, onErrorAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,6 @@ import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.functions.BiConsumer;
|
|
||||||
import io.reactivex.functions.Consumer;
|
|
||||||
import io.reactivex.subjects.BehaviorSubject;
|
|
||||||
import ru.touchin.roboswag.components.utils.LifecycleBindable;
|
import ru.touchin.roboswag.components.utils.LifecycleBindable;
|
||||||
import ru.touchin.roboswag.components.utils.UiUtils;
|
import ru.touchin.roboswag.components.utils.UiUtils;
|
||||||
import ru.touchin.roboswag.core.log.Lc;
|
import ru.touchin.roboswag.core.log.Lc;
|
||||||
|
|
@ -47,6 +43,11 @@ import ru.touchin.roboswag.core.observables.collections.changes.SameItemsPredica
|
||||||
import ru.touchin.roboswag.core.observables.collections.loadable.LoadingMoreList;
|
import ru.touchin.roboswag.core.observables.collections.loadable.LoadingMoreList;
|
||||||
import ru.touchin.roboswag.core.utils.Optional;
|
import ru.touchin.roboswag.core.utils.Optional;
|
||||||
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
||||||
|
import rx.Observable;
|
||||||
|
import rx.functions.Action1;
|
||||||
|
import rx.functions.Action2;
|
||||||
|
import rx.functions.Action3;
|
||||||
|
import rx.subjects.BehaviorSubject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 20/11/2015.
|
* Created by Gavriil Sitnikov on 20/11/2015.
|
||||||
|
|
@ -78,7 +79,7 @@ public abstract class ObservableCollectionAdapter<TItem, TItemViewHolder extends
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final BehaviorSubject<Optional<ObservableCollection<TItem>>> observableCollectionSubject
|
private final BehaviorSubject<Optional<ObservableCollection<TItem>>> observableCollectionSubject
|
||||||
= BehaviorSubject.createDefault(new Optional<>(null));
|
= BehaviorSubject.create(new Optional<>(null));
|
||||||
@NonNull
|
@NonNull
|
||||||
private final BehaviorSubject<Boolean> moreAutoLoadingRequested = BehaviorSubject.create();
|
private final BehaviorSubject<Boolean> moreAutoLoadingRequested = BehaviorSubject.create();
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
@ -130,9 +131,8 @@ public abstract class ObservableCollectionAdapter<TItem, TItemViewHolder extends
|
||||||
final int size = collection.size();
|
final int size = collection.size();
|
||||||
return ((LoadingMoreList<?, ?, ?>) collection)
|
return ((LoadingMoreList<?, ?, ?>) collection)
|
||||||
.loadRange(size, size + PRE_LOADING_COUNT)
|
.loadRange(size, size + PRE_LOADING_COUNT)
|
||||||
.onErrorReturnItem(new ArrayList<>())
|
.onErrorResumeNext(Observable.empty())
|
||||||
.toObservable()
|
.doOnCompleted(() -> moreAutoLoadingRequested.onNext(false));
|
||||||
.doOnComplete(() -> moreAutoLoadingRequested.onNext(false));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -391,49 +391,36 @@ public abstract class ObservableCollectionAdapter<TItem, TItemViewHolder extends
|
||||||
public long getItemId(final int positionInAdapter) {
|
public long getItemId(final int positionInAdapter) {
|
||||||
final LongContainer result = new LongContainer();
|
final LongContainer result = new LongContainer();
|
||||||
tryDelegateAction(positionInAdapter,
|
tryDelegateAction(positionInAdapter,
|
||||||
(itemAdapterDelegate, positionInCollection) ->
|
(itemAdapterDelegate, item, positionInCollection) ->
|
||||||
result.value = itemAdapterDelegate.getItemId(innerCollection.get(positionInCollection),
|
result.value = itemAdapterDelegate.getItemId(item, positionInAdapter, positionInCollection),
|
||||||
positionInAdapter, positionInCollection),
|
|
||||||
positionAdapterDelegate -> result.value = positionAdapterDelegate.getItemId(positionInAdapter),
|
positionAdapterDelegate -> result.value = positionAdapterDelegate.getItemId(positionInAdapter),
|
||||||
(positionInCollection) -> result.value = super.getItemId(positionInAdapter));
|
(item, positionInCollection) -> result.value = super.getItemId(positionInAdapter));
|
||||||
return result.value;
|
return result.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("PMD.CyclomaticComplexity")
|
|
||||||
private void tryDelegateAction(final int positionInAdapter,
|
private void tryDelegateAction(final int positionInAdapter,
|
||||||
@NonNull final BiConsumer<ItemAdapterDelegate, Integer> itemAdapterDelegateAction,
|
@NonNull final Action3<ItemAdapterDelegate, TItem, Integer> itemAdapterDelegateAction,
|
||||||
@NonNull final Consumer<PositionAdapterDelegate> positionAdapterDelegateAction,
|
@NonNull final Action1<PositionAdapterDelegate> positionAdapterDelegateAction,
|
||||||
@NonNull final Consumer<Integer> defaultAction) {
|
@NonNull final Action2<TItem, Integer> defaultAction) {
|
||||||
final int viewType = getItemViewType(positionInAdapter);
|
final int viewType = getItemViewType(positionInAdapter);
|
||||||
final int positionInCollection = getItemPositionInCollection(positionInAdapter);
|
final int positionInCollection = getItemPositionInCollection(positionInAdapter);
|
||||||
|
final TItem item = positionInCollection >= 0 ? innerCollection.get(positionInCollection) : null;
|
||||||
for (final AdapterDelegate<?> delegate : delegates) {
|
for (final AdapterDelegate<?> delegate : delegates) {
|
||||||
if (delegate instanceof ItemAdapterDelegate) {
|
if (delegate instanceof ItemAdapterDelegate) {
|
||||||
if (positionInCollection >= 0 && viewType == delegate.getItemViewType()) {
|
if (item != null && viewType == delegate.getItemViewType()) {
|
||||||
try {
|
itemAdapterDelegateAction.call((ItemAdapterDelegate) delegate, item, positionInCollection);
|
||||||
itemAdapterDelegateAction.accept((ItemAdapterDelegate) delegate, positionInCollection);
|
|
||||||
} catch (final Exception exception) {
|
|
||||||
Lc.assertion(exception);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (delegate instanceof PositionAdapterDelegate) {
|
} else if (delegate instanceof PositionAdapterDelegate) {
|
||||||
if (viewType == delegate.getItemViewType()) {
|
if (viewType == delegate.getItemViewType()) {
|
||||||
try {
|
positionAdapterDelegateAction.call((PositionAdapterDelegate) delegate);
|
||||||
positionAdapterDelegateAction.accept((PositionAdapterDelegate) delegate);
|
|
||||||
} catch (final Exception exception) {
|
|
||||||
Lc.assertion(exception);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Lc.assertion("Delegate of type " + delegate.getClass());
|
Lc.assertion("Delegate of type " + delegate.getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
defaultAction.call(item, positionInCollection);
|
||||||
defaultAction.accept(positionInCollection);
|
|
||||||
} catch (final Exception exception) {
|
|
||||||
Lc.assertion(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -457,15 +444,14 @@ public abstract class ObservableCollectionAdapter<TItem, TItemViewHolder extends
|
||||||
lastUpdatedChangeNumber = innerCollection.getChangesCount();
|
lastUpdatedChangeNumber = innerCollection.getChangesCount();
|
||||||
|
|
||||||
tryDelegateAction(positionInAdapter,
|
tryDelegateAction(positionInAdapter,
|
||||||
(itemAdapterDelegate, positionInCollection) -> {
|
(itemAdapterDelegate, item, positionInCollection) -> {
|
||||||
bindItemViewHolder(itemAdapterDelegate, holder, innerCollection.get(positionInCollection),
|
bindItemViewHolder(itemAdapterDelegate, holder, item, null, positionInAdapter, positionInCollection);
|
||||||
null, positionInAdapter, positionInCollection);
|
|
||||||
updateMoreAutoLoadingRequest(positionInCollection);
|
updateMoreAutoLoadingRequest(positionInCollection);
|
||||||
},
|
},
|
||||||
positionAdapterDelegate -> positionAdapterDelegate.onBindViewHolder(holder, positionInAdapter),
|
positionAdapterDelegate -> positionAdapterDelegate.onBindViewHolder(holder, positionInAdapter),
|
||||||
(positionInCollection) -> {
|
(item, positionInCollection) -> {
|
||||||
if (positionInCollection >= 0) {
|
if (item != null) {
|
||||||
bindItemViewHolder(null, holder, innerCollection.get(positionInCollection), null, positionInAdapter, positionInCollection);
|
bindItemViewHolder(null, holder, item, null, positionInAdapter, positionInCollection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -474,16 +460,14 @@ public abstract class ObservableCollectionAdapter<TItem, TItemViewHolder extends
|
||||||
public void onBindViewHolder(@NonNull final BindableViewHolder holder, final int positionInAdapter, @NonNull final List<Object> payloads) {
|
public void onBindViewHolder(@NonNull final BindableViewHolder holder, final int positionInAdapter, @NonNull final List<Object> payloads) {
|
||||||
super.onBindViewHolder(holder, positionInAdapter, payloads);
|
super.onBindViewHolder(holder, positionInAdapter, payloads);
|
||||||
tryDelegateAction(positionInAdapter,
|
tryDelegateAction(positionInAdapter,
|
||||||
(itemAdapterDelegate, positionInCollection) -> {
|
(itemAdapterDelegate, item, positionInCollection) -> {
|
||||||
bindItemViewHolder(itemAdapterDelegate, holder, innerCollection.get(positionInCollection),
|
bindItemViewHolder(itemAdapterDelegate, holder, item, payloads, positionInAdapter, positionInCollection);
|
||||||
payloads, positionInAdapter, positionInCollection);
|
|
||||||
updateMoreAutoLoadingRequest(positionInCollection);
|
updateMoreAutoLoadingRequest(positionInCollection);
|
||||||
},
|
},
|
||||||
positionAdapterDelegate -> positionAdapterDelegate.onBindViewHolder(holder, positionInAdapter),
|
positionAdapterDelegate -> positionAdapterDelegate.onBindViewHolder(holder, positionInAdapter),
|
||||||
(positionInCollection) -> {
|
(item, positionInCollection) -> {
|
||||||
if (positionInCollection >= 0) {
|
if (item != null) {
|
||||||
bindItemViewHolder(null, holder, innerCollection.get(positionInCollection),
|
bindItemViewHolder(null, holder, item, payloads, positionInAdapter, positionInCollection);
|
||||||
payloads, positionInAdapter, positionInCollection);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015 RoboSwag (Gavriil Sitnikov, Vsevolod Ivanov)
|
||||||
|
*
|
||||||
|
* This file is part of RoboSwag library.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ru.touchin.roboswag.components.deeplinks;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import ru.touchin.roboswag.components.navigation.activities.BaseActivity;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller that helps to manage deep links in activity.
|
||||||
|
* It helps to save and restore deep link and deletes deep link info from intent.
|
||||||
|
* As tin he base class - call methods that starts with 'on' prefix from activity.
|
||||||
|
*
|
||||||
|
* @see #onActivityRestoreInstanceState(Bundle)
|
||||||
|
* @see #onActivitySavedInstanceState(Bundle)
|
||||||
|
*/
|
||||||
|
public abstract class ActivityDeepLinkController<TActivity extends BaseActivity> extends DeepLinkController<TActivity> {
|
||||||
|
|
||||||
|
private static final String DEEP_LINK_EXTRA = "DEEP_LINK_EXTRA";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this method on restore instance state -
|
||||||
|
* in {@link Activity#onCreate(Bundle)} or in {@link Activity#onRestoreInstanceState(Bundle)}.
|
||||||
|
*
|
||||||
|
* @param savedInstanceState - activity's savedInstanceState.
|
||||||
|
*/
|
||||||
|
public void onActivityRestoreInstanceState(@NonNull final Bundle savedInstanceState) {
|
||||||
|
final String deepLinkUrl = savedInstanceState.getString(DEEP_LINK_EXTRA, null);
|
||||||
|
onNewDeepLink(deepLinkUrl == null ? null : Uri.parse(deepLinkUrl));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this method while saving stat of activity - in {@link Activity#onSaveInstanceState(Bundle)}.
|
||||||
|
*
|
||||||
|
* @param stateToSave - activity's stateToSave.
|
||||||
|
*/
|
||||||
|
public void onActivitySavedInstanceState(@NonNull final Bundle stateToSave) {
|
||||||
|
if (getDeepLinkUri() != null) {
|
||||||
|
stateToSave.putString(DEEP_LINK_EXTRA, getDeepLinkUri().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helps to delete info about deep link from activity's intent and from this controller.
|
||||||
|
* Call this after successful deep link processing.
|
||||||
|
*
|
||||||
|
* @param activity - that should delete info about processed deep link.
|
||||||
|
*/
|
||||||
|
protected void deleteDeepLink(@NonNull final TActivity activity) {
|
||||||
|
onNewDeepLink(null);
|
||||||
|
activity.getIntent().setData(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015 RoboSwag (Gavriil Sitnikov, Vsevolod Ivanov)
|
||||||
|
*
|
||||||
|
* This file is part of RoboSwag library.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ru.touchin.roboswag.components.deeplinks;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import ru.touchin.roboswag.components.navigation.activities.BaseActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Ilia Kurtov on 04.08.2015.
|
||||||
|
* Class that helps to operate with deep links.
|
||||||
|
*
|
||||||
|
* @param <TActivity> Type of Activity to process deep links.
|
||||||
|
*/
|
||||||
|
public interface DeepLink<TActivity extends BaseActivity> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by deep link to provide unique name.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by deep link to decide - whenever deep link should process uri or if we are already on that screen that deep link links to.
|
||||||
|
*/
|
||||||
|
boolean isOnSuchScreen(@NonNull TActivity activity, @NonNull Uri deepLinkUri);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by deep link to navigate to the specific screen.
|
||||||
|
*/
|
||||||
|
void navigateTo(@NonNull TActivity activity, @NonNull Uri deepLinkUri);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,123 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015 RoboSwag (Gavriil Sitnikov, Vsevolod Ivanov)
|
||||||
|
*
|
||||||
|
* This file is part of RoboSwag library.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ru.touchin.roboswag.components.deeplinks;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
import ru.touchin.roboswag.components.navigation.activities.BaseActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Ilia Kurtov on 04.08.2015.
|
||||||
|
* Controller for deep links. Its main goal to decide when deep link should be processed.
|
||||||
|
* Call methods that starts with 'on' prefix from {@link TActivity} that should process deep links.
|
||||||
|
*
|
||||||
|
* @param <TActivity> Type of Activity to process deep links.
|
||||||
|
* @see #onNewDeepLink(Uri)
|
||||||
|
* @see #onActivityReadyToProcessDeepLink(BaseActivity)
|
||||||
|
* @see #onActivityStopBeingReady()
|
||||||
|
*/
|
||||||
|
|
||||||
|
public abstract class DeepLinkController<TActivity extends BaseActivity> {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private Uri deepLinkUri;
|
||||||
|
@Nullable
|
||||||
|
private TActivity activity;
|
||||||
|
private boolean allowDeepLinkToProcess = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current deep link.
|
||||||
|
*
|
||||||
|
* @return - current deep link
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
protected Uri getDeepLinkUri() {
|
||||||
|
return deepLinkUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this method after receiving new deep link {@link Uri} from your activity.
|
||||||
|
* It saves new deepLinkUri and tries to process deep link if possible.
|
||||||
|
* In most common cases call this method in {@link Activity#onCreate(Bundle)}
|
||||||
|
* if bundle == null or if you want to restore deep link
|
||||||
|
* in {@link Activity#onCreate(Bundle)} or in {@link Activity#onRestoreInstanceState(Bundle)}
|
||||||
|
* methods.
|
||||||
|
*
|
||||||
|
* @param deepLinkUri - received deep link.
|
||||||
|
*/
|
||||||
|
public void onNewDeepLink(@Nullable final Uri deepLinkUri) {
|
||||||
|
this.deepLinkUri = deepLinkUri;
|
||||||
|
startToProcessDeepLinkIfPossible();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this method when your activity should be ready to process deep link.
|
||||||
|
* In most common cases call this method on {@link Activity#onStart()}
|
||||||
|
*
|
||||||
|
* @param activity - that should be able to process deep link.
|
||||||
|
*/
|
||||||
|
public void onActivityReadyToProcessDeepLink(@NonNull final TActivity activity) {
|
||||||
|
this.activity = activity;
|
||||||
|
startToProcessDeepLinkIfPossible();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this method when your activity stopped being ready to process deep link.
|
||||||
|
* In most common cases call this method on {@link Activity#onStop()}
|
||||||
|
*/
|
||||||
|
public void onActivityStopBeingReady() {
|
||||||
|
activity = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method should be called when you need to add additional condition
|
||||||
|
* for processing deep links. By default {@link #allowDeepLinkToProcess}
|
||||||
|
* equals true.
|
||||||
|
*
|
||||||
|
* @param allowDeepLinkToProcess - pass true here if you want to allow deep
|
||||||
|
* link to process, otherwise - pass false.
|
||||||
|
*/
|
||||||
|
public void setAllowDeepLinkToProcess(final boolean allowDeepLinkToProcess) {
|
||||||
|
this.allowDeepLinkToProcess = allowDeepLinkToProcess;
|
||||||
|
startToProcessDeepLinkIfPossible();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startToProcessDeepLinkIfPossible() {
|
||||||
|
if (activity != null && deepLinkUri != null && allowDeepLinkToProcess) {
|
||||||
|
processDeepLink(activity, deepLinkUri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method would be called if there are non null {@link TActivity},
|
||||||
|
* non null {@link #deepLinkUri} and {@link #allowDeepLinkToProcess} equals true.
|
||||||
|
* Don't forget to call activity.getIntent().setData(null) after deep link processing
|
||||||
|
*
|
||||||
|
* @param activity - that should be able to process deep link.
|
||||||
|
* @param deepLinkUri - received deep link.
|
||||||
|
*/
|
||||||
|
protected abstract void processDeepLink(@NonNull final TActivity activity,
|
||||||
|
@NonNull final Uri deepLinkUri);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2015 RoboSwag (Gavriil Sitnikov, Vsevolod Ivanov)
|
||||||
|
*
|
||||||
|
* This file is part of RoboSwag library.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ru.touchin.roboswag.components.deeplinks;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
import ru.touchin.roboswag.components.navigation.activities.BaseActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Ilia Kurtov on 04.08.2015.
|
||||||
|
* Simple DeepLinkController that process deep links as it is. When deep links received it would have been processing and navigating id should.
|
||||||
|
*/
|
||||||
|
public abstract class SimpleActivityDeepLinkController<TActivity extends BaseActivity, TDeepLink extends DeepLink<TActivity>>
|
||||||
|
extends ActivityDeepLinkController<TActivity> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void processDeepLink(@NonNull final TActivity activity, @NonNull final Uri deepLinkUri) {
|
||||||
|
deleteDeepLink(activity);
|
||||||
|
final TDeepLink deepLink = getDeepLinkByUri(deepLinkUri);
|
||||||
|
if (deepLink != null && !deepLink.isOnSuchScreen(activity, deepLinkUri)) {
|
||||||
|
deleteDeepLink(activity);
|
||||||
|
deepLink.navigateTo(activity, deepLinkUri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns deep link that extending {@link DeepLink}.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
protected abstract TDeepLink getDeepLinkByUri(@NonNull final Uri deepLinkUri);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -30,9 +30,8 @@ import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import io.reactivex.functions.BiFunction;
|
|
||||||
import io.reactivex.functions.Function;
|
|
||||||
import ru.touchin.roboswag.core.log.Lc;
|
import ru.touchin.roboswag.core.log.Lc;
|
||||||
|
import rx.functions.Func1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 07/03/2016.
|
* Created by Gavriil Sitnikov on 07/03/2016.
|
||||||
|
|
@ -45,7 +44,7 @@ import ru.touchin.roboswag.core.log.Lc;
|
||||||
* If {@link #back()} method will be called then stack will go to previous fragment.
|
* If {@link #back()} method will be called then stack will go to previous fragment.
|
||||||
* Usually such logic using to set as top fragments from sidebar and show hamburger when some of them appeared;
|
* Usually such logic using to set as top fragments from sidebar and show hamburger when some of them appeared;
|
||||||
* 4) {@link #pushForResult} means to push fragment with target fragment. It is also adding {@link #WITH_TARGET_FRAGMENT_TAG_MARK} tag.
|
* 4) {@link #pushForResult} means to push fragment with target fragment. It is also adding {@link #WITH_TARGET_FRAGMENT_TAG_MARK} tag.
|
||||||
* Also if such up/back navigation logic is not OK then {@link #backTo(Function)} method could be used with any condition to back to.
|
* Also if such up/back navigation logic is not OK then {@link #backTo(Func1)} method could be used with any condition to back to.
|
||||||
* In that case in any stack-change method it is allowed to setup fragment transactions.
|
* In that case in any stack-change method it is allowed to setup fragment transactions.
|
||||||
*/
|
*/
|
||||||
public class FragmentNavigation {
|
public class FragmentNavigation {
|
||||||
|
|
@ -119,7 +118,6 @@ public class FragmentNavigation {
|
||||||
*
|
*
|
||||||
* @param fragmentClass Class of {@link Fragment} to instantiate;
|
* @param fragmentClass Class of {@link Fragment} to instantiate;
|
||||||
* @param targetFragment Target fragment to be set as {@link Fragment#getTargetFragment()} of instantiated {@link Fragment};
|
* @param targetFragment Target fragment to be set as {@link Fragment#getTargetFragment()} of instantiated {@link Fragment};
|
||||||
* @param addToStack Flag to add this transaction to the back stack;
|
|
||||||
* @param args Bundle to be set as {@link Fragment#getArguments()} of instantiated {@link Fragment};
|
* @param args Bundle to be set as {@link Fragment#getArguments()} of instantiated {@link Fragment};
|
||||||
* @param backStackTag Tag of {@link Fragment} in back stack;
|
* @param backStackTag Tag of {@link Fragment} in back stack;
|
||||||
* @param transactionSetup Function to setup transaction before commit. It is useful to specify transition animations or additional info.
|
* @param transactionSetup Function to setup transaction before commit. It is useful to specify transition animations or additional info.
|
||||||
|
|
@ -128,10 +126,9 @@ public class FragmentNavigation {
|
||||||
//CommitTransaction: it is ok as we could setup transaction before commit
|
//CommitTransaction: it is ok as we could setup transaction before commit
|
||||||
protected void addToStack(@NonNull final Class<? extends Fragment> fragmentClass,
|
protected void addToStack(@NonNull final Class<? extends Fragment> fragmentClass,
|
||||||
@Nullable final Fragment targetFragment,
|
@Nullable final Fragment targetFragment,
|
||||||
final boolean addToStack,
|
|
||||||
@Nullable final Bundle args,
|
@Nullable final Bundle args,
|
||||||
@Nullable final String backStackTag,
|
@Nullable final String backStackTag,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
if (fragmentManager.isDestroyed()) {
|
if (fragmentManager.isDestroyed()) {
|
||||||
Lc.assertion("FragmentManager is destroyed");
|
Lc.assertion("FragmentManager is destroyed");
|
||||||
return;
|
return;
|
||||||
|
|
@ -146,23 +143,17 @@ public class FragmentNavigation {
|
||||||
fragment.setTargetFragment(targetFragment, 0);
|
fragment.setTargetFragment(targetFragment, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
|
final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction()
|
||||||
|
.replace(containerViewId, fragment, null)
|
||||||
|
.addToBackStack(backStackTag);
|
||||||
if (fragmentManager.getBackStackEntryCount() != 0) {
|
if (fragmentManager.getBackStackEntryCount() != 0) {
|
||||||
fragmentTransaction.setTransition(getDefaultTransition());
|
fragmentTransaction.setTransition(getDefaultTransition());
|
||||||
}
|
}
|
||||||
if (transactionSetup != null) {
|
if (transactionSetup != null) {
|
||||||
try {
|
transactionSetup.call(fragmentTransaction).commit();
|
||||||
fragmentTransaction = transactionSetup.apply(fragmentTransaction, fragment);
|
} else {
|
||||||
} catch (final Exception exception) {
|
fragmentTransaction.commit();
|
||||||
Lc.assertion(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fragmentTransaction.replace(containerViewId, fragment, null);
|
|
||||||
if (addToStack) {
|
|
||||||
fragmentTransaction.addToBackStack(backStackTag);
|
|
||||||
}
|
|
||||||
fragmentTransaction.commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -193,20 +184,15 @@ public class FragmentNavigation {
|
||||||
* @param condition Condition of back stack entry to be satisfied;
|
* @param condition Condition of back stack entry to be satisfied;
|
||||||
* @return True if it have back to some entry in stack.
|
* @return True if it have back to some entry in stack.
|
||||||
*/
|
*/
|
||||||
public boolean backTo(@NonNull final Function<FragmentManager.BackStackEntry, Boolean> condition) {
|
public boolean backTo(@NonNull final Func1<FragmentManager.BackStackEntry, Boolean> condition) {
|
||||||
final int stackSize = fragmentManager.getBackStackEntryCount();
|
final int stackSize = fragmentManager.getBackStackEntryCount();
|
||||||
Integer id = null;
|
Integer id = null;
|
||||||
try {
|
for (int i = stackSize - 2; i >= 0; i--) {
|
||||||
for (int i = stackSize - 2; i >= 0; i--) {
|
final FragmentManager.BackStackEntry backStackEntry = fragmentManager.getBackStackEntryAt(i);
|
||||||
final FragmentManager.BackStackEntry backStackEntry = fragmentManager.getBackStackEntryAt(i);
|
id = backStackEntry.getId();
|
||||||
id = backStackEntry.getId();
|
if (condition.call(backStackEntry)) {
|
||||||
if (condition.apply(backStackEntry)) {
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (final Exception exception) {
|
|
||||||
Lc.assertion(exception);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
fragmentManager.popBackStack(id, 0);
|
fragmentManager.popBackStack(id, 0);
|
||||||
|
|
@ -235,7 +221,7 @@ public class FragmentNavigation {
|
||||||
* @param fragmentClass Class of {@link Fragment} to instantiate.
|
* @param fragmentClass Class of {@link Fragment} to instantiate.
|
||||||
*/
|
*/
|
||||||
public void push(@NonNull final Class<? extends Fragment> fragmentClass) {
|
public void push(@NonNull final Class<? extends Fragment> fragmentClass) {
|
||||||
addToStack(fragmentClass, null, true, null, null, null);
|
addToStack(fragmentClass, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -246,7 +232,7 @@ public class FragmentNavigation {
|
||||||
*/
|
*/
|
||||||
public void push(@NonNull final Class<? extends Fragment> fragmentClass,
|
public void push(@NonNull final Class<? extends Fragment> fragmentClass,
|
||||||
@NonNull final Bundle args) {
|
@NonNull final Bundle args) {
|
||||||
addToStack(fragmentClass, null, true, args, null, null);
|
addToStack(fragmentClass, null, args, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -256,8 +242,8 @@ public class FragmentNavigation {
|
||||||
* @param transactionSetup Function to setup transaction before commit. It is useful to specify transition animations or additional info.
|
* @param transactionSetup Function to setup transaction before commit. It is useful to specify transition animations or additional info.
|
||||||
*/
|
*/
|
||||||
public void push(@NonNull final Class<? extends Fragment> fragmentClass,
|
public void push(@NonNull final Class<? extends Fragment> fragmentClass,
|
||||||
@NonNull final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@NonNull final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addToStack(fragmentClass, null, true, null, null, transactionSetup);
|
addToStack(fragmentClass, null, null, null, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -269,8 +255,8 @@ public class FragmentNavigation {
|
||||||
*/
|
*/
|
||||||
public void push(@NonNull final Class<? extends Fragment> fragmentClass,
|
public void push(@NonNull final Class<? extends Fragment> fragmentClass,
|
||||||
@Nullable final Bundle args,
|
@Nullable final Bundle args,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addToStack(fragmentClass, null, true, args, null, transactionSetup);
|
addToStack(fragmentClass, null, args, null, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -281,7 +267,7 @@ public class FragmentNavigation {
|
||||||
*/
|
*/
|
||||||
public void pushForResult(@NonNull final Class<? extends Fragment> fragmentClass,
|
public void pushForResult(@NonNull final Class<? extends Fragment> fragmentClass,
|
||||||
@NonNull final Fragment targetFragment) {
|
@NonNull final Fragment targetFragment) {
|
||||||
addToStack(fragmentClass, targetFragment, true, null, fragmentClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, null);
|
addToStack(fragmentClass, targetFragment, null, fragmentClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -294,7 +280,7 @@ public class FragmentNavigation {
|
||||||
public void pushForResult(@NonNull final Class<? extends Fragment> fragmentClass,
|
public void pushForResult(@NonNull final Class<? extends Fragment> fragmentClass,
|
||||||
@NonNull final Fragment targetFragment,
|
@NonNull final Fragment targetFragment,
|
||||||
@NonNull final Bundle args) {
|
@NonNull final Bundle args) {
|
||||||
addToStack(fragmentClass, targetFragment, true, args, fragmentClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, null);
|
addToStack(fragmentClass, targetFragment, args, fragmentClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -306,8 +292,8 @@ public class FragmentNavigation {
|
||||||
*/
|
*/
|
||||||
public void pushForResult(@NonNull final Class<? extends Fragment> fragmentClass,
|
public void pushForResult(@NonNull final Class<? extends Fragment> fragmentClass,
|
||||||
@NonNull final Fragment targetFragment,
|
@NonNull final Fragment targetFragment,
|
||||||
@NonNull final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@NonNull final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addToStack(fragmentClass, targetFragment, true, null, fragmentClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, transactionSetup);
|
addToStack(fragmentClass, targetFragment, null, fragmentClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -321,8 +307,8 @@ public class FragmentNavigation {
|
||||||
public void pushForResult(@NonNull final Class<? extends Fragment> fragmentClass,
|
public void pushForResult(@NonNull final Class<? extends Fragment> fragmentClass,
|
||||||
@NonNull final Fragment targetFragment,
|
@NonNull final Fragment targetFragment,
|
||||||
@Nullable final Bundle args,
|
@Nullable final Bundle args,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addToStack(fragmentClass, targetFragment, true, args, fragmentClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, transactionSetup);
|
addToStack(fragmentClass, targetFragment, args, fragmentClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -331,7 +317,7 @@ public class FragmentNavigation {
|
||||||
* @param fragmentClass Class of {@link Fragment} to instantiate.
|
* @param fragmentClass Class of {@link Fragment} to instantiate.
|
||||||
*/
|
*/
|
||||||
public void setAsTop(@NonNull final Class<? extends Fragment> fragmentClass) {
|
public void setAsTop(@NonNull final Class<? extends Fragment> fragmentClass) {
|
||||||
addToStack(fragmentClass, null, true, null, fragmentClass.getName() + ';' + TOP_FRAGMENT_TAG_MARK, null);
|
addToStack(fragmentClass, null, null, fragmentClass.getName() + ';' + TOP_FRAGMENT_TAG_MARK, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -342,7 +328,7 @@ public class FragmentNavigation {
|
||||||
*/
|
*/
|
||||||
public void setAsTop(@NonNull final Class<? extends Fragment> fragmentClass,
|
public void setAsTop(@NonNull final Class<? extends Fragment> fragmentClass,
|
||||||
@NonNull final Bundle args) {
|
@NonNull final Bundle args) {
|
||||||
addToStack(fragmentClass, null, true, args, fragmentClass.getName() + ';' + TOP_FRAGMENT_TAG_MARK, null);
|
addToStack(fragmentClass, null, args, fragmentClass.getName() + ';' + TOP_FRAGMENT_TAG_MARK, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -353,8 +339,8 @@ public class FragmentNavigation {
|
||||||
* @param transactionSetup Function to setup transaction before commit. It is useful to specify transition animations or additional info.
|
* @param transactionSetup Function to setup transaction before commit. It is useful to specify transition animations or additional info.
|
||||||
*/
|
*/
|
||||||
public void setAsTop(@NonNull final Class<? extends Fragment> fragmentClass,
|
public void setAsTop(@NonNull final Class<? extends Fragment> fragmentClass,
|
||||||
@NonNull final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@NonNull final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addToStack(fragmentClass, null, true, null, fragmentClass.getName() + ';' + TOP_FRAGMENT_TAG_MARK, transactionSetup);
|
addToStack(fragmentClass, null, null, fragmentClass.getName() + ';' + TOP_FRAGMENT_TAG_MARK, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -367,8 +353,8 @@ public class FragmentNavigation {
|
||||||
*/
|
*/
|
||||||
public void setAsTop(@NonNull final Class<? extends Fragment> fragmentClass,
|
public void setAsTop(@NonNull final Class<? extends Fragment> fragmentClass,
|
||||||
@Nullable final Bundle args,
|
@Nullable final Bundle args,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addToStack(fragmentClass, null, true, args, fragmentClass.getName() + ';' + TOP_FRAGMENT_TAG_MARK, transactionSetup);
|
addToStack(fragmentClass, null, args, fragmentClass.getName() + ';' + TOP_FRAGMENT_TAG_MARK, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -398,7 +384,7 @@ public class FragmentNavigation {
|
||||||
* @param transactionSetup Function to setup transaction before commit. It is useful to specify transition animations or additional info.
|
* @param transactionSetup Function to setup transaction before commit. It is useful to specify transition animations or additional info.
|
||||||
*/
|
*/
|
||||||
public void setInitial(@NonNull final Class<? extends Fragment> fragmentClass,
|
public void setInitial(@NonNull final Class<? extends Fragment> fragmentClass,
|
||||||
@NonNull final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@NonNull final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
setInitial(fragmentClass, null, transactionSetup);
|
setInitial(fragmentClass, null, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -411,7 +397,7 @@ public class FragmentNavigation {
|
||||||
*/
|
*/
|
||||||
public void setInitial(@NonNull final Class<? extends Fragment> fragmentClass,
|
public void setInitial(@NonNull final Class<? extends Fragment> fragmentClass,
|
||||||
@Nullable final Bundle args,
|
@Nullable final Bundle args,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
beforeSetInitialActions();
|
beforeSetInitialActions();
|
||||||
setAsTop(fragmentClass, args, transactionSetup);
|
setAsTop(fragmentClass, args, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package ru.touchin.roboswag.components.navigation;
|
package ru.touchin.roboswag.components.navigation;
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.CallSuper;
|
import android.support.annotation.CallSuper;
|
||||||
|
|
@ -38,13 +37,6 @@ import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import io.reactivex.Completable;
|
|
||||||
import io.reactivex.Maybe;
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.Single;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
import io.reactivex.functions.Action;
|
|
||||||
import io.reactivex.functions.Consumer;
|
|
||||||
import ru.touchin.roboswag.components.navigation.activities.ViewControllerActivity;
|
import ru.touchin.roboswag.components.navigation.activities.ViewControllerActivity;
|
||||||
import ru.touchin.roboswag.components.navigation.fragments.ViewControllerFragment;
|
import ru.touchin.roboswag.components.navigation.fragments.ViewControllerFragment;
|
||||||
import ru.touchin.roboswag.components.utils.BaseLifecycleBindable;
|
import ru.touchin.roboswag.components.utils.BaseLifecycleBindable;
|
||||||
|
|
@ -52,6 +44,12 @@ import ru.touchin.roboswag.components.utils.LifecycleBindable;
|
||||||
import ru.touchin.roboswag.components.utils.UiUtils;
|
import ru.touchin.roboswag.components.utils.UiUtils;
|
||||||
import ru.touchin.roboswag.core.log.Lc;
|
import ru.touchin.roboswag.core.log.Lc;
|
||||||
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
||||||
|
import rx.Completable;
|
||||||
|
import rx.Observable;
|
||||||
|
import rx.Single;
|
||||||
|
import rx.Subscription;
|
||||||
|
import rx.functions.Action0;
|
||||||
|
import rx.functions.Action1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 21/10/2015.
|
* Created by Gavriil Sitnikov on 21/10/2015.
|
||||||
|
|
@ -151,7 +149,7 @@ public class ViewController<TActivity extends ViewControllerActivity<?>,
|
||||||
*
|
*
|
||||||
* @param layoutResId Resource ID to be inflated.
|
* @param layoutResId Resource ID to be inflated.
|
||||||
*/
|
*/
|
||||||
public final void setContentView(@LayoutRes final int layoutResId) {
|
public void setContentView(@LayoutRes final int layoutResId) {
|
||||||
if (getContainer().getChildCount() > 0) {
|
if (getContainer().getChildCount() > 0) {
|
||||||
getContainer().removeAllViews();
|
getContainer().removeAllViews();
|
||||||
}
|
}
|
||||||
|
|
@ -164,7 +162,7 @@ public class ViewController<TActivity extends ViewControllerActivity<?>,
|
||||||
*
|
*
|
||||||
* @param view The desired content to display.
|
* @param view The desired content to display.
|
||||||
*/
|
*/
|
||||||
public final void setContentView(@NonNull final View view) {
|
public void setContentView(@NonNull final View view) {
|
||||||
setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,7 +173,7 @@ public class ViewController<TActivity extends ViewControllerActivity<?>,
|
||||||
* @param view The desired content to display;
|
* @param view The desired content to display;
|
||||||
* @param layoutParams Layout parameters for the view.
|
* @param layoutParams Layout parameters for the view.
|
||||||
*/
|
*/
|
||||||
public final void setContentView(@NonNull final View view, @NonNull final ViewGroup.LayoutParams layoutParams) {
|
public void setContentView(@NonNull final View view, @NonNull final ViewGroup.LayoutParams layoutParams) {
|
||||||
if (getContainer().getChildCount() > 0) {
|
if (getContainer().getChildCount() > 0) {
|
||||||
getContainer().removeAllViews();
|
getContainer().removeAllViews();
|
||||||
}
|
}
|
||||||
|
|
@ -331,13 +329,6 @@ public class ViewController<TActivity extends ViewControllerActivity<?>,
|
||||||
destroyed = true;
|
destroyed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback from parent fragment.
|
|
||||||
*/
|
|
||||||
public void onActivityResult(final int requestCode, final int resultCode, @Nullable final Intent data) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to {@link ViewControllerFragment#onOptionsItemSelected(MenuItem)}.
|
* Similar to {@link ViewControllerFragment#onOptionsItemSelected(MenuItem)}.
|
||||||
*
|
*
|
||||||
|
|
@ -348,186 +339,149 @@ public class ViewController<TActivity extends ViewControllerActivity<?>,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("CPD-START")
|
||||||
|
//CPD: it is same as in other implementation based on BaseLifecycleBindable
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable) {
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable) {
|
||||||
return baseLifecycleBindable.untilStop(observable);
|
return baseLifecycleBindable.untilStop(observable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable, @NonNull final Consumer<T> onNextAction) {
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable, @NonNull final Action1<T> onNextAction) {
|
||||||
return baseLifecycleBindable.untilStop(observable, onNextAction);
|
return baseLifecycleBindable.untilStop(observable, onNextAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable,
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction);
|
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable,
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction,
|
@NonNull final Action1<Throwable> onErrorAction,
|
||||||
@NonNull final Action onCompletedAction) {
|
@NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction, onCompletedAction);
|
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single) {
|
public <T> Subscription untilStop(@NonNull final Single<T> single) {
|
||||||
return baseLifecycleBindable.untilStop(single);
|
return baseLifecycleBindable.untilStop(single);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilStop(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||||
return baseLifecycleBindable.untilStop(single, onSuccessAction);
|
return baseLifecycleBindable.untilStop(single, onSuccessAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single,
|
public <T> Subscription untilStop(@NonNull final Single<T> single,
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
@NonNull final Action1<T> onSuccessAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilStop(single, onSuccessAction, onErrorAction);
|
return baseLifecycleBindable.untilStop(single, onSuccessAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable) {
|
public Subscription untilStop(@NonNull final Completable completable) {
|
||||||
return baseLifecycleBindable.untilStop(completable);
|
return baseLifecycleBindable.untilStop(completable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable, @NonNull final Action onCompletedAction) {
|
public Subscription untilStop(@NonNull final Completable completable, @NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilStop(completable, onCompletedAction);
|
return baseLifecycleBindable.untilStop(completable, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable,
|
public Subscription untilStop(@NonNull final Completable completable,
|
||||||
@NonNull final Action onCompletedAction,
|
@NonNull final Action0 onCompletedAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilStop(completable, onCompletedAction, onErrorAction);
|
return baseLifecycleBindable.untilStop(completable, onCompletedAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe) {
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable) {
|
||||||
return baseLifecycleBindable.untilStop(maybe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe, @NonNull final Consumer<T> onSuccessAction) {
|
|
||||||
return baseLifecycleBindable.untilStop(maybe, onSuccessAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe,
|
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
|
||||||
return baseLifecycleBindable.untilStop(maybe, onSuccessAction, onErrorAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(observable);
|
return baseLifecycleBindable.untilDestroy(observable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable, @NonNull final Consumer<T> onNextAction) {
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable, @NonNull final Action1<T> onNextAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(observable, onNextAction);
|
return baseLifecycleBindable.untilDestroy(observable, onNextAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable,
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction);
|
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable,
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction,
|
@NonNull final Action1<Throwable> onErrorAction,
|
||||||
@NonNull final Action onCompletedAction) {
|
@NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction, onCompletedAction);
|
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single) {
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single) {
|
||||||
return baseLifecycleBindable.untilDestroy(single);
|
return baseLifecycleBindable.untilDestroy(single);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(single, onSuccessAction);
|
return baseLifecycleBindable.untilDestroy(single, onSuccessAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single,
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single,
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
@NonNull final Action1<T> onSuccessAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(single, onSuccessAction, onErrorAction);
|
return baseLifecycleBindable.untilDestroy(single, onSuccessAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable) {
|
public Subscription untilDestroy(@NonNull final Completable completable) {
|
||||||
return baseLifecycleBindable.untilDestroy(completable);
|
return baseLifecycleBindable.untilDestroy(completable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable, @NonNull final Action onCompletedAction) {
|
public Subscription untilDestroy(@NonNull final Completable completable, @NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction);
|
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable,
|
public Subscription untilDestroy(@NonNull final Completable completable,
|
||||||
@NonNull final Action onCompletedAction,
|
@NonNull final Action0 onCompletedAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction, onErrorAction);
|
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(maybe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe, @NonNull final Consumer<T> onCompletedAction) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(maybe, onCompletedAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe,
|
|
||||||
@NonNull final Consumer<T> onCompletedAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(maybe, onCompletedAction, onErrorAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("CPD-END")
|
@SuppressWarnings("CPD-END")
|
||||||
/*
|
//CPD: it is same as in other implementation based on BaseLifecycleBindable
|
||||||
|
/**
|
||||||
* Helper class to simplify constructor override.
|
* Helper class to simplify constructor override.
|
||||||
*/
|
*/
|
||||||
public static class CreationContext {
|
public static class CreationContext {
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,13 @@ import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
|
||||||
import io.reactivex.functions.BiFunction;
|
|
||||||
import ru.touchin.roboswag.components.navigation.activities.ViewControllerActivity;
|
import ru.touchin.roboswag.components.navigation.activities.ViewControllerActivity;
|
||||||
import ru.touchin.roboswag.components.navigation.fragments.SimpleViewControllerFragment;
|
import ru.touchin.roboswag.components.navigation.fragments.SimpleViewControllerFragment;
|
||||||
import ru.touchin.roboswag.components.navigation.fragments.StatelessTargetedViewControllerFragment;
|
import ru.touchin.roboswag.components.navigation.fragments.StatelessTargetedViewControllerFragment;
|
||||||
import ru.touchin.roboswag.components.navigation.fragments.StatelessViewControllerFragment;
|
import ru.touchin.roboswag.components.navigation.fragments.StatelessViewControllerFragment;
|
||||||
import ru.touchin.roboswag.components.navigation.fragments.TargetedViewControllerFragment;
|
import ru.touchin.roboswag.components.navigation.fragments.TargetedViewControllerFragment;
|
||||||
import ru.touchin.roboswag.components.navigation.fragments.ViewControllerFragment;
|
import ru.touchin.roboswag.components.navigation.fragments.ViewControllerFragment;
|
||||||
|
import rx.functions.Func1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 07/03/2016.
|
* Created by Gavriil Sitnikov on 07/03/2016.
|
||||||
|
|
@ -59,7 +59,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
*/
|
*/
|
||||||
public <TState extends AbstractState> void push(@NonNull final Class<? extends ViewControllerFragment<TState, TActivity>> fragmentClass,
|
public <TState extends AbstractState> void push(@NonNull final Class<? extends ViewControllerFragment<TState, TActivity>> fragmentClass,
|
||||||
@NonNull final TState state) {
|
@NonNull final TState state) {
|
||||||
addToStack(fragmentClass, null, true, ViewControllerFragment.createState(state), null, null);
|
addToStack(fragmentClass, null, ViewControllerFragment.createState(state), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -72,8 +72,8 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
*/
|
*/
|
||||||
public <TState extends AbstractState> void push(@NonNull final Class<? extends ViewControllerFragment<TState, TActivity>> fragmentClass,
|
public <TState extends AbstractState> void push(@NonNull final Class<? extends ViewControllerFragment<TState, TActivity>> fragmentClass,
|
||||||
@Nullable final TState state,
|
@Nullable final TState state,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addToStack(fragmentClass, null, true, ViewControllerFragment.createState(state), null, transactionSetup);
|
addToStack(fragmentClass, null, ViewControllerFragment.createState(state), null, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -87,7 +87,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
public <TState extends AbstractState> void pushForResult(@NonNull final Class<? extends ViewControllerFragment<TState, TActivity>> fragmentClass,
|
public <TState extends AbstractState> void pushForResult(@NonNull final Class<? extends ViewControllerFragment<TState, TActivity>> fragmentClass,
|
||||||
@NonNull final Fragment targetFragment,
|
@NonNull final Fragment targetFragment,
|
||||||
@NonNull final TState state) {
|
@NonNull final TState state) {
|
||||||
addToStack(fragmentClass, targetFragment, true, ViewControllerFragment.createState(state),
|
addToStack(fragmentClass, targetFragment, ViewControllerFragment.createState(state),
|
||||||
fragmentClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, null);
|
fragmentClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,9 +103,8 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
public <TState extends AbstractState> void pushForResult(@NonNull final Class<? extends ViewControllerFragment<TState, TActivity>> fragmentClass,
|
public <TState extends AbstractState> void pushForResult(@NonNull final Class<? extends ViewControllerFragment<TState, TActivity>> fragmentClass,
|
||||||
@NonNull final Fragment targetFragment,
|
@NonNull final Fragment targetFragment,
|
||||||
@Nullable final TState state,
|
@Nullable final TState state,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment,
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
FragmentTransaction> transactionSetup) {
|
addToStack(fragmentClass, targetFragment, ViewControllerFragment.createState(state),
|
||||||
addToStack(fragmentClass, targetFragment, true, ViewControllerFragment.createState(state),
|
|
||||||
fragmentClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, transactionSetup);
|
fragmentClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,8 +131,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
*/
|
*/
|
||||||
public <TState extends AbstractState> void setAsTop(@NonNull final Class<? extends ViewControllerFragment<TState, TActivity>> fragmentClass,
|
public <TState extends AbstractState> void setAsTop(@NonNull final Class<? extends ViewControllerFragment<TState, TActivity>> fragmentClass,
|
||||||
@Nullable final TState state,
|
@Nullable final TState state,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment,
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
FragmentTransaction> transactionSetup) {
|
|
||||||
setAsTop(fragmentClass, ViewControllerFragment.createState(state), transactionSetup);
|
setAsTop(fragmentClass, ViewControllerFragment.createState(state), transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,8 +157,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
*/
|
*/
|
||||||
public <TState extends AbstractState> void setInitial(@NonNull final Class<? extends ViewControllerFragment<TState, TActivity>> fragmentClass,
|
public <TState extends AbstractState> void setInitial(@NonNull final Class<? extends ViewControllerFragment<TState, TActivity>> fragmentClass,
|
||||||
@Nullable final TState state,
|
@Nullable final TState state,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment,
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
FragmentTransaction> transactionSetup) {
|
|
||||||
setInitial(fragmentClass, ViewControllerFragment.createState(state), transactionSetup);
|
setInitial(fragmentClass, ViewControllerFragment.createState(state), transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -184,7 +181,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
public <TState extends AbstractState> void pushViewController(@NonNull final Class<? extends ViewController<TActivity,
|
public <TState extends AbstractState> void pushViewController(@NonNull final Class<? extends ViewController<TActivity,
|
||||||
SimpleViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
SimpleViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
||||||
@NonNull final TState state) {
|
@NonNull final TState state) {
|
||||||
addViewControllerToStack(viewControllerClass, state, null, null);
|
addViewControllerToStack(viewControllerClass, null, state, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -195,7 +192,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
*/
|
*/
|
||||||
public void pushViewController(
|
public void pushViewController(
|
||||||
@NonNull final Class<? extends ViewController<TActivity, StatelessViewControllerFragment<TActivity>>> viewControllerClass,
|
@NonNull final Class<? extends ViewController<TActivity, StatelessViewControllerFragment<TActivity>>> viewControllerClass,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addStatelessViewControllerToStack(viewControllerClass, null, null, transactionSetup);
|
addStatelessViewControllerToStack(viewControllerClass, null, null, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,30 +207,28 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
public <TState extends AbstractState> void pushViewController(
|
public <TState extends AbstractState> void pushViewController(
|
||||||
@NonNull final Class<? extends ViewController<TActivity, SimpleViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
@NonNull final Class<? extends ViewController<TActivity, SimpleViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
||||||
@NonNull final TState state,
|
@NonNull final TState state,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addViewControllerToStack(viewControllerClass, state, null, transactionSetup);
|
addViewControllerToStack(viewControllerClass, null, state, null, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pushes {@link ViewController} without adding to stack.
|
* Pushes {@link ViewController} on top of stack with specific {@link StatelessTargetedViewControllerFragment#getState()}
|
||||||
*
|
* and with specific {@link TargetedViewControllerFragment#getTarget()}.
|
||||||
* @param viewControllerClass Class of {@link ViewController} to be pushed.
|
|
||||||
*/
|
|
||||||
public void pushSingleViewController(@NonNull final Class<? extends ViewController<TActivity,
|
|
||||||
StatelessViewControllerFragment<TActivity>>> viewControllerClass) {
|
|
||||||
addToStack(StatelessViewControllerFragment.class, null, false, StatelessViewControllerFragment.createState(viewControllerClass), null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pushes {@link ViewController} without adding to stack and with specific {@link ViewControllerFragment#getState()}.
|
|
||||||
*
|
*
|
||||||
* @param viewControllerClass Class of {@link ViewController} to be pushed;
|
* @param viewControllerClass Class of {@link ViewController} to be pushed;
|
||||||
* @param state {@link AbstractState} of {@link ViewController}'s fragment;
|
* @param targetFragment {@link ViewControllerFragment} to be set as target;
|
||||||
* @param <TState> Type of state of fragment.
|
* @param <TTargetState> Type of state of target fragment. State is using to affect on that fragment;
|
||||||
|
* @param <TTargetFragment> Type of target fragment.
|
||||||
*/
|
*/
|
||||||
public <TState extends AbstractState> void pushSingleViewController(@NonNull final Class<? extends ViewController<TActivity,
|
@SuppressWarnings("CPD-START")
|
||||||
SimpleViewControllerFragment<TState, TActivity>>> viewControllerClass, @NonNull final TState state) {
|
public <TTargetState extends AbstractState,
|
||||||
addToStack(SimpleViewControllerFragment.class, null, false, SimpleViewControllerFragment.createState(viewControllerClass, state), null, null);
|
TTargetFragment extends ViewControllerFragment<? extends TTargetState, TActivity>> void pushStatelessTargetedViewControllerForResult(
|
||||||
|
@NonNull final Class<? extends ViewController<TActivity,
|
||||||
|
TargetedViewControllerFragment<AbstractState, TTargetState, TActivity>>> viewControllerClass,
|
||||||
|
@NonNull final TTargetFragment targetFragment) {
|
||||||
|
addToStack(StatelessTargetedViewControllerFragment.class, targetFragment,
|
||||||
|
StatelessTargetedViewControllerFragment.createState(viewControllerClass),
|
||||||
|
viewControllerClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -244,6 +239,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
* @param <TTargetState> Type of state of target fragment. State is using to affect on that fragment;
|
* @param <TTargetState> Type of state of target fragment. State is using to affect on that fragment;
|
||||||
* @param <TTargetFragment> Type of target fragment.
|
* @param <TTargetFragment> Type of target fragment.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("CPD-END")
|
||||||
public <TTargetState extends AbstractState,
|
public <TTargetState extends AbstractState,
|
||||||
TTargetFragment extends ViewControllerFragment<? extends TTargetState, TActivity>> void pushViewControllerForResult(
|
TTargetFragment extends ViewControllerFragment<? extends TTargetState, TActivity>> void pushViewControllerForResult(
|
||||||
@NonNull final Class<? extends ViewController<TActivity,
|
@NonNull final Class<? extends ViewController<TActivity,
|
||||||
|
|
@ -267,7 +263,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
@NonNull final Class<? extends ViewController<TActivity,
|
@NonNull final Class<? extends ViewController<TActivity,
|
||||||
StatelessTargetedViewControllerFragment<TTargetState, TActivity>>> viewControllerClass,
|
StatelessTargetedViewControllerFragment<TTargetState, TActivity>>> viewControllerClass,
|
||||||
@NonNull final TTargetFragment targetFragment,
|
@NonNull final TTargetFragment targetFragment,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addTargetedStatelessViewControllerToStack(viewControllerClass, targetFragment,
|
addTargetedStatelessViewControllerToStack(viewControllerClass, targetFragment,
|
||||||
viewControllerClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, transactionSetup);
|
viewControllerClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
@ -313,7 +309,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
TargetedViewControllerFragment<TState, TTargetState, TActivity>>> viewControllerClass,
|
TargetedViewControllerFragment<TState, TTargetState, TActivity>>> viewControllerClass,
|
||||||
@NonNull final TTargetFragment targetFragment,
|
@NonNull final TTargetFragment targetFragment,
|
||||||
@NonNull final TState state,
|
@NonNull final TState state,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addTargetedViewControllerToStack(viewControllerClass, targetFragment, state,
|
addTargetedViewControllerToStack(viewControllerClass, targetFragment, state,
|
||||||
viewControllerClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, transactionSetup);
|
viewControllerClass.getName() + ';' + WITH_TARGET_FRAGMENT_TAG_MARK, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
@ -339,7 +335,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
public <TState extends AbstractState> void setViewControllerAsTop(
|
public <TState extends AbstractState> void setViewControllerAsTop(
|
||||||
@NonNull final Class<? extends ViewController<TActivity, SimpleViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
@NonNull final Class<? extends ViewController<TActivity, SimpleViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
||||||
@NonNull final TState state) {
|
@NonNull final TState state) {
|
||||||
addViewControllerToStack(viewControllerClass, state, viewControllerClass.getName() + ' ' + TOP_FRAGMENT_TAG_MARK, null);
|
addViewControllerToStack(viewControllerClass, null, state, viewControllerClass.getName() + ' ' + TOP_FRAGMENT_TAG_MARK, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -351,7 +347,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
*/
|
*/
|
||||||
public void setViewControllerAsTop(
|
public void setViewControllerAsTop(
|
||||||
@NonNull final Class<? extends ViewController<TActivity, StatelessViewControllerFragment<TActivity>>> viewControllerClass,
|
@NonNull final Class<? extends ViewController<TActivity, StatelessViewControllerFragment<TActivity>>> viewControllerClass,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addStatelessViewControllerToStack(viewControllerClass, null, viewControllerClass.getName() + ' ' + TOP_FRAGMENT_TAG_MARK, transactionSetup);
|
addStatelessViewControllerToStack(viewControllerClass, null, viewControllerClass.getName() + ' ' + TOP_FRAGMENT_TAG_MARK, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -367,8 +363,8 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
public <TState extends AbstractState> void setViewControllerAsTop(
|
public <TState extends AbstractState> void setViewControllerAsTop(
|
||||||
@NonNull final Class<? extends ViewController<TActivity, SimpleViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
@NonNull final Class<? extends ViewController<TActivity, SimpleViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
||||||
@NonNull final TState state,
|
@NonNull final TState state,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addViewControllerToStack(viewControllerClass, state, viewControllerClass.getName() + ' ' + TOP_FRAGMENT_TAG_MARK, transactionSetup);
|
addViewControllerToStack(viewControllerClass, null, state, viewControllerClass.getName() + ' ' + TOP_FRAGMENT_TAG_MARK, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -404,7 +400,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
*/
|
*/
|
||||||
public void setInitialViewController(
|
public void setInitialViewController(
|
||||||
@NonNull final Class<? extends ViewController<TActivity, StatelessViewControllerFragment<TActivity>>> viewControllerClass,
|
@NonNull final Class<? extends ViewController<TActivity, StatelessViewControllerFragment<TActivity>>> viewControllerClass,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
beforeSetInitialActions();
|
beforeSetInitialActions();
|
||||||
setViewControllerAsTop(viewControllerClass, transactionSetup);
|
setViewControllerAsTop(viewControllerClass, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
@ -421,7 +417,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
public <TState extends AbstractState> void setInitialViewController(
|
public <TState extends AbstractState> void setInitialViewController(
|
||||||
@NonNull final Class<? extends ViewController<TActivity, SimpleViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
@NonNull final Class<? extends ViewController<TActivity, SimpleViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
||||||
@NonNull final TState state,
|
@NonNull final TState state,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
beforeSetInitialActions();
|
beforeSetInitialActions();
|
||||||
setViewControllerAsTop(viewControllerClass, state, transactionSetup);
|
setViewControllerAsTop(viewControllerClass, state, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
@ -438,8 +434,8 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
@NonNull final Class<? extends ViewController<TActivity, ? extends StatelessViewControllerFragment<TActivity>>> viewControllerClass,
|
@NonNull final Class<? extends ViewController<TActivity, ? extends StatelessViewControllerFragment<TActivity>>> viewControllerClass,
|
||||||
@Nullable final Fragment targetFragment,
|
@Nullable final Fragment targetFragment,
|
||||||
@Nullable final String backStackTag,
|
@Nullable final String backStackTag,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addToStack(StatelessViewControllerFragment.class, targetFragment, true,
|
addToStack(StatelessViewControllerFragment.class, targetFragment,
|
||||||
StatelessViewControllerFragment.createState(viewControllerClass), backStackTag, transactionSetup);
|
StatelessViewControllerFragment.createState(viewControllerClass), backStackTag, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -460,8 +456,8 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
@NonNull final Fragment targetFragment,
|
@NonNull final Fragment targetFragment,
|
||||||
@NonNull final TState state,
|
@NonNull final TState state,
|
||||||
@Nullable final String backStackTag,
|
@Nullable final String backStackTag,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addToStack(TargetedViewControllerFragment.class, targetFragment, true,
|
addToStack(TargetedViewControllerFragment.class, targetFragment,
|
||||||
TargetedViewControllerFragment.createState(viewControllerClass, state), backStackTag, transactionSetup);
|
TargetedViewControllerFragment.createState(viewControllerClass, state), backStackTag, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -479,8 +475,8 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
? extends StatelessTargetedViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
? extends StatelessTargetedViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
||||||
@NonNull final Fragment targetFragment,
|
@NonNull final Fragment targetFragment,
|
||||||
@Nullable final String backStackTag,
|
@Nullable final String backStackTag,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addToStack(StatelessTargetedViewControllerFragment.class, targetFragment, true,
|
addToStack(StatelessTargetedViewControllerFragment.class, targetFragment,
|
||||||
StatelessTargetedViewControllerFragment.createState(viewControllerClass), backStackTag, transactionSetup);
|
StatelessTargetedViewControllerFragment.createState(viewControllerClass), backStackTag, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -488,6 +484,7 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
* Base method to push stateful {@link ViewControllerFragment} to stack.
|
* Base method to push stateful {@link ViewControllerFragment} to stack.
|
||||||
*
|
*
|
||||||
* @param viewControllerClass Class of {@link ViewController} to be pushed;
|
* @param viewControllerClass Class of {@link ViewController} to be pushed;
|
||||||
|
* @param targetFragment {@link ViewControllerFragment} to be set as target;
|
||||||
* @param state {@link AbstractState} of {@link ViewController}'s fragment;
|
* @param state {@link AbstractState} of {@link ViewController}'s fragment;
|
||||||
* @param backStackTag Tag of {@link ViewControllerFragment} in back stack;
|
* @param backStackTag Tag of {@link ViewControllerFragment} in back stack;
|
||||||
* @param transactionSetup Function to setup transaction before commit. It is useful to specify transition animations or additional info;
|
* @param transactionSetup Function to setup transaction before commit. It is useful to specify transition animations or additional info;
|
||||||
|
|
@ -495,10 +492,11 @@ public class ViewControllerNavigation<TActivity extends ViewControllerActivity<?
|
||||||
*/
|
*/
|
||||||
protected <TState extends AbstractState> void addViewControllerToStack(
|
protected <TState extends AbstractState> void addViewControllerToStack(
|
||||||
@NonNull final Class<? extends ViewController<TActivity, ? extends SimpleViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
@NonNull final Class<? extends ViewController<TActivity, ? extends SimpleViewControllerFragment<TState, TActivity>>> viewControllerClass,
|
||||||
|
@Nullable final Fragment targetFragment,
|
||||||
@NonNull final TState state,
|
@NonNull final TState state,
|
||||||
@Nullable final String backStackTag,
|
@Nullable final String backStackTag,
|
||||||
@Nullable final BiFunction<FragmentTransaction, Fragment, FragmentTransaction> transactionSetup) {
|
@Nullable final Func1<FragmentTransaction, FragmentTransaction> transactionSetup) {
|
||||||
addToStack(SimpleViewControllerFragment.class, null, true,
|
addToStack(SimpleViewControllerFragment.class, targetFragment,
|
||||||
SimpleViewControllerFragment.createState(viewControllerClass, state), backStackTag, transactionSetup);
|
SimpleViewControllerFragment.createState(viewControllerClass, state), backStackTag, transactionSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,20 +35,19 @@ import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import io.reactivex.Completable;
|
|
||||||
import io.reactivex.Maybe;
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.Single;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
import io.reactivex.functions.Action;
|
|
||||||
import io.reactivex.functions.Consumer;
|
|
||||||
import io.reactivex.subjects.BehaviorSubject;
|
|
||||||
import ru.touchin.roboswag.components.utils.BaseLifecycleBindable;
|
import ru.touchin.roboswag.components.utils.BaseLifecycleBindable;
|
||||||
import ru.touchin.roboswag.components.utils.LifecycleBindable;
|
import ru.touchin.roboswag.components.utils.LifecycleBindable;
|
||||||
import ru.touchin.roboswag.components.utils.UiUtils;
|
import ru.touchin.roboswag.components.utils.UiUtils;
|
||||||
import ru.touchin.roboswag.core.log.Lc;
|
import ru.touchin.roboswag.core.log.Lc;
|
||||||
import ru.touchin.roboswag.core.utils.Optional;
|
import ru.touchin.roboswag.core.utils.Optional;
|
||||||
import ru.touchin.roboswag.core.utils.pairs.HalfNullablePair;
|
import ru.touchin.roboswag.core.utils.pairs.HalfNullablePair;
|
||||||
|
import rx.Completable;
|
||||||
|
import rx.Observable;
|
||||||
|
import rx.Single;
|
||||||
|
import rx.Subscription;
|
||||||
|
import rx.functions.Action0;
|
||||||
|
import rx.functions.Action1;
|
||||||
|
import rx.subjects.BehaviorSubject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 08/03/2016.
|
* Created by Gavriil Sitnikov on 08/03/2016.
|
||||||
|
|
@ -69,7 +68,7 @@ public abstract class BaseActivity extends AppCompatActivity
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final BehaviorSubject<Optional<HalfNullablePair<Integer, Intent>>> lastActivityResult
|
private final BehaviorSubject<Optional<HalfNullablePair<Integer, Intent>>> lastActivityResult
|
||||||
= BehaviorSubject.createDefault(new Optional<HalfNullablePair<Integer, Intent>>(null));
|
= BehaviorSubject.create(new Optional<HalfNullablePair<Integer, Intent>>(null));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if activity resumed.
|
* Returns if activity resumed.
|
||||||
|
|
@ -258,185 +257,145 @@ public abstract class BaseActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("CPD-START")
|
@SuppressWarnings("CPD-START")
|
||||||
//CPD: it's ok as it's LifecycleBindable
|
//CPD: it is same as in other implementation based on BaseLifecycleBindable
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable) {
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable,
|
||||||
return baseLifecycleBindable.untilStop(observable);
|
@NonNull final Action1<T> onNextAction,
|
||||||
}
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable, @NonNull final Consumer<T> onNextAction) {
|
|
||||||
return baseLifecycleBindable.untilStop(observable, onNextAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable,
|
|
||||||
@NonNull final Consumer<T> onNextAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
|
||||||
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction);
|
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable,
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction,
|
@NonNull final Action1<Throwable> onErrorAction,
|
||||||
@NonNull final Action onCompletedAction) {
|
@NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction, onCompletedAction);
|
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single) {
|
public <T> Subscription untilStop(@NonNull final Single<T> single) {
|
||||||
return baseLifecycleBindable.untilStop(single);
|
return baseLifecycleBindable.untilStop(single);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilStop(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||||
return baseLifecycleBindable.untilStop(single, onSuccessAction);
|
return baseLifecycleBindable.untilStop(single, onSuccessAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single,
|
public <T> Subscription untilStop(@NonNull final Single<T> single,
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
@NonNull final Action1<T> onSuccessAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilStop(single, onSuccessAction, onErrorAction);
|
return baseLifecycleBindable.untilStop(single, onSuccessAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable) {
|
public Subscription untilStop(@NonNull final Completable completable) {
|
||||||
return baseLifecycleBindable.untilStop(completable);
|
return baseLifecycleBindable.untilStop(completable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable, @NonNull final Action onCompletedAction) {
|
public Subscription untilStop(@NonNull final Completable completable, @NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilStop(completable, onCompletedAction);
|
return baseLifecycleBindable.untilStop(completable, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable,
|
public Subscription untilStop(@NonNull final Completable completable,
|
||||||
@NonNull final Action onCompletedAction,
|
@NonNull final Action0 onCompletedAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilStop(completable, onCompletedAction, onErrorAction);
|
return baseLifecycleBindable.untilStop(completable, onCompletedAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe) {
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable) {
|
||||||
return baseLifecycleBindable.untilStop(maybe);
|
return baseLifecycleBindable.untilStop(observable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable, @NonNull final Action1<T> onNextAction) {
|
||||||
return baseLifecycleBindable.untilStop(maybe, onSuccessAction);
|
return baseLifecycleBindable.untilStop(observable, onNextAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe,
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable) {
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
|
||||||
return baseLifecycleBindable.untilStop(maybe, onSuccessAction, onErrorAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(observable);
|
return baseLifecycleBindable.untilDestroy(observable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable, @NonNull final Consumer<T> onNextAction) {
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable, @NonNull final Action1<T> onNextAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(observable, onNextAction);
|
return baseLifecycleBindable.untilDestroy(observable, onNextAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable,
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction);
|
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable,
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction,
|
@NonNull final Action1<Throwable> onErrorAction,
|
||||||
@NonNull final Action onCompletedAction) {
|
@NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction, onCompletedAction);
|
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single) {
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single) {
|
||||||
return baseLifecycleBindable.untilDestroy(single);
|
return baseLifecycleBindable.untilDestroy(single);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(single, onSuccessAction);
|
return baseLifecycleBindable.untilDestroy(single, onSuccessAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single,
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single,
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
@NonNull final Action1<T> onSuccessAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(single, onSuccessAction, onErrorAction);
|
return baseLifecycleBindable.untilDestroy(single, onSuccessAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable) {
|
public Subscription untilDestroy(@NonNull final Completable completable) {
|
||||||
return baseLifecycleBindable.untilDestroy(completable);
|
return baseLifecycleBindable.untilDestroy(completable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable, @NonNull final Action onCompletedAction) {
|
public Subscription untilDestroy(@NonNull final Completable completable, @NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction);
|
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable,
|
public Subscription untilDestroy(@NonNull final Completable completable,
|
||||||
@NonNull final Action onCompletedAction,
|
@NonNull final Action0 onCompletedAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction, onErrorAction);
|
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(maybe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe, @NonNull final Consumer<T> onCompletedAction) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(maybe, onCompletedAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe,
|
|
||||||
@NonNull final Consumer<T> onCompletedAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(maybe, onCompletedAction, onErrorAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("CPD-END")
|
@SuppressWarnings("CPD-END")
|
||||||
/*
|
/*
|
||||||
* Interface to be implemented for someone who want to intercept device back button pressing event.
|
* Interface to be implemented for someone who want to intercept device back button pressing event.
|
||||||
|
|
|
||||||
|
|
@ -103,8 +103,8 @@ public abstract class ViewControllerActivity<TLogic extends Logic> extends BaseA
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T extends View> T findViewById(@IdRes final int id) {
|
public View findViewById(@IdRes final int id) {
|
||||||
final T viewById = super.findViewById(id);
|
final View viewById = super.findViewById(id);
|
||||||
if (viewById == null) {
|
if (viewById == null) {
|
||||||
throw new ShouldNotHappenException("No view for id=" + getResources().getResourceName(id));
|
throw new ShouldNotHappenException("No view for id=" + getResources().getResourceName(id));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
package ru.touchin.roboswag.components.navigation.fragments;
|
package ru.touchin.roboswag.components.navigation.fragments;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
|
|
@ -40,9 +39,6 @@ import java.io.Serializable;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
import io.reactivex.subjects.BehaviorSubject;
|
|
||||||
import ru.touchin.roboswag.components.navigation.AbstractState;
|
import ru.touchin.roboswag.components.navigation.AbstractState;
|
||||||
import ru.touchin.roboswag.components.navigation.ViewController;
|
import ru.touchin.roboswag.components.navigation.ViewController;
|
||||||
import ru.touchin.roboswag.components.navigation.activities.ViewControllerActivity;
|
import ru.touchin.roboswag.components.navigation.activities.ViewControllerActivity;
|
||||||
|
|
@ -51,6 +47,10 @@ import ru.touchin.roboswag.core.log.Lc;
|
||||||
import ru.touchin.roboswag.core.utils.Optional;
|
import ru.touchin.roboswag.core.utils.Optional;
|
||||||
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
||||||
import ru.touchin.roboswag.core.utils.pairs.NullablePair;
|
import ru.touchin.roboswag.core.utils.pairs.NullablePair;
|
||||||
|
import rx.Observable;
|
||||||
|
import rx.Subscription;
|
||||||
|
import rx.exceptions.OnErrorThrowable;
|
||||||
|
import rx.subjects.BehaviorSubject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 21/10/2015.
|
* Created by Gavriil Sitnikov on 21/10/2015.
|
||||||
|
|
@ -118,7 +118,7 @@ public abstract class ViewControllerFragment<TState extends AbstractState, TActi
|
||||||
private final BehaviorSubject<NullablePair<PlaceholderView, Bundle>> viewSubject = BehaviorSubject.create();
|
private final BehaviorSubject<NullablePair<PlaceholderView, Bundle>> viewSubject = BehaviorSubject.create();
|
||||||
@Nullable
|
@Nullable
|
||||||
private ViewController viewController;
|
private ViewController viewController;
|
||||||
private Disposable viewControllerSubscription;
|
private Subscription viewControllerSubscription;
|
||||||
private TState state;
|
private TState state;
|
||||||
private boolean started;
|
private boolean started;
|
||||||
private boolean stateCreated;
|
private boolean stateCreated;
|
||||||
|
|
@ -180,14 +180,15 @@ public abstract class ViewControllerFragment<TState extends AbstractState, TActi
|
||||||
final TActivity activity = activityOptional.get();
|
final TActivity activity = activityOptional.get();
|
||||||
final PlaceholderView container = viewInfo.getFirst();
|
final PlaceholderView container = viewInfo.getFirst();
|
||||||
if (activity == null || container == null) {
|
if (activity == null || container == null) {
|
||||||
return new Optional<ViewController>(null);
|
return null;
|
||||||
}
|
}
|
||||||
final ViewController newViewController = createViewController(activity, container, viewInfo.getSecond());
|
final ViewController newViewController = createViewController(activity, container, viewInfo.getSecond());
|
||||||
newViewController.onCreate();
|
newViewController.onCreate();
|
||||||
return new Optional<>(newViewController);
|
return newViewController;
|
||||||
})
|
})
|
||||||
.subscribe(this::onViewControllerChanged,
|
.subscribe(this::onViewControllerChanged,
|
||||||
throwable -> Lc.cutAssertion(throwable, InvocationTargetException.class, InflateException.class));
|
throwable -> Lc.cutAssertion(throwable,
|
||||||
|
OnErrorThrowable.class, InvocationTargetException.class, InflateException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
@ -195,7 +196,7 @@ public abstract class ViewControllerFragment<TState extends AbstractState, TActi
|
||||||
@Nullable final Bundle savedInstanceState) {
|
@Nullable final Bundle savedInstanceState) {
|
||||||
|
|
||||||
if (getViewControllerClass().getConstructors().length != 1) {
|
if (getViewControllerClass().getConstructors().length != 1) {
|
||||||
throw new ShouldNotHappenException("There should be single constructor for " + getViewControllerClass());
|
throw OnErrorThrowable.from(new ShouldNotHappenException("There should be single constructor for " + getViewControllerClass()));
|
||||||
}
|
}
|
||||||
final Constructor<?> constructor = getViewControllerClass().getConstructors()[0];
|
final Constructor<?> constructor = getViewControllerClass().getConstructors()[0];
|
||||||
final ViewController.CreationContext creationContext = new ViewController.CreationContext(activity, this, view);
|
final ViewController.CreationContext creationContext = new ViewController.CreationContext(activity, this, view);
|
||||||
|
|
@ -207,10 +208,11 @@ public abstract class ViewControllerFragment<TState extends AbstractState, TActi
|
||||||
case 3:
|
case 3:
|
||||||
return (ViewController) constructor.newInstance(this, creationContext, savedInstanceState);
|
return (ViewController) constructor.newInstance(this, creationContext, savedInstanceState);
|
||||||
default:
|
default:
|
||||||
throw new ShouldNotHappenException("Wrong constructor parameters count: " + constructor.getParameterTypes().length);
|
throw OnErrorThrowable
|
||||||
|
.from(new ShouldNotHappenException("Wrong constructor parameters count: " + constructor.getParameterTypes().length));
|
||||||
}
|
}
|
||||||
} catch (final Exception exception) {
|
} catch (final Exception exception) {
|
||||||
throw new ShouldNotHappenException(exception);
|
throw OnErrorThrowable.from(exception);
|
||||||
} finally {
|
} finally {
|
||||||
checkCreationTime(creationTime);
|
checkCreationTime(creationTime);
|
||||||
}
|
}
|
||||||
|
|
@ -313,11 +315,11 @@ public abstract class ViewControllerFragment<TState extends AbstractState, TActi
|
||||||
return (viewController != null && viewController.onOptionsItemSelected(item)) || super.onOptionsItemSelected(item);
|
return (viewController != null && viewController.onOptionsItemSelected(item)) || super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onViewControllerChanged(@NonNull final Optional<ViewController> viewControllerOptional) {
|
private void onViewControllerChanged(@Nullable final ViewController viewController) {
|
||||||
if (this.viewController != null) {
|
if (this.viewController != null) {
|
||||||
this.viewController.onDestroy();
|
this.viewController.onDestroy();
|
||||||
}
|
}
|
||||||
this.viewController = viewControllerOptional.get();
|
this.viewController = viewController;
|
||||||
if (this.viewController != null) {
|
if (this.viewController != null) {
|
||||||
if (started) {
|
if (started) {
|
||||||
this.viewController.onStart();
|
this.viewController.onStart();
|
||||||
|
|
@ -374,7 +376,7 @@ public abstract class ViewControllerFragment<TState extends AbstractState, TActi
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
viewControllerSubscription.dispose();
|
viewControllerSubscription.unsubscribe();
|
||||||
if (viewController != null && !viewController.isDestroyed()) {
|
if (viewController != null && !viewController.isDestroyed()) {
|
||||||
viewController.onDestroy();
|
viewController.onDestroy();
|
||||||
viewController = null;
|
viewController = null;
|
||||||
|
|
@ -382,12 +384,10 @@ public abstract class ViewControllerFragment<TState extends AbstractState, TActi
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(final int requestCode, final int resultCode, @Nullable final Intent data) {
|
public String toString() {
|
||||||
if (viewController != null) {
|
return super.toString() + "ViewController: " + getViewControllerClass();
|
||||||
viewController.onActivityResult(requestCode, resultCode, data);
|
|
||||||
}
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PlaceholderView extends FrameLayout {
|
private static class PlaceholderView extends FrameLayout {
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,9 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import io.reactivex.functions.BiConsumer;
|
|
||||||
import ru.touchin.roboswag.components.navigation.OnFragmentStartedListener;
|
import ru.touchin.roboswag.components.navigation.OnFragmentStartedListener;
|
||||||
import ru.touchin.roboswag.core.log.Lc;
|
import ru.touchin.roboswag.core.log.Lc;
|
||||||
|
import rx.functions.Action2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 21/10/2015.
|
* Created by Gavriil Sitnikov on 21/10/2015.
|
||||||
|
|
@ -111,16 +111,12 @@ public abstract class ViewFragment<TActivity extends AppCompatActivity> extends
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
private void callMethodAfterInstantiation(@NonNull final BiConsumer<View, TActivity> action) {
|
private void callMethodAfterInstantiation(@NonNull final Action2<View, TActivity> action) {
|
||||||
if (getView() == null || getBaseActivity() == null) {
|
if (getView() == null || getBaseActivity() == null) {
|
||||||
Lc.assertion("View and activity shouldn't be null");
|
Lc.assertion("View and activity shouldn't be null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
action.call(getView(), getBaseActivity());
|
||||||
action.accept(getView(), getBaseActivity());
|
|
||||||
} catch (final Exception exception) {
|
|
||||||
Lc.assertion(exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|
|
||||||
|
|
@ -21,18 +21,18 @@ package ru.touchin.roboswag.components.utils;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import io.reactivex.Completable;
|
|
||||||
import io.reactivex.Maybe;
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.Single;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
import io.reactivex.functions.Action;
|
|
||||||
import io.reactivex.functions.Consumer;
|
|
||||||
import io.reactivex.internal.functions.Functions;
|
|
||||||
import io.reactivex.subjects.BehaviorSubject;
|
|
||||||
import ru.touchin.roboswag.core.log.Lc;
|
import ru.touchin.roboswag.core.log.Lc;
|
||||||
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
||||||
|
import rx.Completable;
|
||||||
|
import rx.Observable;
|
||||||
|
import rx.Single;
|
||||||
|
import rx.Subscription;
|
||||||
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
|
import rx.exceptions.OnErrorThrowable;
|
||||||
|
import rx.functions.Action0;
|
||||||
|
import rx.functions.Action1;
|
||||||
|
import rx.functions.Actions;
|
||||||
|
import rx.subjects.BehaviorSubject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 18/04/16.
|
* Created by Gavriil Sitnikov on 18/04/16.
|
||||||
|
|
@ -49,7 +49,7 @@ public class BaseLifecycleBindable implements LifecycleBindable {
|
||||||
@NonNull
|
@NonNull
|
||||||
private final BehaviorSubject<Boolean> isStartedSubject = BehaviorSubject.create();
|
private final BehaviorSubject<Boolean> isStartedSubject = BehaviorSubject.create();
|
||||||
@NonNull
|
@NonNull
|
||||||
private final BehaviorSubject<Boolean> isInAfterSaving = BehaviorSubject.createDefault(false);
|
private final BehaviorSubject<Boolean> isInAfterSaving = BehaviorSubject.create();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call it on parent's onCreate method.
|
* Call it on parent's onCreate method.
|
||||||
|
|
@ -97,230 +97,181 @@ public class BaseLifecycleBindable implements LifecycleBindable {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable) {
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable) {
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
final String codePoint = Lc.getCodePoint(this, 2);
|
||||||
return untilStop(observable, Functions.emptyConsumer(), getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD), Functions.EMPTY_ACTION);
|
return untilStop(observable, Actions.empty(), getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD), Actions.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable, @NonNull final Consumer<T> onNextAction) {
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable, @NonNull final Action1<T> onNextAction) {
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
final String codePoint = Lc.getCodePoint(this, 2);
|
||||||
return untilStop(observable, onNextAction, getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD), Functions.EMPTY_ACTION);
|
return untilStop(observable, onNextAction, getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD), Actions.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable,
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return untilStop(observable, onNextAction, onErrorAction, Functions.EMPTY_ACTION);
|
return untilStop(observable, onNextAction, onErrorAction, Actions.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable,
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction,
|
@NonNull final Action1<Throwable> onErrorAction,
|
||||||
@NonNull final Action onCompletedAction) {
|
@NonNull final Action0 onCompletedAction) {
|
||||||
return until(observable, isStartedSubject.map(started -> !started)
|
return until(observable.delay(item -> isInAfterSaving.first(inAfterSaving -> !inAfterSaving)),
|
||||||
.delay(item -> isInAfterSaving.filter(inAfterSaving -> !inAfterSaving)),
|
isStartedSubject.map(started -> !started),
|
||||||
onNextAction, onErrorAction, onCompletedAction);
|
onNextAction, onErrorAction, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single) {
|
public <T> Subscription untilStop(@NonNull final Single<T> single) {
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
final String codePoint = Lc.getCodePoint(this, 2);
|
||||||
return untilStop(single, Functions.emptyConsumer(), getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD));
|
return untilStop(single, Actions.empty(), getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilStop(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
final String codePoint = Lc.getCodePoint(this, 2);
|
||||||
return untilStop(single, onSuccessAction, getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD));
|
return untilStop(single, onSuccessAction, getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single,
|
public <T> Subscription untilStop(@NonNull final Single<T> single,
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
@NonNull final Action1<T> onSuccessAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return until(single.toObservable(), isStartedSubject.map(started -> !started)
|
return untilStop(single.toObservable(), onSuccessAction, onErrorAction, Actions.empty());
|
||||||
.delay(item -> isInAfterSaving.filter(inAfterSaving -> !inAfterSaving)),
|
|
||||||
onSuccessAction, onErrorAction, Functions.EMPTY_ACTION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable) {
|
public Subscription untilStop(@NonNull final Completable completable) {
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
final String codePoint = Lc.getCodePoint(this, 2);
|
||||||
return untilStop(completable, Functions.EMPTY_ACTION, getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD));
|
return untilStop(completable, Actions.empty(), getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable,
|
public Subscription untilStop(@NonNull final Completable completable,
|
||||||
@NonNull final Action onCompletedAction) {
|
@NonNull final Action0 onCompletedAction) {
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
final String codePoint = Lc.getCodePoint(this, 2);
|
||||||
return untilStop(completable, onCompletedAction, getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD));
|
return untilStop(completable, onCompletedAction, getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable,
|
public Subscription untilStop(@NonNull final Completable completable,
|
||||||
@NonNull final Action onCompletedAction,
|
@NonNull final Action0 onCompletedAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return until(completable.toObservable(), isStartedSubject.map(started -> !started)
|
return untilStop(completable.toObservable(), Actions.empty(), onErrorAction, onCompletedAction);
|
||||||
.delay(item -> isInAfterSaving.filter(inAfterSaving -> !inAfterSaving)),
|
|
||||||
Functions.emptyConsumer(), onErrorAction, onCompletedAction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe) {
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable) {
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
final String codePoint = Lc.getCodePoint(this, 2);
|
||||||
return untilStop(maybe, Functions.emptyConsumer(), getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD));
|
return untilDestroy(observable, Actions.empty(), getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD), Actions.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable,
|
||||||
|
@NonNull final Action1<T> onNextAction) {
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
final String codePoint = Lc.getCodePoint(this, 2);
|
||||||
return untilStop(maybe, onSuccessAction, getActionThrowableForAssertion(codePoint, UNTIL_STOP_METHOD));
|
return untilDestroy(observable, onNextAction, getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD), Actions.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe,
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return until(maybe.toObservable(), isStartedSubject.map(started -> !started), onSuccessAction, onErrorAction, Functions.EMPTY_ACTION);
|
return untilDestroy(observable, onNextAction, onErrorAction, Actions.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable) {
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable,
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
@NonNull final Action1<T> onNextAction,
|
||||||
return untilDestroy(observable, Functions.emptyConsumer(),
|
@NonNull final Action1<Throwable> onErrorAction,
|
||||||
getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD), Functions.EMPTY_ACTION);
|
@NonNull final Action0 onCompletedAction) {
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable,
|
|
||||||
@NonNull final Consumer<T> onNextAction) {
|
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
|
||||||
return untilDestroy(observable, onNextAction, getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD), Functions.EMPTY_ACTION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable,
|
|
||||||
@NonNull final Consumer<T> onNextAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
|
||||||
return untilDestroy(observable, onNextAction, onErrorAction, Functions.EMPTY_ACTION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable,
|
|
||||||
@NonNull final Consumer<T> onNextAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction,
|
|
||||||
@NonNull final Action onCompletedAction) {
|
|
||||||
return until(observable, isCreatedSubject.map(created -> !created), onNextAction, onErrorAction, onCompletedAction);
|
return until(observable, isCreatedSubject.map(created -> !created), onNextAction, onErrorAction, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single) {
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single) {
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
final String codePoint = Lc.getCodePoint(this, 2);
|
||||||
return untilDestroy(single, Functions.emptyConsumer(), getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD));
|
return untilDestroy(single, Actions.empty(), getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
final String codePoint = Lc.getCodePoint(this, 2);
|
||||||
return untilDestroy(single, onSuccessAction, getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD));
|
return untilDestroy(single, onSuccessAction, getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single,
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single,
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
@NonNull final Action1<T> onSuccessAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return until(single.toObservable(), isCreatedSubject.map(created -> !created), onSuccessAction, onErrorAction, Functions.EMPTY_ACTION);
|
return until(single.toObservable(), isCreatedSubject.map(created -> !created), onSuccessAction, onErrorAction, Actions.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable) {
|
public Subscription untilDestroy(@NonNull final Completable completable) {
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
final String codePoint = Lc.getCodePoint(this, 2);
|
||||||
return untilDestroy(completable, Functions.EMPTY_ACTION, getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD));
|
return untilDestroy(completable, Actions.empty(), getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable, @NonNull final Action onCompletedAction) {
|
public Subscription untilDestroy(@NonNull final Completable completable, @NonNull final Action0 onCompletedAction) {
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
final String codePoint = Lc.getCodePoint(this, 2);
|
||||||
return untilDestroy(completable, onCompletedAction, getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD));
|
return untilDestroy(completable, onCompletedAction, getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable,
|
public Subscription untilDestroy(@NonNull final Completable completable,
|
||||||
@NonNull final Action onCompletedAction,
|
@NonNull final Action0 onCompletedAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return until(completable.toObservable(), isCreatedSubject.map(created -> !created),
|
return until(completable.toObservable(), isCreatedSubject.map(created -> !created), Actions.empty(), onErrorAction, onCompletedAction);
|
||||||
Functions.emptyConsumer(), onErrorAction, onCompletedAction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
private <T> Subscription until(@NonNull final Observable<T> observable,
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe) {
|
@NonNull final Observable<Boolean> conditionSubject,
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
@NonNull final Action1<T> onNextAction,
|
||||||
return untilDestroy(maybe, Functions.emptyConsumer(), getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD));
|
@NonNull final Action1<Throwable> onErrorAction,
|
||||||
}
|
@NonNull final Action0 onCompletedAction) {
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe, @NonNull final Consumer<T> onSuccessAction) {
|
|
||||||
final String codePoint = Lc.getCodePoint(this, 2);
|
|
||||||
return untilDestroy(maybe, onSuccessAction, getActionThrowableForAssertion(codePoint, UNTIL_DESTROY_METHOD));
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe,
|
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
|
||||||
return until(maybe.toObservable(), isCreatedSubject.map(created -> !created), onSuccessAction, onErrorAction, Functions.EMPTY_ACTION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private <T> Disposable until(@NonNull final Observable<T> observable,
|
|
||||||
@NonNull final Observable<Boolean> conditionSubject,
|
|
||||||
@NonNull final Consumer<T> onNextAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction,
|
|
||||||
@NonNull final Action onCompletedAction) {
|
|
||||||
final Observable<T> actualObservable;
|
final Observable<T> actualObservable;
|
||||||
if (onNextAction == Functions.emptyConsumer() && onErrorAction == (Consumer) Functions.emptyConsumer()
|
if (onNextAction == Actions.empty() && onErrorAction == (Action1) Actions.empty() && onCompletedAction == Actions.empty()) {
|
||||||
&& onCompletedAction == Functions.EMPTY_ACTION) {
|
|
||||||
actualObservable = observable;
|
actualObservable = observable;
|
||||||
} else {
|
} else {
|
||||||
actualObservable = observable.observeOn(AndroidSchedulers.mainThread())
|
actualObservable = observable.observeOn(AndroidSchedulers.mainThread())
|
||||||
.doOnComplete(onCompletedAction)
|
.doOnCompleted(onCompletedAction)
|
||||||
.doOnNext(onNextAction)
|
.doOnNext(onNextAction)
|
||||||
.doOnError(onErrorAction);
|
.doOnError(onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
return isCreatedSubject.firstOrError()
|
return isCreatedSubject.first()
|
||||||
.flatMapObservable(created -> created ? actualObservable : Observable.empty())
|
.switchMap(created -> created ? actualObservable : Observable.empty())
|
||||||
.takeUntil(conditionSubject.filter(condition -> condition))
|
.takeUntil(conditionSubject.filter(condition -> condition))
|
||||||
.onErrorResumeNext(throwable -> {
|
.onErrorResumeNext(throwable -> {
|
||||||
if (throwable instanceof RuntimeException) {
|
final boolean isRxError = throwable instanceof OnErrorThrowable;
|
||||||
|
if ((!isRxError && throwable instanceof RuntimeException)
|
||||||
|
|| (isRxError && throwable.getCause() instanceof RuntimeException)) {
|
||||||
Lc.assertion(throwable);
|
Lc.assertion(throwable);
|
||||||
}
|
}
|
||||||
return Observable.empty();
|
return Observable.empty();
|
||||||
|
|
@ -329,7 +280,7 @@ public class BaseLifecycleBindable implements LifecycleBindable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private Consumer<Throwable> getActionThrowableForAssertion(@NonNull final String codePoint, @NonNull final String method) {
|
private Action1<Throwable> getActionThrowableForAssertion(@NonNull final String codePoint, @NonNull final String method) {
|
||||||
return throwable -> Lc.assertion(new ShouldNotHappenException("Unexpected error on " + method + " at " + codePoint, throwable));
|
return throwable -> Lc.assertion(new ShouldNotHappenException("Unexpected error on " + method + " at " + codePoint, throwable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,17 +21,15 @@ package ru.touchin.roboswag.components.utils;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import io.reactivex.Completable;
|
import rx.Completable;
|
||||||
import io.reactivex.CompletableEmitter;
|
import rx.CompletableSubscriber;
|
||||||
import io.reactivex.Emitter;
|
import rx.Observable;
|
||||||
import io.reactivex.Maybe;
|
import rx.Single;
|
||||||
import io.reactivex.MaybeEmitter;
|
import rx.SingleSubscriber;
|
||||||
import io.reactivex.Observable;
|
import rx.Subscriber;
|
||||||
import io.reactivex.Single;
|
import rx.Subscription;
|
||||||
import io.reactivex.SingleEmitter;
|
import rx.functions.Action0;
|
||||||
import io.reactivex.disposables.Disposable;
|
import rx.functions.Action1;
|
||||||
import io.reactivex.functions.Action;
|
|
||||||
import io.reactivex.functions.Consumer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 15/04/16.
|
* Created by Gavriil Sitnikov on 15/04/16.
|
||||||
|
|
@ -51,10 +49,10 @@ public interface LifecycleBindable {
|
||||||
*
|
*
|
||||||
* @param observable {@link Observable} to subscribe until onStop;
|
* @param observable {@link Observable} to subscribe until onStop;
|
||||||
* @param <T> Type of emitted by observable items;
|
* @param <T> Type of emitted by observable items;
|
||||||
* @return {@link Disposable} which will unsubscribes from observable onStop.
|
* @return {@link Subscription} which will unsubscribes from observable onStop.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilStop(@NonNull Observable<T> observable);
|
<T> Subscription untilStop(@NonNull Observable<T> observable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that observable won't be subscribed after onStop.
|
* Method should be used to guarantee that observable won't be subscribed after onStop.
|
||||||
|
|
@ -63,12 +61,12 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if observable can emit them.
|
* Don't forget to process errors if observable can emit them.
|
||||||
*
|
*
|
||||||
* @param observable {@link Observable} to subscribe until onStop;
|
* @param observable {@link Observable} to subscribe until onStop;
|
||||||
* @param onNextAction Action which will raise on every {@link Emitter#onNext(Object)} item;
|
* @param onNextAction Action which will raise on every {@link Subscriber#onNext(Object)} item;
|
||||||
* @param <T> Type of emitted by observable items;
|
* @param <T> Type of emitted by observable items;
|
||||||
* @return {@link Disposable} which will unsubscribes from observable onStop.
|
* @return {@link Subscription} which will unsubscribes from observable onStop.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilStop(@NonNull Observable<T> observable, @NonNull Consumer<T> onNextAction);
|
<T> Subscription untilStop(@NonNull Observable<T> observable, @NonNull Action1<T> onNextAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that observable won't be subscribed after onStop.
|
* Method should be used to guarantee that observable won't be subscribed after onStop.
|
||||||
|
|
@ -77,13 +75,13 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if observable can emit them.
|
* Don't forget to process errors if observable can emit them.
|
||||||
*
|
*
|
||||||
* @param observable {@link Observable} to subscribe until onStop;
|
* @param observable {@link Observable} to subscribe until onStop;
|
||||||
* @param onNextAction Action which will raise on every {@link Emitter#onNext(Object)} item;
|
* @param onNextAction Action which will raise on every {@link Subscriber#onNext(Object)} item;
|
||||||
* @param onErrorAction Action which will raise on every {@link Emitter#onError(Throwable)} throwable;
|
* @param onErrorAction Action which will raise on every {@link Subscriber#onError(Throwable)} throwable;
|
||||||
* @param <T> Type of emitted by observable items;
|
* @param <T> Type of emitted by observable items;
|
||||||
* @return {@link Disposable} which will unsubscribes from observable onStop.
|
* @return {@link Subscription} which will unsubscribes from observable onStop.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilStop(@NonNull Observable<T> observable, @NonNull Consumer<T> onNextAction, @NonNull Consumer<Throwable> onErrorAction);
|
<T> Subscription untilStop(@NonNull Observable<T> observable, @NonNull Action1<T> onNextAction, @NonNull Action1<Throwable> onErrorAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that observable won't be subscribed after onStop.
|
* Method should be used to guarantee that observable won't be subscribed after onStop.
|
||||||
|
|
@ -92,15 +90,15 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if observable can emit them.
|
* Don't forget to process errors if observable can emit them.
|
||||||
*
|
*
|
||||||
* @param observable {@link Observable} to subscribe until onStop;
|
* @param observable {@link Observable} to subscribe until onStop;
|
||||||
* @param onNextAction Action which will raise on every {@link Emitter#onNext(Object)} item;
|
* @param onNextAction Action which will raise on every {@link Subscriber#onNext(Object)} item;
|
||||||
* @param onErrorAction Action which will raise on every {@link Emitter#onError(Throwable)} throwable;
|
* @param onErrorAction Action which will raise on every {@link Subscriber#onError(Throwable)} throwable;
|
||||||
* @param onCompletedAction Action which will raise at {@link Emitter#onComplete()} on completion of observable;
|
* @param onCompletedAction Action which will raise at {@link Subscriber#onCompleted()} on completion of observable;
|
||||||
* @param <T> Type of emitted by observable items;
|
* @param <T> Type of emitted by observable items;
|
||||||
* @return {@link Disposable} which is wrapping source observable to unsubscribe from it onStop.
|
* @return {@link Subscription} which is wrapping source observable to unsubscribe from it onStop.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilStop(@NonNull Observable<T> observable,
|
<T> Subscription untilStop(@NonNull Observable<T> observable,
|
||||||
@NonNull Consumer<T> onNextAction, @NonNull Consumer<Throwable> onErrorAction, @NonNull Action onCompletedAction);
|
@NonNull Action1<T> onNextAction, @NonNull Action1<Throwable> onErrorAction, @NonNull Action0 onCompletedAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that single won't be subscribed after onStop.
|
* Method should be used to guarantee that single won't be subscribed after onStop.
|
||||||
|
|
@ -110,10 +108,10 @@ public interface LifecycleBindable {
|
||||||
*
|
*
|
||||||
* @param single {@link Single} to subscribe until onStop;
|
* @param single {@link Single} to subscribe until onStop;
|
||||||
* @param <T> Type of emitted by single item;
|
* @param <T> Type of emitted by single item;
|
||||||
* @return {@link Disposable} which will unsubscribes from single onStop.
|
* @return {@link Subscription} which will unsubscribes from single onStop.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilStop(@NonNull Single<T> single);
|
<T> Subscription untilStop(@NonNull Single<T> single);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that single won't be subscribed after onStop.
|
* Method should be used to guarantee that single won't be subscribed after onStop.
|
||||||
|
|
@ -122,12 +120,12 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if single can emit them.
|
* Don't forget to process errors if single can emit them.
|
||||||
*
|
*
|
||||||
* @param single {@link Single} to subscribe until onStop;
|
* @param single {@link Single} to subscribe until onStop;
|
||||||
* @param onSuccessAction Action which will raise on every {@link SingleEmitter#onSuccess(Object)} item;
|
* @param onSuccessAction Action which will raise on every {@link SingleSubscriber#onSuccess(Object)} item;
|
||||||
* @param <T> Type of emitted by single item;
|
* @param <T> Type of emitted by single item;
|
||||||
* @return {@link Disposable} which will unsubscribes from single onStop.
|
* @return {@link Subscription} which will unsubscribes from single onStop.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilStop(@NonNull Single<T> single, @NonNull Consumer<T> onSuccessAction);
|
<T> Subscription untilStop(@NonNull Single<T> single, @NonNull Action1<T> onSuccessAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that single won't be subscribed after onStop.
|
* Method should be used to guarantee that single won't be subscribed after onStop.
|
||||||
|
|
@ -136,13 +134,13 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if single can emit them.
|
* Don't forget to process errors if single can emit them.
|
||||||
*
|
*
|
||||||
* @param single {@link Single} to subscribe until onStop;
|
* @param single {@link Single} to subscribe until onStop;
|
||||||
* @param onSuccessAction Action which will raise on every {@link SingleEmitter#onSuccess(Object)} item;
|
* @param onSuccessAction Action which will raise on every {@link SingleSubscriber#onSuccess(Object)} item;
|
||||||
* @param onErrorAction Action which will raise on every {@link SingleEmitter#onError(Throwable)} throwable;
|
* @param onErrorAction Action which will raise on every {@link SingleSubscriber#onError(Throwable)} throwable;
|
||||||
* @param <T> Type of emitted by observable items;
|
* @param <T> Type of emitted by observable items;
|
||||||
* @return {@link Disposable} which is wrapping source single to unsubscribe from it onStop.
|
* @return {@link Subscription} which is wrapping source single to unsubscribe from it onStop.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilStop(@NonNull Single<T> single, @NonNull Consumer<T> onSuccessAction, @NonNull Consumer<Throwable> onErrorAction);
|
<T> Subscription untilStop(@NonNull Single<T> single, @NonNull Action1<T> onSuccessAction, @NonNull Action1<Throwable> onErrorAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that completable won't be subscribed after onStop.
|
* Method should be used to guarantee that completable won't be subscribed after onStop.
|
||||||
|
|
@ -151,10 +149,10 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if completable can emit them.
|
* Don't forget to process errors if completable can emit them.
|
||||||
*
|
*
|
||||||
* @param completable {@link Completable} to subscribe until onStop;
|
* @param completable {@link Completable} to subscribe until onStop;
|
||||||
* @return {@link Disposable} which will unsubscribes from completable onStop.
|
* @return {@link Subscription} which will unsubscribes from completable onStop.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
Disposable untilStop(@NonNull Completable completable);
|
Subscription untilStop(@NonNull Completable completable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that completable won't be subscribed after onStop.
|
* Method should be used to guarantee that completable won't be subscribed after onStop.
|
||||||
|
|
@ -163,11 +161,11 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if completable can emit them.
|
* Don't forget to process errors if completable can emit them.
|
||||||
*
|
*
|
||||||
* @param completable {@link Completable} to subscribe until onStop;
|
* @param completable {@link Completable} to subscribe until onStop;
|
||||||
* @param onCompletedAction Action which will raise at {@link CompletableEmitter#onComplete()} on completion of observable;
|
* @param onCompletedAction Action which will raise at {@link CompletableSubscriber#onCompleted()} on completion of observable;
|
||||||
* @return {@link Disposable} which is wrapping source completable to unsubscribe from it onStop.
|
* @return {@link Subscription} which is wrapping source completable to unsubscribe from it onStop.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
Disposable untilStop(@NonNull Completable completable, @NonNull Action onCompletedAction);
|
Subscription untilStop(@NonNull Completable completable, @NonNull Action0 onCompletedAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that completable won't be subscribed after onStop.
|
* Method should be used to guarantee that completable won't be subscribed after onStop.
|
||||||
|
|
@ -176,51 +174,12 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if completable can emit them.
|
* Don't forget to process errors if completable can emit them.
|
||||||
*
|
*
|
||||||
* @param completable {@link Completable} to subscribe until onStop;
|
* @param completable {@link Completable} to subscribe until onStop;
|
||||||
* @param onCompletedAction Action which will raise at {@link CompletableEmitter#onComplete()} on completion of observable;
|
* @param onCompletedAction Action which will raise at {@link CompletableSubscriber#onCompleted()} on completion of observable;
|
||||||
* @param onErrorAction Action which will raise on every {@link CompletableEmitter#onError(Throwable)} throwable;
|
* @param onErrorAction Action which will raise on every {@link CompletableSubscriber#onError(Throwable)} throwable;
|
||||||
* @return {@link Disposable} which is wrapping source completable to unsubscribe from it onStop.
|
* @return {@link Subscription} which is wrapping source completable to unsubscribe from it onStop.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
Disposable untilStop(@NonNull Completable completable, @NonNull Action onCompletedAction, @NonNull Consumer<Throwable> onErrorAction);
|
Subscription untilStop(@NonNull Completable completable, @NonNull Action0 onCompletedAction, @NonNull Action1<Throwable> onErrorAction);
|
||||||
|
|
||||||
/**
|
|
||||||
* Method should be used to guarantee that maybe won't be subscribed after onStop.
|
|
||||||
* It is automatically subscribing to the maybe.
|
|
||||||
* Usually it is using to stop requests/execution while element is off or to not do illegal actions after onStop like fragment's stack changing.
|
|
||||||
* Don't forget to process errors if completable can emit them.
|
|
||||||
*
|
|
||||||
* @param maybe {@link Maybe} to subscribe until onStop;
|
|
||||||
* @return {@link Disposable} which will unsubscribes from completable onStop.
|
|
||||||
*/
|
|
||||||
@NonNull
|
|
||||||
<T> Disposable untilStop(@NonNull Maybe<T> maybe);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method should be used to guarantee that maybe won't be subscribed after onStop.
|
|
||||||
* It is automatically subscribing to the maybe and calls onCompletedAction on maybe item.
|
|
||||||
* Usually it is using to stop requests/execution while element is off or to not do illegal actions after onStop like fragment's stack changing.
|
|
||||||
* Don't forget to process errors if completable can emit them.
|
|
||||||
*
|
|
||||||
* @param maybe {@link Maybe} to subscribe until onStop;
|
|
||||||
* @param onSuccessAction Action which will raise at {@link MaybeEmitter#onSuccess(Object)} ()} on completion of observable;
|
|
||||||
* @return {@link Disposable} which is wrapping source maybe to unsubscribe from it onStop.
|
|
||||||
*/
|
|
||||||
@NonNull
|
|
||||||
<T> Disposable untilStop(@NonNull Maybe<T> maybe, @NonNull Consumer<T> onSuccessAction);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method should be used to guarantee that maybe won't be subscribed after onStop.
|
|
||||||
* It is automatically subscribing to the maybe and calls onCompletedAction and onErrorAction on maybe item.
|
|
||||||
* Usually it is using to stop requests/execution while element is off or to not do illegal actions after onStop like fragment's stack changing.
|
|
||||||
* Don't forget to process errors if completable can emit them.
|
|
||||||
*
|
|
||||||
* @param maybe {@link Maybe} to subscribe until onStop;
|
|
||||||
* @param onSuccessAction Action which will raise at {@link MaybeEmitter#onSuccess(Object)} ()} on completion of observable;
|
|
||||||
* @param onErrorAction Action which will raise on every {@link MaybeEmitter#onError(Throwable)} throwable;
|
|
||||||
* @return {@link Disposable} which is wrapping source maybe to unsubscribe from it onStop.
|
|
||||||
*/
|
|
||||||
@NonNull
|
|
||||||
<T> Disposable untilStop(@NonNull Maybe<T> maybe, @NonNull Consumer<T> onSuccessAction, @NonNull Consumer<Throwable> onErrorAction);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that observable won't be subscribed after onDestroy.
|
* Method should be used to guarantee that observable won't be subscribed after onDestroy.
|
||||||
|
|
@ -229,10 +188,10 @@ public interface LifecycleBindable {
|
||||||
*
|
*
|
||||||
* @param observable {@link Observable} to subscribe until onDestroy;
|
* @param observable {@link Observable} to subscribe until onDestroy;
|
||||||
* @param <T> Type of emitted by observable items;
|
* @param <T> Type of emitted by observable items;
|
||||||
* @return {@link Disposable} which is wrapping source maybe to unsubscribe from it onDestroy.
|
* @return {@link Subscription} which is wrapping source observable to unsubscribe from it onDestroy.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilDestroy(@NonNull Observable<T> observable);
|
<T> Subscription untilDestroy(@NonNull Observable<T> observable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that observable won't be subscribed after onDestroy.
|
* Method should be used to guarantee that observable won't be subscribed after onDestroy.
|
||||||
|
|
@ -240,12 +199,12 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if observable can emit them.
|
* Don't forget to process errors if observable can emit them.
|
||||||
*
|
*
|
||||||
* @param observable {@link Observable} to subscribe until onDestroy;
|
* @param observable {@link Observable} to subscribe until onDestroy;
|
||||||
* @param onNextAction Action which will raise on every {@link Emitter#onNext(Object)} item;
|
* @param onNextAction Action which will raise on every {@link Subscriber#onNext(Object)} item;
|
||||||
* @param <T> Type of emitted by observable items;
|
* @param <T> Type of emitted by observable items;
|
||||||
* @return {@link Disposable} which is wrapping source observable to unsubscribe from it onDestroy.
|
* @return {@link Subscription} which is wrapping source observable to unsubscribe from it onDestroy.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilDestroy(@NonNull Observable<T> observable, @NonNull Consumer<T> onNextAction);
|
<T> Subscription untilDestroy(@NonNull Observable<T> observable, @NonNull Action1<T> onNextAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that observable won't be subscribed after onDestroy.
|
* Method should be used to guarantee that observable won't be subscribed after onDestroy.
|
||||||
|
|
@ -253,13 +212,13 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if observable can emit them.
|
* Don't forget to process errors if observable can emit them.
|
||||||
*
|
*
|
||||||
* @param observable {@link Observable} to subscribe until onDestroy;
|
* @param observable {@link Observable} to subscribe until onDestroy;
|
||||||
* @param onNextAction Action which will raise on every {@link Emitter#onNext(Object)} item;
|
* @param onNextAction Action which will raise on every {@link Subscriber#onNext(Object)} item;
|
||||||
* @param onErrorAction Action which will raise on every {@link Emitter#onError(Throwable)} throwable;
|
* @param onErrorAction Action which will raise on every {@link Subscriber#onError(Throwable)} throwable;
|
||||||
* @param <T> Type of emitted by observable items;
|
* @param <T> Type of emitted by observable items;
|
||||||
* @return {@link Disposable} which is wrapping source observable to unsubscribe from it onDestroy.
|
* @return {@link Subscription} which is wrapping source observable to unsubscribe from it onDestroy.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilDestroy(@NonNull Observable<T> observable, @NonNull Consumer<T> onNextAction, @NonNull Consumer<Throwable> onErrorAction);
|
<T> Subscription untilDestroy(@NonNull Observable<T> observable, @NonNull Action1<T> onNextAction, @NonNull Action1<Throwable> onErrorAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that observable won't be subscribed after onDestroy.
|
* Method should be used to guarantee that observable won't be subscribed after onDestroy.
|
||||||
|
|
@ -267,15 +226,15 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if observable can emit them.
|
* Don't forget to process errors if observable can emit them.
|
||||||
*
|
*
|
||||||
* @param observable {@link Observable} to subscribe until onDestroy;
|
* @param observable {@link Observable} to subscribe until onDestroy;
|
||||||
* @param onNextAction Action which will raise on every {@link Emitter#onNext(Object)} item;
|
* @param onNextAction Action which will raise on every {@link Subscriber#onNext(Object)} item;
|
||||||
* @param onErrorAction Action which will raise on every {@link Emitter#onError(Throwable)} throwable;
|
* @param onErrorAction Action which will raise on every {@link Subscriber#onError(Throwable)} throwable;
|
||||||
* @param onCompletedAction Action which will raise at {@link Emitter#onComplete()} on completion of observable;
|
* @param onCompletedAction Action which will raise at {@link Subscriber#onCompleted()} on completion of observable;
|
||||||
* @param <T> Type of emitted by observable items;
|
* @param <T> Type of emitted by observable items;
|
||||||
* @return {@link Disposable} which is wrapping source observable to unsubscribe from it onDestroy.
|
* @return {@link Subscription} which is wrapping source observable to unsubscribe from it onDestroy.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilDestroy(@NonNull Observable<T> observable,
|
<T> Subscription untilDestroy(@NonNull Observable<T> observable,
|
||||||
@NonNull Consumer<T> onNextAction, @NonNull Consumer<Throwable> onErrorAction, @NonNull Action onCompletedAction);
|
@NonNull Action1<T> onNextAction, @NonNull Action1<Throwable> onErrorAction, @NonNull Action0 onCompletedAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that single won't be subscribed after onDestroy.
|
* Method should be used to guarantee that single won't be subscribed after onDestroy.
|
||||||
|
|
@ -284,10 +243,10 @@ public interface LifecycleBindable {
|
||||||
*
|
*
|
||||||
* @param single {@link Single} to subscribe until onDestroy;
|
* @param single {@link Single} to subscribe until onDestroy;
|
||||||
* @param <T> Type of emitted by single items;
|
* @param <T> Type of emitted by single items;
|
||||||
* @return {@link Disposable} which is wrapping source single to unsubscribe from it onDestroy.
|
* @return {@link Subscription} which is wrapping source single to unsubscribe from it onDestroy.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilDestroy(@NonNull Single<T> single);
|
<T> Subscription untilDestroy(@NonNull Single<T> single);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that single won't be subscribed after onDestroy.
|
* Method should be used to guarantee that single won't be subscribed after onDestroy.
|
||||||
|
|
@ -295,12 +254,12 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if single can emit them.
|
* Don't forget to process errors if single can emit them.
|
||||||
*
|
*
|
||||||
* @param single {@link Single} to subscribe until onDestroy;
|
* @param single {@link Single} to subscribe until onDestroy;
|
||||||
* @param onSuccessAction Action which will raise on every {@link SingleEmitter#onSuccess(Object)} item;
|
* @param onSuccessAction Action which will raise on every {@link SingleSubscriber#onSuccess(Object)} item;
|
||||||
* @param <T> Type of emitted by single items;
|
* @param <T> Type of emitted by single items;
|
||||||
* @return {@link Disposable} which is wrapping source single to unsubscribe from it onDestroy.
|
* @return {@link Subscription} which is wrapping source single to unsubscribe from it onDestroy.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilDestroy(@NonNull Single<T> single, @NonNull Consumer<T> onSuccessAction);
|
<T> Subscription untilDestroy(@NonNull Single<T> single, @NonNull Action1<T> onSuccessAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that single won't be subscribed after onDestroy.
|
* Method should be used to guarantee that single won't be subscribed after onDestroy.
|
||||||
|
|
@ -308,13 +267,13 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if single can emit them.
|
* Don't forget to process errors if single can emit them.
|
||||||
*
|
*
|
||||||
* @param single {@link Single} to subscribe until onDestroy;
|
* @param single {@link Single} to subscribe until onDestroy;
|
||||||
* @param onSuccessAction Action which will raise on every {@link SingleEmitter#onSuccess(Object)} item;
|
* @param onSuccessAction Action which will raise on every {@link SingleSubscriber#onSuccess(Object)} item;
|
||||||
* @param onErrorAction Action which will raise on every {@link SingleEmitter#onError(Throwable)} throwable;
|
* @param onErrorAction Action which will raise on every {@link SingleSubscriber#onError(Throwable)} throwable;
|
||||||
* @param <T> Type of emitted by single items;
|
* @param <T> Type of emitted by single items;
|
||||||
* @return {@link Disposable} which is wrapping source single to unsubscribe from it onDestroy.
|
* @return {@link Subscription} which is wrapping source single to unsubscribe from it onDestroy.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
<T> Disposable untilDestroy(@NonNull Single<T> single, @NonNull Consumer<T> onSuccessAction, @NonNull Consumer<Throwable> onErrorAction);
|
<T> Subscription untilDestroy(@NonNull Single<T> single, @NonNull Action1<T> onSuccessAction, @NonNull Action1<Throwable> onErrorAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that completable won't be subscribed after onDestroy.
|
* Method should be used to guarantee that completable won't be subscribed after onDestroy.
|
||||||
|
|
@ -322,22 +281,22 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if completable can emit them.
|
* Don't forget to process errors if completable can emit them.
|
||||||
*
|
*
|
||||||
* @param completable {@link Completable} to subscribe until onDestroy;
|
* @param completable {@link Completable} to subscribe until onDestroy;
|
||||||
* @return {@link Disposable} which is wrapping source completable to unsubscribe from it onDestroy.
|
* @return {@link Subscription} which is wrapping source completable to unsubscribe from it onDestroy.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
Disposable untilDestroy(@NonNull Completable completable);
|
Subscription untilDestroy(@NonNull Completable completable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that completable won't be subscribed after onDestroy.
|
* Method should be used to guarantee that completable won't be subscribed after onDestroy.
|
||||||
* It is automatically subscribing to the completable and calls onCompletedAction on completable item.
|
* It is automatically subscribing to the completable and calls onCompletedAction on completable item.
|
||||||
* Don't forget to process errors if completable can emit them.
|
* Don't forget to process errors if single can emit them.
|
||||||
*
|
*
|
||||||
* @param completable {@link Completable} to subscribe until onDestroy;
|
* @param completable {@link Completable} to subscribe until onDestroy;
|
||||||
* @param onCompletedAction Action which will raise on every {@link CompletableEmitter#onComplete()} item;
|
* @param onCompletedAction Action which will raise on every {@link CompletableSubscriber#onCompleted()} item;
|
||||||
* @return {@link Disposable} which is wrapping source single to unsubscribe from it onDestroy.
|
* @return {@link Subscription} which is wrapping source single to unsubscribe from it onDestroy.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
Disposable untilDestroy(@NonNull Completable completable, @NonNull Action onCompletedAction);
|
Subscription untilDestroy(@NonNull Completable completable, @NonNull Action0 onCompletedAction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method should be used to guarantee that completable won't be subscribed after onDestroy.
|
* Method should be used to guarantee that completable won't be subscribed after onDestroy.
|
||||||
|
|
@ -345,47 +304,11 @@ public interface LifecycleBindable {
|
||||||
* Don't forget to process errors if completable can emit them.
|
* Don't forget to process errors if completable can emit them.
|
||||||
*
|
*
|
||||||
* @param completable {@link Completable} to subscribe until onDestroy;
|
* @param completable {@link Completable} to subscribe until onDestroy;
|
||||||
* @param onCompletedAction Action which will raise on every {@link CompletableEmitter#onComplete()} item;
|
* @param onCompletedAction Action which will raise on every {@link CompletableSubscriber#onCompleted()} item;
|
||||||
* @param onErrorAction Action which will raise on every {@link CompletableEmitter#onError(Throwable)} throwable;
|
* @param onErrorAction Action which will raise on every {@link CompletableSubscriber#onError(Throwable)} throwable;
|
||||||
* @return {@link Disposable} which is wrapping source completable to unsubscribe from it onDestroy.
|
* @return {@link Subscription} which is wrapping source completable to unsubscribe from it onDestroy.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
@NonNull
|
||||||
Disposable untilDestroy(@NonNull Completable completable, @NonNull Action onCompletedAction, @NonNull Consumer<Throwable> onErrorAction);
|
Subscription untilDestroy(@NonNull Completable completable, @NonNull Action0 onCompletedAction, @NonNull Action1<Throwable> onErrorAction);
|
||||||
|
|
||||||
/**
|
|
||||||
* Method should be used to guarantee that maybe won't be subscribed after onDestroy.
|
|
||||||
* It is automatically subscribing to the maybe.
|
|
||||||
* Don't forget to process errors if maybe can emit them.
|
|
||||||
*
|
|
||||||
* @param maybe {@link Maybe} to subscribe until onDestroy;
|
|
||||||
* @return {@link Disposable} which is wrapping source maybe to unsubscribe from it onDestroy.
|
|
||||||
*/
|
|
||||||
@NonNull
|
|
||||||
<T> Disposable untilDestroy(@NonNull Maybe<T> maybe);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method should be used to guarantee that maybe won't be subscribed after onDestroy.
|
|
||||||
* It is automatically subscribing to the maybe and calls onCompletedAction on maybe item.
|
|
||||||
* Don't forget to process errors if maybe can emit them.
|
|
||||||
*
|
|
||||||
* @param maybe {@link Maybe} to subscribe until onDestroy;
|
|
||||||
* @param onSuccessAction Action which will raise on every {@link MaybeEmitter#onSuccess(Object)} ()} item;
|
|
||||||
* @return {@link Disposable} which is wrapping source maybe to unsubscribe from it onDestroy.
|
|
||||||
*/
|
|
||||||
@NonNull
|
|
||||||
<T> Disposable untilDestroy(@NonNull Maybe<T> maybe, @NonNull Consumer<T> onSuccessAction);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method should be used to guarantee that maybe won't be subscribed after onDestroy.
|
|
||||||
* It is automatically subscribing to the maybe and calls onSuccessAction and onErrorAction on maybe events.
|
|
||||||
* Don't forget to process errors if completable can emit them.
|
|
||||||
*
|
|
||||||
* @param maybe {@link Maybe} to subscribe until onDestroy;
|
|
||||||
* @param onSuccessAction Action which will raise on every {@link MaybeEmitter#onSuccess(Object)} ()} item;
|
|
||||||
* @param onErrorAction Action which will raise on every {@link MaybeEmitter#onError(Throwable)} throwable;
|
|
||||||
* @return {@link Disposable} which is wrapping source maybe to unsubscribe from it onDestroy.
|
|
||||||
*/
|
|
||||||
@NonNull
|
|
||||||
<T> Disposable untilDestroy(@NonNull Maybe<T> maybe, @NonNull Consumer<T> onSuccessAction, @NonNull Consumer<Throwable> onErrorAction);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -27,8 +27,8 @@ import java.lang.reflect.Constructor;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
||||||
|
import rx.Observable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 24/03/16.
|
* Created by Gavriil Sitnikov on 24/03/16.
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,9 @@ import android.view.ViewGroup;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import io.reactivex.functions.Action;
|
|
||||||
import io.reactivex.functions.Consumer;
|
|
||||||
import ru.touchin.roboswag.components.navigation.activities.BaseActivity;
|
import ru.touchin.roboswag.components.navigation.activities.BaseActivity;
|
||||||
import ru.touchin.roboswag.core.log.Lc;
|
|
||||||
import ru.touchin.roboswag.core.log.LcGroup;
|
import ru.touchin.roboswag.core.log.LcGroup;
|
||||||
|
import rx.functions.Action0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 13/11/2015.
|
* Created by Gavriil Sitnikov on 13/11/2015.
|
||||||
|
|
@ -102,8 +100,8 @@ public final class UiUtils {
|
||||||
* @param onClickListener Click listener;
|
* @param onClickListener Click listener;
|
||||||
* @param delay Delay after which click listener will be called.
|
* @param delay Delay after which click listener will be called.
|
||||||
*/
|
*/
|
||||||
public static void setOnRippleClickListener(@NonNull final View targetView, @Nullable final Action onClickListener, final long delay) {
|
public static void setOnRippleClickListener(@NonNull final View targetView, @Nullable final Action0 onClickListener, final long delay) {
|
||||||
setOnRippleClickListener(targetView, onClickListener != null ? view -> onClickListener.run() : null, delay);
|
setOnRippleClickListener(targetView, onClickListener != null ? v -> onClickListener.call() : null, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -112,8 +110,18 @@ public final class UiUtils {
|
||||||
* @param targetView View to set click listener to;
|
* @param targetView View to set click listener to;
|
||||||
* @param onClickListener Click listener.
|
* @param onClickListener Click listener.
|
||||||
*/
|
*/
|
||||||
public static void setOnRippleClickListener(@NonNull final View targetView, @Nullable final Action onClickListener) {
|
public static void setOnRippleClickListener(@NonNull final View targetView, @Nullable final Action0 onClickListener) {
|
||||||
setOnRippleClickListener(targetView, onClickListener != null ? view -> onClickListener.run() : null, RIPPLE_EFFECT_DELAY);
|
setOnRippleClickListener(targetView, onClickListener != null ? v -> onClickListener.call() : null, RIPPLE_EFFECT_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets click listener to view. On click it will call something with {@link #RIPPLE_EFFECT_DELAY}.
|
||||||
|
*
|
||||||
|
* @param targetView View to set click listener to;
|
||||||
|
* @param onClickListener Click listener.
|
||||||
|
*/
|
||||||
|
public static void setOnRippleClickListener(@NonNull final View targetView, @Nullable final View.OnClickListener onClickListener) {
|
||||||
|
setOnRippleClickListener(targetView, onClickListener, RIPPLE_EFFECT_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -123,7 +131,9 @@ public final class UiUtils {
|
||||||
* @param onClickListener Click listener;
|
* @param onClickListener Click listener;
|
||||||
* @param delay Delay after which click listener will be called.
|
* @param delay Delay after which click listener will be called.
|
||||||
*/
|
*/
|
||||||
public static void setOnRippleClickListener(@NonNull final View targetView, @Nullable final Consumer<View> onClickListener, final long delay) {
|
public static void setOnRippleClickListener(@NonNull final View targetView,
|
||||||
|
@Nullable final View.OnClickListener onClickListener,
|
||||||
|
final long delay) {
|
||||||
if (onClickListener == null) {
|
if (onClickListener == null) {
|
||||||
targetView.setOnClickListener(null);
|
targetView.setOnClickListener(null);
|
||||||
return;
|
return;
|
||||||
|
|
@ -135,11 +145,7 @@ public final class UiUtils {
|
||||||
|| (targetView.getContext() instanceof BaseActivity && !((BaseActivity) targetView.getContext()).isActuallyResumed())) {
|
|| (targetView.getContext() instanceof BaseActivity && !((BaseActivity) targetView.getContext()).isActuallyResumed())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
onClickListener.onClick(targetView);
|
||||||
onClickListener.accept(targetView);
|
|
||||||
} catch (final Exception exception) {
|
|
||||||
Lc.assertion(exception);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
targetView.setOnClickListener(v -> {
|
targetView.setOnClickListener(v -> {
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ import android.content.IntentFilter;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
import rx.Observable;
|
||||||
import io.reactivex.subjects.BehaviorSubject;
|
import rx.subjects.BehaviorSubject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 02/11/2015.
|
* Created by Gavriil Sitnikov on 02/11/2015.
|
||||||
|
|
@ -50,12 +50,12 @@ public final class HeadsetStateObserver {
|
||||||
isConnectedReceiver.isWirelessConnectedChangedEvent,
|
isConnectedReceiver.isWirelessConnectedChangedEvent,
|
||||||
(isWiredConnected, isWirelessConnected) -> isWiredConnected || isWirelessConnected)
|
(isWiredConnected, isWirelessConnected) -> isWiredConnected || isWirelessConnected)
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.doOnSubscribe(disposable -> {
|
.doOnSubscribe(() -> {
|
||||||
final IntentFilter headsetStateIntentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
|
final IntentFilter headsetStateIntentFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
|
||||||
headsetStateIntentFilter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
|
headsetStateIntentFilter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
|
||||||
context.registerReceiver(isConnectedReceiver, headsetStateIntentFilter);
|
context.registerReceiver(isConnectedReceiver, headsetStateIntentFilter);
|
||||||
})
|
})
|
||||||
.doOnDispose(() -> context.unregisterReceiver(isConnectedReceiver)))
|
.doOnUnsubscribe(() -> context.unregisterReceiver(isConnectedReceiver)))
|
||||||
.replay(1)
|
.replay(1)
|
||||||
.refCount();
|
.refCount();
|
||||||
}
|
}
|
||||||
|
|
@ -90,8 +90,8 @@ public final class HeadsetStateObserver {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public IsConnectedReceiver(@NonNull final AudioManager audioManager) {
|
public IsConnectedReceiver(@NonNull final AudioManager audioManager) {
|
||||||
super();
|
super();
|
||||||
isWiredConnectedChangedEvent = BehaviorSubject.createDefault(audioManager.isWiredHeadsetOn());
|
isWiredConnectedChangedEvent = BehaviorSubject.create(audioManager.isWiredHeadsetOn());
|
||||||
isWirelessConnectedChangedEvent = BehaviorSubject.createDefault(audioManager.isBluetoothA2dpOn());
|
isWirelessConnectedChangedEvent = BehaviorSubject.create(audioManager.isBluetoothA2dpOn());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,10 @@ import android.os.Looper;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.subjects.PublishSubject;
|
|
||||||
import ru.touchin.roboswag.core.log.Lc;
|
import ru.touchin.roboswag.core.log.Lc;
|
||||||
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
import ru.touchin.roboswag.core.utils.ShouldNotHappenException;
|
||||||
|
import rx.Observable;
|
||||||
|
import rx.subjects.PublishSubject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 02/11/2015.
|
* Created by Gavriil Sitnikov on 02/11/2015.
|
||||||
|
|
@ -58,9 +58,9 @@ public final class VolumeController {
|
||||||
.switchMap(volumeObserver -> selfVolumeChangedEvent
|
.switchMap(volumeObserver -> selfVolumeChangedEvent
|
||||||
.mergeWith(volumeObserver.systemVolumeChangedEvent
|
.mergeWith(volumeObserver.systemVolumeChangedEvent
|
||||||
.map(event -> getVolume())
|
.map(event -> getVolume())
|
||||||
.doOnSubscribe(disposable -> context.getContentResolver()
|
.doOnSubscribe(() -> context.getContentResolver()
|
||||||
.registerContentObserver(Settings.System.CONTENT_URI, true, volumeObserver))
|
.registerContentObserver(Settings.System.CONTENT_URI, true, volumeObserver))
|
||||||
.doOnDispose(() -> context.getContentResolver()
|
.doOnUnsubscribe(() -> context.getContentResolver()
|
||||||
.unregisterContentObserver(volumeObserver)))
|
.unregisterContentObserver(volumeObserver)))
|
||||||
.startWith(getVolume()))
|
.startWith(getVolume()))
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ import java.lang.reflect.Type;
|
||||||
import ru.touchin.roboswag.core.log.Lc;
|
import ru.touchin.roboswag.core.log.Lc;
|
||||||
import ru.touchin.roboswag.core.observables.storable.Store;
|
import ru.touchin.roboswag.core.observables.storable.Store;
|
||||||
import ru.touchin.roboswag.core.utils.Optional;
|
import ru.touchin.roboswag.core.utils.Optional;
|
||||||
import io.reactivex.Completable;
|
import rx.Completable;
|
||||||
import io.reactivex.Single;
|
import rx.Single;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import java.lang.reflect.Type;
|
||||||
import ru.touchin.roboswag.core.observables.storable.Converter;
|
import ru.touchin.roboswag.core.observables.storable.Converter;
|
||||||
import ru.touchin.roboswag.core.observables.storable.SameTypesConverter;
|
import ru.touchin.roboswag.core.observables.storable.SameTypesConverter;
|
||||||
import ru.touchin.roboswag.core.observables.storable.Storable;
|
import ru.touchin.roboswag.core.observables.storable.Storable;
|
||||||
import ru.touchin.roboswag.core.observables.storable.NonNullStorable;
|
import ru.touchin.roboswag.core.observables.storable.concrete.NonNullStorable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gavriil Sitnikov on 01/09/2016.
|
* Created by Gavriil Sitnikov on 01/09/2016.
|
||||||
|
|
|
||||||
|
|
@ -28,15 +28,14 @@ import android.support.annotation.Nullable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import io.reactivex.Maybe;
|
|
||||||
import ru.touchin.roboswag.components.utils.BaseLifecycleBindable;
|
import ru.touchin.roboswag.components.utils.BaseLifecycleBindable;
|
||||||
import ru.touchin.roboswag.components.utils.LifecycleBindable;
|
import ru.touchin.roboswag.components.utils.LifecycleBindable;
|
||||||
import io.reactivex.Completable;
|
import rx.Completable;
|
||||||
import io.reactivex.Observable;
|
import rx.Observable;
|
||||||
import io.reactivex.Single;
|
import rx.Single;
|
||||||
import io.reactivex.disposables.Disposable;
|
import rx.Subscription;
|
||||||
import io.reactivex.functions.Action;
|
import rx.functions.Action0;
|
||||||
import io.reactivex.functions.Consumer;
|
import rx.functions.Action1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -146,180 +145,140 @@ public class LifecycleView extends FrameLayout implements LifecycleBindable {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable) {
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable) {
|
||||||
return baseLifecycleBindable.untilStop(observable);
|
return baseLifecycleBindable.untilStop(observable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable, @NonNull final Consumer<T> onNextAction) {
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable, @NonNull final Action1<T> onNextAction) {
|
||||||
return baseLifecycleBindable.untilStop(observable, onNextAction);
|
return baseLifecycleBindable.untilStop(observable, onNextAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable,
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction);
|
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Observable<T> observable,
|
public <T> Subscription untilStop(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction,
|
@NonNull final Action1<Throwable> onErrorAction,
|
||||||
@NonNull final Action onCompletedAction) {
|
@NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction, onCompletedAction);
|
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single) {
|
public <T> Subscription untilStop(@NonNull final Single<T> single) {
|
||||||
return baseLifecycleBindable.untilStop(single);
|
return baseLifecycleBindable.untilStop(single);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilStop(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||||
return baseLifecycleBindable.untilStop(single, onSuccessAction);
|
return baseLifecycleBindable.untilStop(single, onSuccessAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Single<T> single,
|
public <T> Subscription untilStop(@NonNull final Single<T> single,
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
@NonNull final Action1<T> onSuccessAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilStop(single, onSuccessAction, onErrorAction);
|
return baseLifecycleBindable.untilStop(single, onSuccessAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable) {
|
public Subscription untilStop(@NonNull final Completable completable) {
|
||||||
return baseLifecycleBindable.untilStop(completable);
|
return baseLifecycleBindable.untilStop(completable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable, @NonNull final Action onCompletedAction) {
|
public Subscription untilStop(@NonNull final Completable completable, @NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilStop(completable, onCompletedAction);
|
return baseLifecycleBindable.untilStop(completable, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilStop(@NonNull final Completable completable,
|
public Subscription untilStop(@NonNull final Completable completable,
|
||||||
@NonNull final Action onCompletedAction,
|
@NonNull final Action0 onCompletedAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilStop(completable, onCompletedAction, onErrorAction);
|
return baseLifecycleBindable.untilStop(completable, onCompletedAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe) {
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable) {
|
||||||
return baseLifecycleBindable.untilStop(maybe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe, @NonNull final Consumer<T> onSuccessAction) {
|
|
||||||
return baseLifecycleBindable.untilStop(maybe, onSuccessAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilStop(@NonNull final Maybe<T> maybe,
|
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
|
||||||
return baseLifecycleBindable.untilStop(maybe, onSuccessAction, onErrorAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(observable);
|
return baseLifecycleBindable.untilDestroy(observable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable, @NonNull final Consumer<T> onNextAction) {
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable, @NonNull final Action1<T> onNextAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(observable, onNextAction);
|
return baseLifecycleBindable.untilDestroy(observable, onNextAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable,
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction);
|
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Observable<T> observable,
|
public <T> Subscription untilDestroy(@NonNull final Observable<T> observable,
|
||||||
@NonNull final Consumer<T> onNextAction,
|
@NonNull final Action1<T> onNextAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction,
|
@NonNull final Action1<Throwable> onErrorAction,
|
||||||
@NonNull final Action onCompletedAction) {
|
@NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction, onCompletedAction);
|
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single) {
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single) {
|
||||||
return baseLifecycleBindable.untilDestroy(single);
|
return baseLifecycleBindable.untilDestroy(single);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single, @NonNull final Consumer<T> onSuccessAction) {
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(single, onSuccessAction);
|
return baseLifecycleBindable.untilDestroy(single, onSuccessAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T> Disposable untilDestroy(@NonNull final Single<T> single,
|
public <T> Subscription untilDestroy(@NonNull final Single<T> single,
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
@NonNull final Action1<T> onSuccessAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(single, onSuccessAction, onErrorAction);
|
return baseLifecycleBindable.untilDestroy(single, onSuccessAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable) {
|
public Subscription untilDestroy(@NonNull final Completable completable) {
|
||||||
return baseLifecycleBindable.untilDestroy(completable);
|
return baseLifecycleBindable.untilDestroy(completable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable, @NonNull final Action onCompletedAction) {
|
public Subscription untilDestroy(@NonNull final Completable completable, @NonNull final Action0 onCompletedAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction);
|
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Disposable untilDestroy(@NonNull final Completable completable,
|
public Subscription untilDestroy(@NonNull final Completable completable,
|
||||||
@NonNull final Action onCompletedAction,
|
@NonNull final Action0 onCompletedAction,
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
@NonNull final Action1<Throwable> onErrorAction) {
|
||||||
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction, onErrorAction);
|
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction, onErrorAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(maybe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe, @NonNull final Consumer<T> onSuccessAction) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(maybe, onSuccessAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public <T> Disposable untilDestroy(@NonNull final Maybe<T> maybe,
|
|
||||||
@NonNull final Consumer<T> onSuccessAction,
|
|
||||||
@NonNull final Consumer<Throwable> onErrorAction) {
|
|
||||||
return baseLifecycleBindable.untilDestroy(maybe, onSuccessAction, onErrorAction);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ public class MaterialLoadingBar extends AppCompatImageView {
|
||||||
typedArray.recycle();
|
typedArray.recycle();
|
||||||
|
|
||||||
progressDrawable = new MaterialProgressDrawable(context, size);
|
progressDrawable = new MaterialProgressDrawable(context, size);
|
||||||
setColor(color);
|
progressDrawable.setColor(color);
|
||||||
progressDrawable.setStrokeWidth(strokeWidth);
|
progressDrawable.setStrokeWidth(strokeWidth);
|
||||||
setScaleType(ScaleType.CENTER);
|
setScaleType(ScaleType.CENTER);
|
||||||
setImageDrawable(progressDrawable);
|
setImageDrawable(progressDrawable);
|
||||||
|
|
@ -107,7 +107,7 @@ public class MaterialLoadingBar extends AppCompatImageView {
|
||||||
progressDrawable.stop();
|
progressDrawable.stop();
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set color of loader.
|
* Set color of loader.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.TextInputLayout;
|
|
||||||
import android.support.v7.widget.AppCompatEditText;
|
import android.support.v7.widget.AppCompatEditText;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
|
|
@ -32,15 +31,12 @@ import android.text.TextWatcher;
|
||||||
import android.text.method.SingleLineTransformationMethod;
|
import android.text.method.SingleLineTransformationMethod;
|
||||||
import android.text.method.TransformationMethod;
|
import android.text.method.TransformationMethod;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewParent;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
|
||||||
import android.view.inputmethod.InputConnection;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import ru.touchin.roboswag.components.R;
|
import ru.touchin.roboswag.components.R;
|
||||||
|
import ru.touchin.roboswag.components.utils.Typefaces;
|
||||||
import ru.touchin.roboswag.components.views.internal.AttributesUtils;
|
import ru.touchin.roboswag.components.views.internal.AttributesUtils;
|
||||||
import ru.touchin.roboswag.core.log.Lc;
|
import ru.touchin.roboswag.core.log.Lc;
|
||||||
|
|
||||||
|
|
@ -100,6 +96,10 @@ public class TypefacedEditText extends AppCompatEditText {
|
||||||
} else {
|
} else {
|
||||||
setSingleLine();
|
setSingleLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isInEditMode()) {
|
||||||
|
setTypeface(Typefaces.getFromAttributes(context, attrs, R.styleable.TypefacedEditText, R.styleable.TypefacedEditText_customTypeface));
|
||||||
|
}
|
||||||
typedArray.recycle();
|
typedArray.recycle();
|
||||||
if (inDebugMode) {
|
if (inDebugMode) {
|
||||||
checkAttributes(context, attrs);
|
checkAttributes(context, attrs);
|
||||||
|
|
@ -107,25 +107,12 @@ public class TypefacedEditText extends AppCompatEditText {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public InputConnection onCreateInputConnection(@NonNull final EditorInfo attrs) {
|
|
||||||
final InputConnection inputConnection = super.onCreateInputConnection(attrs);
|
|
||||||
if (inputConnection != null && attrs.hintText == null) {
|
|
||||||
for (ViewParent parent = getParent(); parent instanceof View; parent = parent.getParent()) {
|
|
||||||
if (parent instanceof TextInputLayout) {
|
|
||||||
attrs.hintText = ((TextInputLayout) parent).getHint();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return inputConnection;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkAttributes(@NonNull final Context context, @NonNull final AttributeSet attrs) {
|
private void checkAttributes(@NonNull final Context context, @NonNull final AttributeSet attrs) {
|
||||||
final List<String> errors = new ArrayList<>();
|
final List<String> errors = new ArrayList<>();
|
||||||
Boolean multiline = null;
|
Boolean multiline = null;
|
||||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TypefacedEditText);
|
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TypefacedEditText);
|
||||||
|
AttributesUtils.checkAttribute(typedArray, errors, R.styleable.TypefacedEditText_customTypeface, true,
|
||||||
|
"customTypeface required parameter");
|
||||||
AttributesUtils.checkAttribute(typedArray, errors, R.styleable.TypefacedEditText_isMultiline, true,
|
AttributesUtils.checkAttribute(typedArray, errors, R.styleable.TypefacedEditText_isMultiline, true,
|
||||||
"isMultiline required parameter");
|
"isMultiline required parameter");
|
||||||
if (typedArray.hasValue(R.styleable.TypefacedEditText_isMultiline)) {
|
if (typedArray.hasValue(R.styleable.TypefacedEditText_isMultiline)) {
|
||||||
|
|
@ -152,6 +139,12 @@ public class TypefacedEditText extends AppCompatEditText {
|
||||||
private void checkEditTextSpecificAttributes(@NonNull final TypedArray typedArray, @NonNull final Class androidRes,
|
private void checkEditTextSpecificAttributes(@NonNull final TypedArray typedArray, @NonNull final Class androidRes,
|
||||||
@NonNull final List<String> errors)
|
@NonNull final List<String> errors)
|
||||||
throws NoSuchFieldException, IllegalAccessException {
|
throws NoSuchFieldException, IllegalAccessException {
|
||||||
|
AttributesUtils.checkAttribute(typedArray, errors, AttributesUtils.getField(androidRes, "TextView_typeface"), false,
|
||||||
|
"remove typeface and use customTypeface");
|
||||||
|
AttributesUtils.checkAttribute(typedArray, errors, AttributesUtils.getField(androidRes, "TextView_textStyle"), false,
|
||||||
|
"remove textStyle and use customTypeface");
|
||||||
|
AttributesUtils.checkAttribute(typedArray, errors, AttributesUtils.getField(androidRes, "TextView_fontFamily"), false,
|
||||||
|
"remove fontFamily and use customTypeface");
|
||||||
AttributesUtils.checkAttribute(typedArray, errors, AttributesUtils.getField(androidRes, "TextView_singleLine"), false,
|
AttributesUtils.checkAttribute(typedArray, errors, AttributesUtils.getField(androidRes, "TextView_singleLine"), false,
|
||||||
"remove singleLine and use isMultiline");
|
"remove singleLine and use isMultiline");
|
||||||
AttributesUtils.checkAttribute(typedArray, errors, AttributesUtils.getField(androidRes, "TextView_includeFontPadding"), false,
|
AttributesUtils.checkAttribute(typedArray, errors, AttributesUtils.getField(androidRes, "TextView_includeFontPadding"), false,
|
||||||
|
|
@ -324,6 +317,15 @@ public class TypefacedEditText extends AppCompatEditText {
|
||||||
super.setInputType(type);
|
super.setInputType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets typeface from 'assets/fonts' folder by name.
|
||||||
|
*
|
||||||
|
* @param name Full name of typeface (without extension, e.g. 'Roboto-Regular').
|
||||||
|
*/
|
||||||
|
public void setTypeface(@NonNull final String name) {
|
||||||
|
setTypeface(Typefaces.getByName(getContext(), name));
|
||||||
|
}
|
||||||
|
|
||||||
public void setOnTextChangedListener(@Nullable final OnTextChangedListener onTextChangedListener) {
|
public void setOnTextChangedListener(@Nullable final OnTextChangedListener onTextChangedListener) {
|
||||||
this.onTextChangedListener = onTextChangedListener;
|
this.onTextChangedListener = onTextChangedListener;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import ru.touchin.roboswag.components.R;
|
import ru.touchin.roboswag.components.R;
|
||||||
|
import ru.touchin.roboswag.components.utils.Typefaces;
|
||||||
import ru.touchin.roboswag.components.utils.UiUtils;
|
import ru.touchin.roboswag.components.utils.UiUtils;
|
||||||
import ru.touchin.roboswag.components.views.internal.AttributesUtils;
|
import ru.touchin.roboswag.components.views.internal.AttributesUtils;
|
||||||
import ru.touchin.roboswag.core.log.Lc;
|
import ru.touchin.roboswag.core.log.Lc;
|
||||||
|
|
@ -92,6 +93,9 @@ public class TypefacedTextView extends AppCompatTextView {
|
||||||
} else {
|
} else {
|
||||||
setLineStrategy(lineStrategy);
|
setLineStrategy(lineStrategy);
|
||||||
}
|
}
|
||||||
|
if (!isInEditMode()) {
|
||||||
|
setTypeface(Typefaces.getFromAttributes(context, attrs, R.styleable.TypefacedTextView, R.styleable.TypefacedTextView_customTypeface));
|
||||||
|
}
|
||||||
typedArray.recycle();
|
typedArray.recycle();
|
||||||
if (inDebugMode) {
|
if (inDebugMode) {
|
||||||
checkAttributes(context, attrs);
|
checkAttributes(context, attrs);
|
||||||
|
|
@ -103,6 +107,8 @@ public class TypefacedTextView extends AppCompatTextView {
|
||||||
final List<String> errors = new ArrayList<>();
|
final List<String> errors = new ArrayList<>();
|
||||||
LineStrategy lineStrategy = null;
|
LineStrategy lineStrategy = null;
|
||||||
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TypefacedTextView);
|
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.TypefacedTextView);
|
||||||
|
AttributesUtils.checkAttribute(typedArray, errors, R.styleable.TypefacedTextView_customTypeface, true,
|
||||||
|
"customTypeface required parameter");
|
||||||
AttributesUtils.checkAttribute(typedArray, errors, R.styleable.TypefacedTextView_lineStrategy, true,
|
AttributesUtils.checkAttribute(typedArray, errors, R.styleable.TypefacedTextView_lineStrategy, true,
|
||||||
"lineStrategy required parameter");
|
"lineStrategy required parameter");
|
||||||
if (typedArray.hasValue(R.styleable.TypefacedTextView_lineStrategy)) {
|
if (typedArray.hasValue(R.styleable.TypefacedTextView_lineStrategy)) {
|
||||||
|
|
@ -305,6 +311,15 @@ public class TypefacedTextView extends AppCompatTextView {
|
||||||
Lc.assertion(new IllegalStateException(AttributesUtils.viewError(this, "Do not specify ellipsize use setLineStrategy instead")));
|
Lc.assertion(new IllegalStateException(AttributesUtils.viewError(this, "Do not specify ellipsize use setLineStrategy instead")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets typeface from 'assets/fonts' folder by name.
|
||||||
|
*
|
||||||
|
* @param name Full name of typeface (without extension, e.g. 'Roboto-Regular').
|
||||||
|
*/
|
||||||
|
public void setTypeface(@NonNull final String name) {
|
||||||
|
setTypeface(Typefaces.getByName(getContext(), name));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setText(@Nullable final CharSequence text, @Nullable final BufferType type) {
|
public void setText(@Nullable final CharSequence text, @Nullable final BufferType type) {
|
||||||
super.setText(text, type);
|
super.setText(text, type);
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,9 @@ public final class AttributesUtils {
|
||||||
public static void checkRegularTextViewAttributes(@NonNull final TypedArray typedArray, @NonNull final Class androidRes,
|
public static void checkRegularTextViewAttributes(@NonNull final TypedArray typedArray, @NonNull final Class androidRes,
|
||||||
@NonNull final Collection<String> errors, @NonNull final String lineStrategyParameterName)
|
@NonNull final Collection<String> errors, @NonNull final String lineStrategyParameterName)
|
||||||
throws NoSuchFieldException, IllegalAccessException {
|
throws NoSuchFieldException, IllegalAccessException {
|
||||||
checkAttribute(typedArray, errors, getField(androidRes, "TextView_fontFamily"), true, "fontFamily required parameter");
|
checkAttribute(typedArray, errors, getField(androidRes, "TextView_typeface"), false, "remove typeface and use customTypeface");
|
||||||
|
checkAttribute(typedArray, errors, getField(androidRes, "TextView_textStyle"), false, "remove textStyle and use customTypeface");
|
||||||
|
checkAttribute(typedArray, errors, getField(androidRes, "TextView_fontFamily"), false, "remove fontFamily and use customTypeface");
|
||||||
checkAttribute(typedArray, errors, getField(androidRes, "TextView_includeFontPadding"), false, "includeFontPadding forbid parameter");
|
checkAttribute(typedArray, errors, getField(androidRes, "TextView_includeFontPadding"), false, "includeFontPadding forbid parameter");
|
||||||
checkAttribute(typedArray, errors, getField(androidRes, "TextView_singleLine"), false,
|
checkAttribute(typedArray, errors, getField(androidRes, "TextView_singleLine"), false,
|
||||||
"remove singleLine and use " + lineStrategyParameterName);
|
"remove singleLine and use " + lineStrategyParameterName);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
<attr name="customTypeface" format="string"/>
|
<attr name="customTypeface" format="string"/>
|
||||||
|
|
||||||
<declare-styleable name="TypefacedTextView">
|
<declare-styleable name="TypefacedTextView">
|
||||||
|
<attr name="customTypeface"/>
|
||||||
<attr name="lineStrategy" format="enum">
|
<attr name="lineStrategy" format="enum">
|
||||||
<enum name="singleLineEllipsize" value="0"/>
|
<enum name="singleLineEllipsize" value="0"/>
|
||||||
<enum name="singleLineMarquee" value="1"/>
|
<enum name="singleLineMarquee" value="1"/>
|
||||||
|
|
@ -16,6 +17,7 @@
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="TypefacedEditText">
|
<declare-styleable name="TypefacedEditText">
|
||||||
|
<attr name="customTypeface"/>
|
||||||
<attr name="isMultiline" format="boolean"/>
|
<attr name="isMultiline" format="boolean"/>
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue