View Custom view template
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 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 { |
View NullableBooleansTest
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 NullableBooleansTest { | |
enum class Result { OK, NOT } | |
private fun testNullableBooleanWhen( | |
nullableBoolean: Boolean?, | |
check: (Boolean?) -> Boolean, | |
resulting: Result | |
) { | |
val result = if (check(nullableBoolean)) { |
View SchedulersRule
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 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 | |
} |
View KoinExtensions.kt
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 ru.mobileup.midhub.extension | |
import org.koin.android.ext.koin.androidApplication | |
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 | |
/** |
View EnterStringDialogFragment.kt
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 ru.mobileup.businessnavigator.ui.base.dialog | |
import android.app.Dialog | |
import android.content.Context | |
import android.os.Bundle | |
import android.support.annotation.LayoutRes | |
import android.support.annotation.StringRes | |
import android.support.v7.app.AlertDialog | |
import android.support.v7.app.AppCompatDialogFragment | |
import android.text.Editable |
View Extensions.kt
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
inline fun SharedPreferences.edit(changes: SharedPreferences.Editor.() -> SharedPreferences.Editor) { | |
edit().changes().apply() | |
} | |
fun ImageView.tintSrc(@ColorRes colorRes: Int) { | |
val drawable = DrawableCompat.wrap(drawable) | |
DrawableCompat.setTint(drawable, ContextCompat.getColor(context, colorRes)) | |
setImageDrawable(drawable) | |
if (drawable is TintAwareDrawable) invalidate() // Because in this case setImageDrawable will not call invalidate() | |
} |
View SpinnerWithHintAdapter.java
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
/** | |
* @author Vasili Chyrvon (vasili.chyrvon@gmail.com) | |
*/ | |
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 { |
View ProgressDimDialogFragment.kt
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
/** | |
* Dialog fragment showing progress widget on dimmed screen. | |
* @author Vasili Chyrvon (vasili.chyrvon@gmail.com) | |
*/ | |
class ProgressDimDialogFragment : AppCompatDialogFragment() { | |
companion object { | |
val TAG = "ProgressDimDialogFragment" | |
private val ARGS_DISPATCH_BACK_PRESS = "args_dispatches_back_press" |
View RxPM vs MVP
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
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. | |
Pros: | |
- 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. |
View EnterStringDialogFragment.java
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 ru.mobileup.myalarm2.ui.dialog; | |
import android.app.Activity; | |
import android.app.Dialog; | |
import android.os.Bundle; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.StringRes; | |
import android.support.v7.app.AlertDialog; | |
import android.support.v7.app.AppCompatDialogFragment; | |
import android.widget.EditText; |
NewerOlder