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' }
		}
	}
Copy the code

Step 2. Add the dependency

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

Feature

  • toast
_toast("hello")
_long_toast("hello")
Copy the code

  • dp,sp,px
_dip2px(20)
_sp2px(20)
.
Copy the code

  • SharedPreference

config in your application

SharedPreferenceImpl.init(this."name")Copy the code

then

sp_saveString("key"."value")
sp_getString("key")
.
Copy the code

  • async
val t = _async {
    Thread.sleep(3000)
    _runUI {
      hello.text = "hello"
    }
}
t.cancel()
Copy the code

  • startActivity/Sercice
_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)
.
Copy the code

  • loadColor/Drawable
_loadColor(R.color.f)
_loadDrawable(R.drawable.f)
.
Copy the code

  • log
//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")
.
Copy the code