Skip to content

Instantly share code, notes, and snippets.

@Krosxx
Krosxx / RangeLoop.kts
Created December 18, 2019 09:23
kotlin [多层嵌套循环] 转换成一行
fun <T : Comparable<T>> loop(vararg range: Iterable<T>, action: (List<T>) -> Unit) {
if (range.isEmpty()) return
startLoop(range.size, range, listOf(), action)
}
fun <T : Comparable<T>> startLoop(
rawSize: Int,
rs: Array<out Iterable<T>>,
ps: List<T>,
action: (List<T>) -> Unit
@Krosxx
Krosxx / SmartKeyDataStore.kt
Created June 29, 2020 09:03
PreferenceDataStore for SmartKey
import androidx.preference.PreferenceDataStore
import cn.vove7.smartkey.BaseConfig
import cn.vove7.smartkey.get
/**
* # SmartKeyDataStore
*
* Created on 2020/6/29
* @author Vove
@Krosxx
Krosxx / CustomLinkMovementMethod.java
Created July 2, 2020 03:32
解决 ClickSpan 与 TextView 点击事件冲突 tv.movementMethod = CustomLinkMovementMethod()
import android.text.Layout;
import android.text.NoCopySpan;
import android.text.Selection;
import android.text.Spannable;
import android.text.method.MovementMethod;
import android.text.method.ScrollingMovementMethod;
import android.text.style.ClickableSpan;
import android.view.KeyEvent;
import android.view.MotionEvent;
@Krosxx
Krosxx / KtorExceptionHandler.kt
Created July 16, 2020 03:03
Call ExceptionHandler for Ktor
import io.ktor.application.*
import io.ktor.http.HttpStatusCode
import io.ktor.response.respond
import io.ktor.util.AttributeKey
import io.ktor.util.pipeline.PipelinePhase
typealias DoHandlerExp = suspend (ApplicationCall, Throwable) -> Unit
class ExceptionHandler(
@Krosxx
Krosxx / MultiTypeBindingAdapter.kt
Created July 16, 2020 06:26
DataBindingAdapter for RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import kotlin.reflect.KClass
/**
@Krosxx
Krosxx / ViewPropertiesDelegate.kt
Created August 7, 2020 03:50
View 属性代理
import android.view.View
import android.widget.Spinner
import android.widget.TextView
import kotlin.reflect.KProperty
/**
* View 属性代理
*
* @param V : View
@Krosxx
Krosxx / flutter_aar_upload.gradle
Created March 11, 2021 10:55
Flutter module upload aar to maven
// This script is used to initialize the build in a module or plugin project.
// During this phase, the script applies the Maven plugin and configures the
// destination of the local repository.
// The local repository will contain the AAR and POM files.
void configureProject(Project project, String mavenUrl, String mavenUser, String mavenPwd, String version) {
if (!project.hasProperty("android")) {
throw new GradleException("Android property not found.")
}
if (!project.android.hasProperty("libraryVariants")) {