Introducing ReactiveBus

Today, I’ve released my another tiny project. It’s a very simple implementation of Event Bus with RxJava 2 under the hood. This library is compatible with Java 1.7 or higher. I didn’t use Java 1.8 or 1.9 because I wanted to make it compatible with Android apps. You can use it as follows: Bus bus = ReactiveBus.create(); Disposable observer = bus.receive().subscribe(new Consumer<Event>() { @Override public void accept(Event event) { // handle event here } }); Once, we created Event Bus object and our observer (or more precisely: disposable subscriber), we can start sending events: ...

March 11, 2018 · 2 min · 259 words · Piotr Wittchen

DroidCon Poland 2017 - Is your app really connected?

Yesterday, I gave a presentation about connectivity in the Android apps during the DroidCon Poland 2017 Conference in Kraków. Below, you can see slides from this presentation. View slides on SpeakerDeck There’s also tweet related to this presentation from DroidCon Kraków: Piotr Wittchen tells us about how we can we keep the track of network 🌎 or Internet connectivity changes in our app 📱🆘🙂 pic.twitter.com/7YGGzNJeb2 — droidcon Kraków (@droidconkr) December 2, 2017 I hope, you enjoyed it. Any kind of feedback is welcome (in the comments below this article or via e-mail). Don’t forget to check ReactiveNetwork library I mentioned during the presentation. ...

December 2, 2017 · 1 min · 103 words · Piotr Wittchen

Simple reactive HTTP client and server with RxJava, Vert.x and Android

During Hack Your Career event at the Silesian University of Technology, I’ve prepared a presentation titled Reactive Programming - Efficient Server Applications with a colleague from work. Arek told about theory of Reactive Programming, shown basic concepts, data types and a few examples in the code. During my part of the presentation, I’ve wrote a very simple server and client in Java (9 on the server, 7 on the client) with Vert.x (Core and Rx), RxJava 2, OkHttp 3, Android and RxAndroid. Presentation was targeted mainly to the university students with no experience with reactive programming, but it was an open event and anyone could attend it. Below, we can see a very simple code snippet showing how to create a reactive HTTP server with Vert.x. We can create a stream of requests, make Flowable out of it, apply any kind of RxJava 2 operator including backpressure handling and subscribe the stream. Moreover, we can also reactively start the server with rxListen(int port) method. This is just a basic example, where will be sending request to the only one endpoint. In the case, when we want to handle more endpoints, we can use vertx-web library and design REST API. ...

November 9, 2017 · 3 min · 556 words · Piotr Wittchen

Integrating ErrorProne and NullAway with an Android project

Recently, with the remote help of guys from Uber in California, I integrated NullAway and ErrorProne with the one of my open-source Android projects. What is NullAway? Basically, it’s a tool to help eliminate NullPointerExceptions (NPEs) in your Java code. It detects situations where NPE could occur at the compile time. Let’s have a look at the following code: static void log(Object x) { System.out.println(x.toString()); } static void foo() { log(null); } NullAway will find out that we’re passing null and we’ll get appropriate error message: ...

September 15, 2017 · 2 min · 387 words · Piotr Wittchen

Introducing ReactiveAirplaneMode

I’m continuing Rxfication of the Android. Recently I released brand new library called ReactiveAirplaneMode. As you may guess, it allows listening Airplane mode on Android device with RxJava observables. A usual I’ve hidden all implementation details, BroadcastReceivers and rest of the Android related stuff behind RxJava abstraction layer, so API is really simple. Just take a look on that: ReactiveAirplaneMode.create() .observe(context) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(isOn -> textView.setText(String.format("Airplane mode on: %s", isOn.toString()))); In the code above subscriber will be notified only when airplane mode changes. If you want to read airplane mode and then listen to it, you can use the following method: ...

August 15, 2017 · 1 min · 198 words · Piotr Wittchen