Author: Sebastian Kacprzak

Android BLE

Unpacking BLE frames in a readable way.

Ever wondered why does unpacking Bluetooth data you receive is so much work compared to automatic unpacking done by Retrofit via GSon/etc? This is caused because BLE data is usually very tightly packed and data format varies greatly between devices. Some devices can send Int values as one/two/three/four bytes, sometimes they are big-endian, sometimes little-endian. […]

Android RxJava Tips Tricks

RxJava

Do you want to make sure that your Rx Java Disposables are disposed from the viewModel when they are no longer needed?

Pure Rx Java solution Create CompositeDisposable as field Register all your Disposables via its add method. When you don’t need to receive more updates call clear: public class RxLifecycleViewModel extends ViewModel { private final CompositeDisposable disposables = new CompositeDisposable(); public void onAttach(final ViewInterface view) { disposables.add(Observable.interval(1, TimeUnit.SECONDS) .subscribe(aLong -> { view.updateText(aLong); })); } public void […]