Created
March 11, 2016 08:34
-
-
Save mootoh/6955e08e52a8e3bd3460 to your computer and use it in GitHub Desktop.
Zundoko.rxjava
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://twitter.com/kumiromilk/status/707437861881180160 | |
public class Zundoko { | |
private static final String TAG = "KIYOSHI"; | |
private static final String ZUN = "ズン"; | |
private static final String DOKO = "ドコ"; | |
public static void zundoko() { | |
Observable o = Observable.create(new Observable.OnSubscribe<String>() { | |
Random rand = new Random(); | |
@Override | |
public void call(Subscriber<? super String> subscriber) { | |
subscriber.onNext(rand.nextInt() % 2 == 0 ? "ズン" : "ドコ"); | |
subscriber.onCompleted(); | |
} | |
}); | |
o.repeat(100000).buffer(5).subscribe(new Action1<ArrayList<String>>() { | |
@Override | |
public void call(ArrayList<String> message) { | |
Log.d(TAG, message.toString()); | |
if (message.get(0) == ZUN && | |
message.get(1) == ZUN && | |
message.get(2) == ZUN && | |
message.get(3) == ZUN && | |
message.get(4) == DOKO) { | |
Log.d(TAG, "'キ・ヨ・シ!"); | |
System.exit(0); | |
} | |
} | |
}); | |
} | |
} |
Author
mootoh
commented
Mar 11, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment