Log.v(“ThreeTips”, “#7”)

Mert SIMSEK
1 min readNov 30, 2016

--

1 — Observable.fromCallable();

We all need convert our sync methods to async observables. Most of us use create or defer method for this. But It is a bit ugly.

Observable.create(subscriber -> {
try {
subscriber.onNext(longOperation());
subscriber.onCompleted();
} catch (IOException e) {
subscriber.onError(e);
}
});
Observable.defer(() -> {
try {
return Observable.just(longOperation());
} catch (IOException e) {
return Observable.error(e);
}
});

This is one-line way to do it. It is simple and pretty.

Observable.fromCallable(() -> longOperation());

2 — Using styles in Android Databinding

Answer is no. You can not use styles with databinding(For now).

3 — You can change your Keystore Alias

Last week I tried to build my project on CI server. So I moved my keystore and password properties to CI server. But I faced with a different problem. If your keystore alias name includes Turkish character (or any special character) your build fails. Here is code snippet to copy to terminal.

References:

https://artemzin.com/blog/rxjava-defer-execution-of-function-via-fromcallable/

http://stackoverflow.com/questions/31980342/android-data-binding-style

https://gist.github.com/ishida/2719962

--

--

Mert SIMSEK
Mert SIMSEK

No responses yet