一些Android开发的扩展。
//初始化
Ext.with(application)
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
//依赖项
//org.jetbrains.kotlin:kotlin-stdlib-jdk7
2.x
dependencies {
implementation 'com.github.VictorChow:kotlin-android-lib:2.0.0'
}
1.x
dependencies {
implementation 'com.github.VictorChow:kotlin-android-lib:1.2.4'
}
//设置宽高
fun View.setWidth(value: Int)
fun View.setHeight(value: Int)
fun View.resize(width: Int, height: Int)
...
fun findColor(@ColorRes resId: Int)
fun findDrawable(@DrawableRes resId: Int)
fun findColorStateList(@ColorRes resId: Int)
...
val screenWidth: Int
val screenHeight: Int
val screenDensity: Float
...
fun Long.year()
fun Long.month()
fun Long.day()
...
fun String.toast()
fun String.md5()
fun String.sha1()
...
fun Animator.addListener {
onStart { }
onCancel { }
onEnd { }
onRepeat { }
}
fun Animator.addPauseListener {
onPause { }
onResume { }
}
...
val connectivityManager
val alarmManager
val telephonyManager
val activityManager
...
fun spSetInt(key: String, value: Int)
fun spGetInt(key: String, defaultValue: Int = 0)
...
fun Bitmap.toBase64(): String
fun Bitmap.resize(w: Number, h: Number): Bitmap
...
fun File.copy(dest: File)
fun File.copyDirectory(dest: File)
...
fun toast(msg: Any, isShort: Boolean = true)
fun Activity.goActivity<T>()
fun Activity.goActivity<T>(requestCode: Int)
...
fun Fragment.goActivity<T>()
fun Fragment.goActivity<T>(requestCode: Int)
...
fun add(activity: Activity)
fun remove(activity: Activity)
fun removeAll()
...
fun aboveApi(api: Int, included: Boolean = false, block: () -> Unit)
fun belowApi(api: Int, included: Boolean = false, block: () -> Unit)