Skip to content

Instantly share code, notes, and snippets.

View nasserkhosravi's full-sized avatar

nâsser xosravi nasserkhosravi

View GitHub Profile
@nasserkhosravi
nasserkhosravi / modular_deeplink_query.kt
Last active October 16, 2024 16:13
Modular lazy function pattern in kotlin
@nasserkhosravi
nasserkhosravi / rxscheduler.kt
Created August 19, 2022 19:10
Interfacing Rx Schedulers
import io.reactivex.Scheduler
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
class DefaultSchedulerProvider : SchedulerProvider {
override fun io(): Scheduler = Schedulers.io()
override fun ui(): Scheduler = AndroidSchedulers.mainThread()
override fun computation(): Scheduler = Schedulers.computation()
override fun trampoline(): Scheduler = Schedulers.trampoline()
@nasserkhosravi
nasserkhosravi / TestDataGenerator.kt
Last active February 25, 2023 07:54
Update aFloat function
import kotlin.random.Random
import kotlin.reflect.KMutableProperty
import kotlin.reflect.KProperty
fun <T> Array<T>.aElement(): T {
require(this.isNotEmpty())
return this[Random.nextInt(0, size - 1)]
}
fun aBoolean(random: Random = Random): Boolean {
@nasserkhosravi
nasserkhosravi / NumberTextWatcher.kt
Last active May 31, 2020 08:12
//- Add separator to text each 3 number //- Handle selection when selection position is after separator
package com.nasserkhosravi.uikit
import android.text.Editable
import android.text.SpannableStringBuilder
import android.text.TextWatcher
import android.widget.EditText
import android.widget.TextView
/**
* Your [EditText] should have ltr layout direction