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 by.krossovochkin.testflow | |
import io.reactivex.Observable | |
import io.reactivex.schedulers.Schedulers.computation | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.channels.ReceiveChannel | |
import kotlinx.coroutines.channels.produce | |
import kotlinx.coroutines.flow.* | |
import kotlinx.coroutines.selects.select |
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 com.krossovochkin.butterknifetest | |
import io.reactivex.Observable | |
import io.reactivex.subjects.BehaviorSubject | |
import org.junit.Test | |
class RxUnitTest { | |
/* Base tests */ |
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
fun hiThere(): Single<Int> { | |
return Completable.timer(1, TimeUnit.SECONDS) | |
.andThen(Single.just(40)) | |
.subscribeOn(computation()) | |
} | |
fun test() { | |
Observable.just(1) | |
.flatMapSingle { hiThere() } | |
.subscribeOn(io()) | |
.subscribe { 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
suspend fun hiThere(): Int { | |
return withContext(Dispatchers.Default) { | |
delay(1000) | |
40 | |
} | |
} | |
@Test | |
fun test() { | |
CoroutineScope(Job()).launch { | |
flowOf(1) |
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 TestViewModel : MyViewModel() { | |
init { | |
scope.launch( | |
Observable.just("10") | |
.subscribe { println("Something") } | |
) | |
Observable.just("10") | |
.doOnNext { println("something") } |
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 by.krossovochkin.testflow | |
import io.reactivex.Observable | |
import io.reactivex.exceptions.CompositeException | |
import io.reactivex.schedulers.Schedulers | |
import kotlinx.coroutines.* | |
import kotlinx.coroutines.flow.* | |
import org.junit.Test | |
import java.util.concurrent.CopyOnWriteArrayList | |
import java.util.concurrent.CountDownLatch |
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.android.synthetic.main.activity_main.* | |
class ExtensionsActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
update() | |
} |
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
private fun setTheme(theme: ThemeManager.Theme, animate: Boolean = true) { | |
if (!animate) { | |
ThemeManager.theme = theme | |
return | |
} | |
if (imageView.isVisible) { | |
return | |
} |
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() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
LayoutInflaterCompat.setFactory2( | |
LayoutInflater.from(this), | |
MyLayoutInflater(delegate) | |
) | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_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 MyLayoutInflater( | |
private val delegate: AppCompatDelegate | |
) : LayoutInflater.Factory2 { | |
override fun onCreateView( | |
parent: View?, | |
name: String, | |
context: Context, | |
attrs: AttributeSet | |
): View? { |
NewerOlder