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
package <Whatever Package Ya Want Really> | |
import android.os.Handler | |
import io.mockk.every | |
import io.mockk.mockk | |
import java.util.concurrent.CountDownLatch | |
/** | |
* TestHandler provides a way to execute tests that require a [Handler]. | |
* |
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
class Solution { | |
fun isRobotBounded(instructions: String): Boolean { | |
val robot = Robot() | |
repeat(4) { | |
instructions.forEach { instruction -> | |
when (instruction) { | |
'G' -> robot.move() | |
'R' -> robot.turnRight() | |
'L' -> robot.turnLeft() | |
} |
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
import kotlinx.coroutines.experimental.GlobalScope | |
import kotlinx.coroutines.experimental.channels.Channel | |
import kotlinx.coroutines.experimental.channels.Channel.Factory.CONFLATED | |
import kotlinx.coroutines.experimental.channels.Channel.Factory.UNLIMITED | |
import kotlinx.coroutines.experimental.channels.sendBlocking | |
import kotlinx.coroutines.experimental.launch | |
fun main(args: Array<String>) { | |
val channels = listOf<Channel<Int>>( | |
Channel(capacity = UNLIMITED), |
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
public class DisposingObserver<T> implements Observer<T> { | |
@Override | |
@CallSuper | |
public void onSubscribe(Disposable d) { | |
DisposableManager.add(d); | |
} | |
@Override | |
public void onNext(T next) {} |
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
public class DisposableManager { | |
private static CompositeDisposable compositeDisposable; | |
public static void add(Disposable disposable) { | |
getCompositeDisposable().add(disposable); | |
} | |
public static void dispose() { | |
getCompositeDisposable().dispose(); |
NewerOlder