Kotlin extensions for android. 😏
Kotlin
Clone or download
VictorChow Merge pull request #17 from pdog18/master
1. merge NumberExt.kt to DisplayExt.kt
Latest commit e08e913 Apr 10, 2018
Permalink
Failed to load latest commit information.
ext 1. merge NumberExt.kt to DisplayExt.kt Apr 3, 2018
gradle/wrapper fix bug Dec 9, 2017
.gitignore init Aug 18, 2017
DETAIL.md update readme Dec 18, 2017
LICENSE Initial commit Aug 18, 2017
README.md update readme Dec 18, 2017
build.gradle fix bug Dec 9, 2017
gradle.properties init Aug 18, 2017
gradlew init Aug 18, 2017
gradlew.bat init Aug 18, 2017
settings.gradle init Aug 18, 2017

README.md

KotlinAndroidLib

一些Android开发的扩展。

[点这查看所有支持的扩展API(readmore)]

Usage

//初始化
Ext.with(application)

Gradle

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
//依赖项
//org.jetbrains.kotlin:kotlin-stdlib-jre
//com.android.support:appcompat-v7

dependencies {
    compile 'com.github.VictorChow:kotlin-android-lib:1.2.2'
}

Brief

ViewExt

//设置宽高
fun View.setWidth(value: Int)
fun View.setHeight(value: Int)
fun View.resize(width: Int, height: Int)
...

CommonExt

fun findColor(@ColorRes resId: Int) 
fun findDrawable(@DrawableRes resId: Int)
fun findColorStateList(@ColorRes resId: Int)
...

DisplayExt

val screenWidth: Int
val screenHeight: Int
val screenDensity: Float
...

DateTimeExt

fun Long.year()
fun Long.month()
fun Long.day()
...

StringExt

fun String.toast()
fun String.md5()
fun String.sha1()
...

ListenerExt

fun Animator.addListener {
    onStart { }
    onCancel { }
    onEnd { }
    onRepeat { }
}

fun Animator.addPauseListener {
    onPause { }
    onResume { }
}
...

ManagerExt

val connectivityManager
val alarmManager
val telephonyManager
val activityManager
...

SharedPreferencesExt

fun spSetInt(key: String, value: Int)
fun spGetInt(key: String, defaultValue: Int = 0)
...

BitmapExt

fun Bitmap.toBase64(): String
fun Bitmap.resize(w: Number, h: Number): Bitmap
...

FileExt

fun File.copy(dest: File)
fun File.copyDirectory(dest: File)
...

ToastExt

fun toast(msg: Any, isShort: Boolean = true) 

ActivityExt

fun Activity.goActivity<T>()
fun Activity.goActivity<T>(requestCode: Int)
...

FragmentExt (support.v4)

fun Fragment.goActivity<T>()
fun Fragment.goActivity<T>(requestCode: Int)
...

ActivityMgr

fun add(activity: Activity)
fun remove(activity: Activity)
fun removeAll()
...

ApiExt

fun aboveApi(api: Int, included: Boolean = false, block: () -> Unit)
fun belowApi(api: Int, included: Boolean = false, block: () -> Unit)

[点这查看所有支持的扩展API(readmore)]