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 junitparams.JUnitParamsRunner | |
import junitparams.Parameters | |
import org.junit.Test; | |
import org.junit.Assert.*; | |
import org.junit.Before | |
import org.junit.runner.RunWith | |
import org.junit.runners.Parameterized | |
import java.util.* |
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
Observable.fromArray(1,2,3,4) | |
.subscribeBy( | |
onNext = { | |
println(it) | |
}, | |
onComplete = { | |
println("Completed") | |
}, | |
onError = { | |
println(it.message) |
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
Observable.fromArray(1,2,3,4) | |
.subscribeBy( | |
onNext = { | |
if(it==2){ | |
throw (RuntimeException("Exception on 2")) | |
} | |
println(it) | |
}, | |
onComplete = { | |
println("Completed") |
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
Observable.fromArray(1,2,3) | |
.doOnNext { | |
if(it==2){ | |
throw (RuntimeException("Exception on 2")) | |
} | |
} | |
.onExceptionResumeNext(Observable.just(10)) | |
.subscribeBy( | |
onNext = { | |
println(it) |
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
Observable.fromArray(1,2,3) | |
.doOnNext { | |
if(it==2){ | |
throw (RuntimeException("Exception on 2")) | |
} | |
} | |
.doOnError { | |
println("Doing on error") | |
} | |
.subscribeBy( |
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
Observable.fromArray(1,2,3) | |
.doOnNext { | |
if(it==2){ | |
throw (RuntimeException("Exception on 2")) | |
} | |
} | |
.onErrorReturnItem (-1) | |
.subscribeBy( | |
onNext = { | |
println(it) |
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
Observable.fromArray(1,2,3) | |
.doOnNext { | |
if(it==2){ | |
throw (RuntimeException("Exception on 2")) | |
} | |
} | |
.onErrorReturn{ | |
t: Throwable -> | |
if(t.message=="<something you want>"){ | |
1 // Return a value based on error type |
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
Observable.fromArray(1,2,3) | |
.doOnNext { | |
if(it==2){ | |
throw (RuntimeException("Exception on 2")) | |
} | |
} | |
.retry() | |
.subscribeBy( | |
onNext = { | |
println(it) |
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
Observable.fromArray(1,2,3) | |
.doOnNext { | |
if(it==2){ | |
throw (RuntimeException("Exception on 2")) | |
} | |
} | |
.retry(3) | |
.subscribeBy( | |
onNext = { | |
println(it) |
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 RandomNumberGeneratorService:Service() { | |
private val binder: IBinder = RandomNumberGeneratorServiceBinder() | |
private lateinit var handlerThread:HandlerThread | |
private lateinit var handler: Handler | |
var randomNumber: Int = -1 | |
private val TAG = RandomNumberGeneratorService::class.java.simpleName | |
private lateinit var mNM: NotificationManager | |
private val NOTIFICATION = R.string.local_service_started | |
private val HANDLER_THREAD_NAME="random_number_generator_thread" | |
private lateinit var notificationBuilder: NotificationCompat.Builder |
OlderNewer