(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
/** | |
* an {@link ObservableOperator} that simulates an if-else in an RxJava Stream, it takes a {@link Map} | |
* of {@link Predicate} as key and a {@link Function} as value ... the if any emitted item passes | |
* the {@link Predicate}, this emitted item will be passed to the {@link Function} mapped to it, | |
* and this item will be invoked and it's result will continue down the stream | |
* <p> | |
* sample code : | |
* <p> | |
* {@code List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8);}<br> | |
* {@code Map<Predicate<Integer>, Function<Integer, String>> blocks = new LinkedHashMap<>(2)}<br> |
public static Observable<List<String>> paginatedThings(final Observable<Void> onNextObservable) { | |
return Observable.create(new Observable.OnSubscribe<List<String>>() { | |
@Override | |
public void call(final Subscriber<? super List<String>> subscriber) { | |
onNextObservable.subscribe(new Observer<Void>() { | |
int latestPage = -1; | |
@Override | |
public void onCompleted() { | |
subscriber.onCompleted(); |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
package com.uphyca.fragmenttest; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.support.v4.app.Fragment; | |
import android.support.v4.app.FragmentActivity; | |
import android.support.v4.app.FragmentManager; | |
import android.test.ActivityUnitTestCase; | |
import android.view.LayoutInflater; |
public final class ResultFuture implements Future<Result> { | |
private final CountDownLatch latch = new CountDownLatch(1); | |
private Result value; | |
@Override | |
public boolean cancel(boolean mayInterruptIfRunning) { | |
return false; | |
} | |
@Override |
package no.nsb.ombord; | |
import java.net.DatagramPacket; | |
import java.net.DatagramSocket; | |
import java.net.InetAddress; | |
import java.net.SocketTimeoutException; | |
import java.net.UnknownHostException; | |
import org.apache.http.util.ExceptionUtils; |