small updates

This commit is contained in:
Alexander Bubnov 2017-04-18 21:54:57 +03:00
parent 415f5c7d76
commit 8925e5083e
3 changed files with 19 additions and 5 deletions

View File

@ -1,13 +1,21 @@
package ru.touchin.roboswag.components.adapters;
import android.support.annotation.NonNull;
import android.view.ViewGroup;
import java.util.List;
import ru.touchin.roboswag.components.utils.LifecycleBindable;
public abstract class AdapterDelegate<TViewHolder extends BindableViewHolder, TItem> {
@NonNull
private final LifecycleBindable lifecycleBindable;
public AdapterDelegate(@NonNull final LifecycleBindable lifecycleBindable) {
this.lifecycleBindable = lifecycleBindable;
}
public abstract int getItemViewType();
public abstract boolean isForViewType(@NonNull final Object item, final int adapterPosition, final int itemCollectionPosition);
@ -27,4 +35,9 @@ public abstract class AdapterDelegate<TViewHolder extends BindableViewHolder, TI
//do nothing by default
}
@NonNull
protected LifecycleBindable getLifecycleBindable() {
return lifecycleBindable;
}
}

View File

@ -98,6 +98,7 @@ public abstract class ObservableCollectionAdapter<TItem, TItemViewHolder extends
innerCollection.clear();
return Observable.empty();
}
innerCollection.set(collection.getItems());
return collection.observeChanges().observeOn(AndroidSchedulers.mainThread());
}), this::onApplyChanges);
historyPreLoadingObservable = observableCollectionSubject

View File

@ -60,7 +60,7 @@ public class BaseLifecycleBindable implements LifecycleBindable {
* Call it on parent's onStart method.
*/
public void onStart() {
if (isStartedSubject.hasValue() && !isStartedSubject.getValue()) {
if (!isStartedSubject.hasValue() || !isStartedSubject.getValue()) {
isStartedSubject.onNext(true);
}
}
@ -71,7 +71,7 @@ public class BaseLifecycleBindable implements LifecycleBindable {
* In that case onResume will be called after onSaveInstanceState so lifecycle object is becoming started.
*/
public void onResume() {
if (isStartedSubject.hasValue() && !isStartedSubject.getValue()) {
if (!isStartedSubject.hasValue() || !isStartedSubject.getValue()) {
isStartedSubject.onNext(true);
}
}
@ -80,7 +80,7 @@ public class BaseLifecycleBindable implements LifecycleBindable {
* Call it on parent's onSaveInstanceState method.
*/
public void onSaveInstanceState() {
if (isStartedSubject.hasValue() && isStartedSubject.getValue()) {
if (!isStartedSubject.hasValue() || isStartedSubject.getValue()) {
isStartedSubject.onNext(false);
}
}
@ -89,7 +89,7 @@ public class BaseLifecycleBindable implements LifecycleBindable {
* Call it on parent's onStop method.
*/
public void onStop() {
if (isStartedSubject.hasValue() && isStartedSubject.getValue()) {
if (!isStartedSubject.hasValue() || isStartedSubject.getValue()) {
isStartedSubject.onNext(false);
}
}