Kotlin-Extract

Introduction: Kotlin 常用的扩展方法,提升 Android 开发效率不止一点点
More: Author   ReportBugs   
Tags:
android-kotlin-

Kotlin-Extract is a "toolbox" for Kotlin Android developer. like anko , The library contains a lot of helpers for Android SDK, including, but not limited to:

depend

Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

Step 2. Add the dependency

    dependencies {
            compile 'com.github.jiang111:Kotlin-Extract:lasted_version'
    }

Feature

  • toast ```java

_toast("hello") _long_toast("hello")

>* dp,sp,px
```java

_dip2px(20)
_sp2px(20)
...
  • SharedPreference

config in your application

SharedPreferenceImpl.init(this, "name")

then


sp_saveString("key","value")
sp_getString("key")
...
  • async ```java

val t = _async { Thread.sleep(3000) _runUI { hello.text = "hello" } } t.cancel()


>* startActivity/Sercice
```java

_startActivity<Activity>("id" to 5, "name" to "hello", "age" to 12, "male" to true)
_startService<Service>("id" to 5, "name" to "hello", "age" to 12, "male" to true)
...
  • loadColor/Drawable ```java

_loadColor(R.color.f) _loadDrawable(R.drawable.f) ...


>* log
```java
//in Application
LogImpl.init(debug,tag)
// use in any class
_i(msg="msg",tag="tag")
_i(msg="msg")
_json(msg="msg",tag="tag")
_json(msg="msg")
...
  • View ```java view.hide() view.show() view.invisible() view.toggle() view.fadeIn() view.fadeOut() EditText.showKeyBoard()

```

Apps
About Me
GitHub: Trinea
Facebook: Dev Tools