Testing asynchronous RxJava code using Mockito
Restart service if start_sticky on Xiaomi
Service does not restart after a user kill a application on Xiaomi devices even we use
[code language="java"] @Override public int onStartCommand(Intent intent, int flags, int startId) { return START_STICKY; } [/code]
CV of IT pro
Loading data from few sources by rxjava
[code language=”java”]
Observable<Data> memory = …;
Observable<Data> disk = …;
Observable<Data> network = …;
// Retrieve the first source with data
Observable<Data> source = Observable
.concat(memory, disk, network)
.first();
[/code]
Save data to cache
[code language=”java”]
Observable<Data> networkWithSave = network.doOnNext(data -> {
saveToDisk(data);
cacheInMemory(data);
});
Observable<Data> diskWithCache = disk.doOnNext(data -> {
cacheInMemory(data);
});
[/code]
Update data
[code language=”java”]
Observable<Data> source = Observable
.concat(memory, diskWithCache, networkWithSave)
.first(data -> data.isUpToDate());
[/code]