View NanoRedux.kt
import kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.cancel | |
import timber.log.Timber | |
interface State | |
interface Action | |
interface Effect | |
interface Screen<T : State> { |
View AndroidBaseFragment.kt
import android.os.Bundle | |
import androidx.annotation.LayoutRes | |
import androidx.fragment.app.Fragment | |
open class BaseFragment(@LayoutRes contentLayoutId: Int) : Fragment(contentLayoutId) { | |
protected lateinit var runId: String | |
private set | |
private var instanceStateSaved: Boolean = false | |
override fun onCreate(savedInstanceState: Bundle?) { |
View KotlinBase64.kt
import io.ktor.utils.io.core.String | |
private const val BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" | |
private val BASE64_INVERSE_ALPHABET = IntArray(256) { BASE64_ALPHABET.indexOf(it.toChar()) } | |
fun String.encodeBase64(): String = String(encodeBase64ToByteArray()) | |
fun String.encodeBase64ToByteArray(): ByteArray = encodeToByteArray().encodeBase64() | |
fun ByteArray.encodeBase64ToString(): String = String(encodeBase64()) | |
fun String.decodeBase64(): String = String(decodeBase64ToByteArray()) |
View SmartField.kt
import android.text.Editable | |
import android.text.TextWatcher | |
import android.view.View | |
import android.widget.EditText | |
/** | |
* Created by Konstantin Tskhovrebov (aka @terrakok) on 18.09.17. | |
*/ | |
class SmartField<T: Any>( | |
private val editText: EditText, |
View SimpleDividerDecorator.kt
/** | |
* Created by Konstantin Tskhovrebov (aka @terrakok) on 25.08.17. | |
*/ | |
class SimpleDividerDecorator( | |
private val dividerSizePx: Int, | |
dividerColor: Int | |
) : RecyclerView.ItemDecoration() { | |
private val paint = Paint().apply { color = dividerColor } | |
View Extension.kt
fun Resources.color(colorRes: Int) = | |
if (Build.VERSION.SDK_INT >= 23) { | |
this.getColor(colorRes, null) | |
} else { | |
this.getColor(colorRes) | |
} | |
fun ViewGroup.inflate(@LayoutRes layoutRes: Int, attachToRoot: Boolean = false): View { | |
return LayoutInflater.from(context).inflate(layoutRes, this, attachToRoot) | |
} |
View MoxyMapFragment.kt
import android.os.Bundle | |
import android.support.annotation.LayoutRes | |
import android.support.v4.app.Fragment | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import com.arellomobile.mvp.MvpDelegate | |
import com.google.android.gms.maps.GoogleMap | |
import com.google.android.gms.maps.MapView | |
import com.google.android.gms.maps.OnMapReadyCallback |
View CurlLoggingInterceptor.kt
/* | |
* Copyright (C) 2016 Jeff Gilfelt. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |