Skip to content

Instantly share code, notes, and snippets.

View Jeevuz's full-sized avatar

Vasili Chyrvon Jeevuz

View GitHub Profile
import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.core.content.withStyledAttributes
class MyCustomView(
context: Context,
attrs: AttributeSet? = null
) : View(context, attrs) {
init {
class NullableBooleansTest {
enum class Result { OK, NOT }
private fun testNullableBooleanWhen(
nullableBoolean: Boolean?,
check: (Boolean?) -> Boolean,
resulting: Result
) {
val result = if (check(nullableBoolean)) {
Jeevuz / SchedulersRule
Last active December 17, 2019 10:24
Test Rule to test the classes with rx shedulers
class SchedulersRule(private val useTestScheduler: Boolean = false) : ExternalResource() {
private lateinit var _testScheduler: TestScheduler
val testScheduler: TestScheduler
get() {
if (!useTestScheduler) throw IllegalStateException("TestScheduler is switched off.")
return _testScheduler
Jeevuz / KoinExtensions.kt
Last active June 25, 2018 15:58
Helpers for Koin (0.9.3)
package ru.mobileup.midhub.extension
import org.koin.core.bean.BeanDefinition
import org.koin.core.bean.Definition
import org.koin.dsl.context.Context
import org.koin.dsl.module.Module
import org.koin.dsl.module.applicationContext
Jeevuz / EnterStringDialogFragment.kt
Last active October 26, 2020 09:10
Universal DialogFragments
package ru.mobileup.businessnavigator.ui.base.dialog
import android.content.Context
import android.os.Bundle
import android.text.Editable
Jeevuz / Extensions.kt
Last active January 3, 2023 10:25
Here I collect some of my most useful Kotlin extensions
inline fun SharedPreferences.edit(changes: SharedPreferences.Editor.() -> SharedPreferences.Editor) {
fun ImageView.tintSrc(@ColorRes colorRes: Int) {
val drawable = DrawableCompat.wrap(drawable)
DrawableCompat.setTint(drawable, ContextCompat.getColor(context, colorRes))
if (drawable is TintAwareDrawable) invalidate() // Because in this case setImageDrawable will not call invalidate()
Jeevuz /
Created June 20, 2017 14:47
Adapter for spinner with hint
* @author Vasili Chyrvon (
class SpinnerWithHintAdapter(context: Context, @LayoutRes resource: Int, @StringRes hintResId: Int) : ArrayAdapter<String>(context, resource) {
private val hintColor by lazy { getHintColorAttribute() }
private var textColors: ColorStateList? = null
private val hint by lazy { context.getString(hintResId) }
override fun isEnabled(position: Int): Boolean {
Jeevuz / ProgressDimDialogFragment.kt
Created March 30, 2017 08:36
Progress DialogFragment with only progress view on the dimmed screen
* Dialog fragment showing progress widget on dimmed screen.
* @author Vasili Chyrvon (
class ProgressDimDialogFragment : AppCompatDialogFragment() {
companion object {
val TAG = "ProgressDimDialogFragment"
private val ARGS_DISPATCH_BACK_PRESS = "args_dispatches_back_press"
Jeevuz / RxPM vs MVP
Last active April 5, 2017 19:36
Real project's part converted from MVP (with Moxy) into RxPM (with Outlast). See revisions diff.
This is real project screen with complex UI that was switched
from using the MVP with Moxy library
to the use of RxPM pattern (Reactive Presentation Model) with Outlast library (persistent PM layer).
I was doing it to see pros and cons of the RxPM pattern.
- easy integration with RxBindings for complex UI.
- nice saved states in PM (for PM and MVVM lovers).
- easy combining of reactive streams coming from network, db, etc. in PM.
Jeevuz /
Last active January 18, 2017 10:19
Dialog to ask for string to enter
package ru.mobileup.myalarm2.ui.dialog;
import android.os.Bundle;
import android.widget.EditText;