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 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 = "" | |
} |
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
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 |
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 RxJavaErrorUnitTest { | |
companion object { | |
private const val DEFAULT_USER = "DEFAULT_USER" | |
} | |
@Test | |
fun getUserTest() { | |
getUser() | |
.onErrorReturnItem(DEFAULT_USER) |
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
DEFAULT_USER |
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
@Test | |
fun undeliverableException() { | |
Observable.create<String> { sink -> | |
sink.onNext(USER) | |
sink.onComplete() | |
sink.onError(Exception()) | |
}.subscribe(::println) | |
} |
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
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 |
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
<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" |
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 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) |
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
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) |
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
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() | |
} |