Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
ext
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

KotlinAndroidLib

一些Android开发的扩展。

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

2.x - AndroidX

1.x - Android Support

Usage

//初始化
Ext.with(application)

Gradle

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
//依赖项
//org.jetbrains.kotlin:kotlin-stdlib-jdk7

2.x
dependencies {
    compile 'com.github.VictorChow:kotlin-android-lib:2.0.0'
}

1.x
dependencies {
    compile 'com.github.VictorChow:kotlin-android-lib:1.2.4'
}

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

You can’t perform that action at this time.