Skip to content

Instantly share code, notes, and snippets.

View hjhjw1991's full-sized avatar
🛴

hjhjw1991 hjhjw1991

🛴
View GitHub Profile
#!/bin/zsh
ifconfig | sed -n -e '/127.0.0.1/d' -e '/inet /p' | awk '{print $2}'
@hjhjw1991
hjhjw1991 / MethodProxy.kt
Created June 15, 2020 08:36 — forked from crowjdh/MethodProxy.kt
Method proxy for Kotlin(verification necessary)
inline fun <reified T : Record> T.proxy(): T {
return Proxy.newProxyInstance(javaClass.classLoader,
arrayOf(Record::class.java),
RecordInvocationHandler(this)) as T
}
class RecordInvocationHandler<T: Record>(private val caller: T) : InvocationHandler {
override fun invoke(proxy: Any, method: Method, args: Array<Any>): Any? {
var result: Any? = null
package com.hjhjw1991
/**
* 带参数单例实现, 可复用
* 定义
* class ToSingle(arg: Any){
* companion object: SingletonHolder<ToSingle, Any> ({arg -> doInit(arg)})
* }
* 使用
* ToSingle.getInstance(arg).xxx
@hjhjw1991
hjhjw1991 / HJGradientAlphaImageView.kt
Last active July 19, 2023 06:54
透明度渐变、线性渐变的 ImageView
package com.huangjun.barney.views
import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatImageView
import kotlin.math.max
import kotlin.math.min
/**