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
| import kotlinx.coroutines.* | |
| import kotlinx.coroutines.flow.* | |
| import kotlinx.coroutines.sync.* | |
| interface AsyncResource<out T> { | |
| sealed interface State<out T> { | |
| data object NotStarted : State<Nothing> | |
| data class Loading<out T>(val currentResource: Completed<T>?) : State<T> | |
| sealed interface Completed<out T> : State<T> { |
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
| import android.view.View | |
| import android.widget.ScrollView | |
| fun ScrollView.smoothScrollToViewBottom(view: View) { | |
| val scrollViewHeight = height | |
| val outViewPosition = IntArray(2) | |
| view.getLocationOnScreen(outViewPosition) | |
| val viewY = outViewPosition[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
| import android.app.Activity | |
| import android.view.LayoutInflater | |
| import android.view.View | |
| import android.view.ViewGroup | |
| import androidx.fragment.app.DialogFragment | |
| import androidx.fragment.app.Fragment | |
| import androidx.lifecycle.DefaultLifecycleObserver | |
| import androidx.lifecycle.Lifecycle | |
| import androidx.lifecycle.LifecycleOwner | |
| import androidx.lifecycle.Observer |
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
| android { | |
| namespace = "" | |
| compileSdk = 34 | |
| defaultConfig { | |
| applicationId = "" | |
| minSdk = 21 | |
| targetSdk = 34 | |
| versionCode = 1 | |
| versionName = "1.0" |
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
| function Convert-ImageToAscii( | |
| [Parameter(ParameterSetName = "A")] | |
| [string] $Path, | |
| [Parameter(ParameterSetName = "B")] | |
| [System.Drawing.Bitmap] $Image, | |
| [switch] $UseAlpha | |
| ) { | |
| $bitMap = if ($Path) { | |
| [System.Drawing.Bitmap]::FromFile((Resolve-Path $Path)) | |
| } |
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 getAllDivisiblePairsInRangeCount( | |
| start: Int, | |
| end: Int, | |
| ignoreSelfDivision: Boolean = false, | |
| ): Int { | |
| require(start != 0) { | |
| "start parameter can't be $start" | |
| } | |
| require(start <= end) { | |
| "start '$start' must be less or equal to end '$end'" |
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
| // Based on: https://stackoverflow.com/questions/23323823/android-countdowntimer-tick-is-not-accurate | |
| abstract class SimplePreciseTimer @JvmOverloads constructor( | |
| periodInMillis: Long = 1, | |
| ) : java.util.Timer(true) { | |
| private var task = newTask() | |
| private var hasStarted = false | |
| private var isRunning = false | |
| var periodInMillis = periodInMillis |
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
| import android.graphics.drawable.Drawable | |
| import android.os.Build | |
| import androidx.annotation.ArrayRes | |
| import androidx.annotation.BoolRes | |
| import androidx.annotation.ColorRes | |
| import androidx.annotation.DimenRes | |
| import androidx.annotation.DrawableRes | |
| import androidx.annotation.IntegerRes | |
| import androidx.annotation.PluralsRes | |
| import androidx.annotation.RequiresApi |
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
| import java.util.Locale | |
| // [...] | |
| android { | |
| defaultConfig { | |
| // [...] | |
| val defaultLocale = Locale("en") | |
| val appLocales = getAppLocales(defaultLocale) |
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
| import kotlin.reflect.KClass | |
| fun main() { | |
| val baseDependencies = listOf( | |
| Gun(bullets = 50), | |
| Hammer(power = 100), | |
| ) | |
| val dependencyClasses = listOf( | |
| Hero::class, |