Skip to content

Instantly share code, notes, and snippets.

View WendyYanto's full-sized avatar

Wenn WendyYanto

  • Singapore
View GitHub Profile
class RxJavaUnitTest {
companion object {
private const val USER_ID = "USER_ID"
private const val NAME = "John Doe"
private const val AGE = 20
private const val EMPTY = ""
}
io.reactivex.rxjava3.exceptions.OnErrorNotImplementedException: The exception was not handled due to missing onError handler in the subscribe() method call. Further reading: https://github.com/ReactiveX/RxJava/wiki/Error-Handling | java.lang.Exception: UserID is invalid
class RxJavaErrorUnitTest {
companion object {
private const val DEFAULT_USER = "DEFAULT_USER"
}
@Test
fun getUserTest() {
getUser()
.onErrorReturnItem(DEFAULT_USER)
@Test
fun undeliverableException() {
Observable.create<String> { sink ->
sink.onNext(USER)
sink.onComplete()
sink.onError(Exception())
}.subscribe(::println)
}
io.reactivex.rxjava3.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | java.lang.Exception
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<WebView
android:id="@+id/wv_main"
class MainActivity : AppCompatActivity() {
companion object {
private const val URL = "https://www.google.com"
}
private lateinit var webView: WebView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
webView.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(
view: WebView?,
request: WebResourceRequest?
): Boolean {
return super.shouldOverrideUrlLoading(view, request)
}
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
webView.webViewClient = object : WebViewClient() {
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
showLoading()
}
override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
dismissLoading()
}