This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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? { |
This file contains hidden or 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 MyTextView | |
| @JvmOverloads | |
| constructor( | |
| context: Context, | |
| attrs: AttributeSet? = null, | |
| defStyleAttr: Int = 0 | |
| ) : AppCompatTextView(context, attrs, defStyleAttr), | |
| ThemeManager.ThemeChangedListener { | |
| override fun onFinishInflate() { |
This file contains hidden or 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
| object ThemeManager { | |
| private val listeners = mutableSetOf<ThemeChangedListener>() | |
| var theme = Theme.LIGHT | |
| set(value) { | |
| field = value | |
| listeners.forEach { listener -> listener.onThemeChanged(value) } | |
| } | |
| interface ThemeChangedListener { |
NewerOlder