method compose in class Observable cannot be applied to given types;
required: ObservableTransformer<CAP#1,R>
found: ObservableTransformer<Object,CAP#2>
reason: cannot infer type-variable(s) R
(argument mismatch; ObservableTransformer<Object,CAP#2> cannot be converted to ObservableTransformer<CAP#1,R>)
where R,T are type-variables:
R extends Object declared in method compose(ObservableTransformer<T,R>)
T extends Object declared in class Observable
where CAP#1,CAP#2 are fresh type-variables:
CAP#1 extends Object from capture of ?
CAP#2 extends Object from capture of ?
The error comes from CompositeDisposable compose function.
mDisposables.add(
grantPermission()
.compose(waitForTextureSurfaceReady())
.compose(openCameraToGetCameraDevice())
.compose(createCaptureSession())
.compose(setCaptureRequestAndObserveAvailableImage())
.onErrorReturn(new Function<Throwable, Object>() {
@Override
public Object apply(Throwable throwable) throws Exception {
return UiModel.failed(throwable);
}
})
.ofType(UiModel.class)
.subscribe(new Consumer<UiModel>() {
@Override
public void accept(UiModel viewModel)
throws Exception {
// Error handling.
if (viewModel.error != null) {
showAlertDialog(viewModel.error);
}
}
}));
private ObservableTransformer<?, Object> waitForTextureSurfaceReady() {
return new ObservableTransformer<Object, Object>() {
@Override
public ObservableSource<Object> apply(Observable<Object> upstream) {
return upstream
.ofType(Boolean.class)
.flatMap(new Function<Boolean, ObservableSource<Object>>() {
@Override
public ObservableSource<Object> apply(Boolean granted)
throws Exception {
if (granted) {
return new TextureViewObservable(mCameraView).ofType(Object.class);
} else {
throw new IllegalStateException("Permission is not granted.");
}
}
});
}
};
}
The gradle configuration is the same of the repository, and I installed the build tools that you are using.
I am very new in MVP patterns and with rxjava. I see that you use this functions for granting the runtime permissions.
Thanks in advance.
Unai.