static
This commit is contained in:
parent
a135d5ac16
commit
031648451f
|
|
@ -44,6 +44,7 @@ import rx.functions.Action1;
|
|||
* Created by Gavriil Sitnikov on 12/8/2016.
|
||||
* ViewHolder that implements {@link LifecycleBindable} and uses parent bindable object as bridge (Activity, ViewController etc.).
|
||||
*/
|
||||
@SuppressWarnings("PMD.TooManyMethods")
|
||||
public class BindableViewHolder extends RecyclerView.ViewHolder implements LifecycleBindable {
|
||||
|
||||
@NonNull
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ import rx.functions.Action1;
|
|||
* @param <TActivity> Type of activity where such {@link ViewController} could be;
|
||||
* @param <TFragment> Type of fragment where such {@link ViewController} could be;
|
||||
*/
|
||||
@SuppressWarnings("PMD.TooManyMethods")
|
||||
@SuppressWarnings({"PMD.TooManyMethods", "PMD.ExcessivePublicCount"})
|
||||
public class ViewController<TActivity extends ViewControllerActivity<?>,
|
||||
TFragment extends ViewControllerFragment<?, TActivity>>
|
||||
implements LifecycleBindable {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@ import ru.touchin.roboswag.components.utils.BaseLifecycleBindable;
|
|||
import ru.touchin.roboswag.components.utils.LifecycleBindable;
|
||||
import ru.touchin.roboswag.components.utils.UiUtils;
|
||||
import ru.touchin.roboswag.core.log.Lc;
|
||||
import rx.Completable;
|
||||
import rx.Observable;
|
||||
import rx.Single;
|
||||
import rx.Subscription;
|
||||
import rx.functions.Action0;
|
||||
import rx.functions.Action1;
|
||||
|
|
@ -269,6 +271,46 @@ public abstract class BaseActivity extends AppCompatActivity
|
|||
return baseLifecycleBindable.untilStop(observable, onNextAction, onErrorAction, onCompletedAction);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public <T> Subscription untilStop(@NonNull final Single<T> single) {
|
||||
return baseLifecycleBindable.untilStop(single);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public <T> Subscription untilStop(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||
return baseLifecycleBindable.untilStop(single, onSuccessAction);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public <T> Subscription untilStop(@NonNull final Single<T> single,
|
||||
@NonNull final Action1<T> onSuccessAction,
|
||||
@NonNull final Action1<Throwable> onErrorAction) {
|
||||
return baseLifecycleBindable.untilStop(single, onSuccessAction, onErrorAction);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Subscription untilStop(@NonNull final Completable completable) {
|
||||
return baseLifecycleBindable.untilStop(completable);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Subscription untilStop(@NonNull final Completable completable, @NonNull final Action0 onCompletedAction) {
|
||||
return baseLifecycleBindable.untilStop(completable, onCompletedAction);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Subscription untilStop(@NonNull final Completable completable,
|
||||
@NonNull final Action0 onCompletedAction,
|
||||
@NonNull final Action1<Throwable> onErrorAction) {
|
||||
return baseLifecycleBindable.untilStop(completable, onCompletedAction, onErrorAction);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public <T> Subscription untilStop(@NonNull final Observable<T> observable) {
|
||||
|
|
@ -310,6 +352,46 @@ public abstract class BaseActivity extends AppCompatActivity
|
|||
return baseLifecycleBindable.untilDestroy(observable, onNextAction, onErrorAction, onCompletedAction);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public <T> Subscription untilDestroy(@NonNull final Single<T> single) {
|
||||
return baseLifecycleBindable.untilDestroy(single);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public <T> Subscription untilDestroy(@NonNull final Single<T> single, @NonNull final Action1<T> onSuccessAction) {
|
||||
return baseLifecycleBindable.untilDestroy(single, onSuccessAction);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public <T> Subscription untilDestroy(@NonNull final Single<T> single,
|
||||
@NonNull final Action1<T> onSuccessAction,
|
||||
@NonNull final Action1<Throwable> onErrorAction) {
|
||||
return baseLifecycleBindable.untilDestroy(single, onSuccessAction, onErrorAction);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Subscription untilDestroy(@NonNull final Completable completable) {
|
||||
return baseLifecycleBindable.untilDestroy(completable);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Subscription untilDestroy(@NonNull final Completable completable, @NonNull final Action0 onCompletedAction) {
|
||||
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Subscription untilDestroy(@NonNull final Completable completable,
|
||||
@NonNull final Action0 onCompletedAction,
|
||||
@NonNull final Action1<Throwable> onErrorAction) {
|
||||
return baseLifecycleBindable.untilDestroy(completable, onCompletedAction, onErrorAction);
|
||||
}
|
||||
|
||||
@SuppressWarnings("CPD-END")
|
||||
//CPD: it is same as in other implementation based on BaseLifecycleBindable
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import rx.subjects.BehaviorSubject;
|
|||
* Created by Gavriil Sitnikov on 18/04/16.
|
||||
* Simple implementation of {@link LifecycleBindable}. Could be used to not implement interface but use such object inside.
|
||||
*/
|
||||
@SuppressWarnings("PMD.TooManyMethods")
|
||||
public class BaseLifecycleBindable implements LifecycleBindable {
|
||||
|
||||
private static final String UNTIL_DESTROY_METHOD = "untilDestroy";
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import android.support.annotation.NonNull;
|
|||
import rx.Completable;
|
||||
import rx.Observable;
|
||||
import rx.Single;
|
||||
import rx.SingleSubscriber;
|
||||
import rx.Subscriber;
|
||||
import rx.Subscription;
|
||||
import rx.functions.Action0;
|
||||
|
|
@ -38,6 +39,7 @@ import rx.functions.Func1;
|
|||
* Use {@link #untilStop(Observable)} method to subscribe to observable where you want and unsubscribe onStop.
|
||||
* Use {@link #untilDestroy(Observable)} method to subscribe to observable where you want and unsubscribe onDestroy.
|
||||
*/
|
||||
@SuppressWarnings("PMD.TooManyMethods")
|
||||
public interface LifecycleBindable {
|
||||
|
||||
/**
|
||||
|
|
@ -132,7 +134,7 @@ public interface LifecycleBindable {
|
|||
* Don't forget to process errors if single can emit them.
|
||||
*
|
||||
* @param single {@link Single} to subscribe until onStop;
|
||||
* @param onSuccessAction Action which will raise on every {@link rx.SingleSubscriber#onSuccess(Object)} item;
|
||||
* @param onSuccessAction Action which will raise on every {@link SingleSubscriber#onSuccess(Object)} item;
|
||||
* @param <T> Type of emitted by single item;
|
||||
* @return {@link Subscription} which will unsubscribes from single onStop.
|
||||
*/
|
||||
|
|
@ -146,8 +148,8 @@ public interface LifecycleBindable {
|
|||
* Don't forget to process errors if single can emit them.
|
||||
*
|
||||
* @param single {@link Single} to subscribe until onStop;
|
||||
* @param onSuccessAction Action which will raise on every {@link rx.SingleSubscriber#onSuccess(Object)} item;
|
||||
* @param onErrorAction Action which will raise on every {@link rx.SingleSubscriber#onError(Throwable)} throwable;
|
||||
* @param onSuccessAction Action which will raise on every {@link SingleSubscriber#onSuccess(Object)} item;
|
||||
* @param onErrorAction Action which will raise on every {@link SingleSubscriber#onError(Throwable)} throwable;
|
||||
* @param <T> Type of emitted by observable items;
|
||||
* @return {@link Subscription} which is wrapping source single to unsubscribe from it onStop.
|
||||
*/
|
||||
|
|
@ -173,7 +175,7 @@ public interface LifecycleBindable {
|
|||
* Don't forget to process errors if completable can emit them.
|
||||
*
|
||||
* @param completable {@link Completable} to subscribe until onStop;
|
||||
* @param onCompletedAction Action which will raise at {@link rx.Completable.CompletableSubscriber#onCompleted()} on completion of observable;
|
||||
* @param onCompletedAction Action which will raise at {@link Completable.CompletableSubscriber#onCompleted()} on completion of observable;
|
||||
* @return {@link Subscription} which is wrapping source completable to unsubscribe from it onStop.
|
||||
*/
|
||||
@NonNull
|
||||
|
|
@ -186,8 +188,8 @@ public interface LifecycleBindable {
|
|||
* Don't forget to process errors if completable can emit them.
|
||||
*
|
||||
* @param completable {@link Completable} to subscribe until onStop;
|
||||
* @param onCompletedAction Action which will raise at {@link rx.Completable.CompletableSubscriber#onCompleted()} on completion of observable;
|
||||
* @param onErrorAction Action which will raise on every {@link rx.Completable.CompletableSubscriber#onError(Throwable)} throwable;
|
||||
* @param onCompletedAction Action which will raise at {@link Completable.CompletableSubscriber#onCompleted()} on completion of observable;
|
||||
* @param onErrorAction Action which will raise on every {@link Completable.CompletableSubscriber#onError(Throwable)} throwable;
|
||||
* @return {@link Subscription} which is wrapping source completable to unsubscribe from it onStop.
|
||||
*/
|
||||
@NonNull
|
||||
|
|
@ -266,7 +268,7 @@ public interface LifecycleBindable {
|
|||
* Don't forget to process errors if single can emit them.
|
||||
*
|
||||
* @param single {@link Single} to subscribe until onDestroy;
|
||||
* @param onSuccessAction Action which will raise on every {@link rx.SingleSubscriber#onSuccess(Object)} item;
|
||||
* @param onSuccessAction Action which will raise on every {@link SingleSubscriber#onSuccess(Object)} item;
|
||||
* @param <T> Type of emitted by single items;
|
||||
* @return {@link Subscription} which is wrapping source single to unsubscribe from it onDestroy.
|
||||
*/
|
||||
|
|
@ -279,8 +281,8 @@ public interface LifecycleBindable {
|
|||
* Don't forget to process errors if single can emit them.
|
||||
*
|
||||
* @param single {@link Single} to subscribe until onDestroy;
|
||||
* @param onSuccessAction Action which will raise on every {@link rx.SingleSubscriber#onSuccess(Object)} item;
|
||||
* @param onErrorAction Action which will raise on every {@link rx.SingleSubscriber#onError(Throwable)} throwable;
|
||||
* @param onSuccessAction Action which will raise on every {@link SingleSubscriber#onSuccess(Object)} item;
|
||||
* @param onErrorAction Action which will raise on every {@link SingleSubscriber#onError(Throwable)} throwable;
|
||||
* @param <T> Type of emitted by single items;
|
||||
* @return {@link Subscription} which is wrapping source single to unsubscribe from it onDestroy.
|
||||
*/
|
||||
|
|
@ -317,7 +319,7 @@ public interface LifecycleBindable {
|
|||
*
|
||||
* @param completable {@link Completable} to subscribe until onDestroy;
|
||||
* @param onCompletedAction Action which will raise on every {@link Completable.CompletableSubscriber#onCompleted()} item;
|
||||
* @param onErrorAction Action which will raise on every {@link rx.Completable.CompletableSubscriber#onError(Throwable)} throwable;
|
||||
* @param onErrorAction Action which will raise on every {@link Completable.CompletableSubscriber#onError(Throwable)} throwable;
|
||||
* @return {@link Subscription} which is wrapping source completable to unsubscribe from it onDestroy.
|
||||
*/
|
||||
@NonNull
|
||||
|
|
|
|||
Loading…
Reference in New Issue