fix of click listening
This commit is contained in:
parent
2791bc3b81
commit
fa434b274d
|
|
@ -29,6 +29,11 @@ public abstract class BaseActivity extends AppCompatActivity
|
|||
private final BehaviorSubject<Boolean> isStartedSubject = BehaviorSubject.create();
|
||||
@NonNull
|
||||
private final BaseUiBindable baseUiBindable = new BaseUiBindable(isCreatedSubject, isStartedSubject);
|
||||
private boolean resumed;
|
||||
|
||||
public boolean isResumed() {
|
||||
return resumed;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
|
|
@ -42,6 +47,18 @@ public abstract class BaseActivity extends AppCompatActivity
|
|||
isStartedSubject.onNext(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
resumed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
resumed = false;
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
isStartedSubject.onNext(false);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import android.view.ViewGroup;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import ru.touchin.roboswag.components.navigation.AbstractBaseFragment;
|
||||
import ru.touchin.roboswag.components.navigation.activities.BaseActivity;
|
||||
import rx.functions.Action0;
|
||||
import rx.functions.Func1;
|
||||
|
||||
|
|
@ -180,9 +181,12 @@ public final class UiUtils {
|
|||
}
|
||||
|
||||
final Runnable runnable = () -> {
|
||||
if (targetView.getWindowVisibility() == View.VISIBLE) {
|
||||
onClickListener.onClick(targetView);
|
||||
if (targetView.getWindowVisibility() != View.VISIBLE
|
||||
|| !targetView.hasWindowFocus()
|
||||
|| (targetView.getContext() instanceof BaseActivity && !((BaseActivity) targetView.getContext()).isResumed())) {
|
||||
return;
|
||||
}
|
||||
onClickListener.onClick(targetView);
|
||||
};
|
||||
|
||||
targetView.setOnClickListener(v -> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue