Kotlin extensions for android. 😏
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ext
gradle/wrapper
.gitignore
DETAIL.md
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

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.3'
}

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)]