Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
compile 'com.github.littlejigege:suger:v0.0.8.5'
//用到库中的JsonWrapper才要拉
implementation 'com.google.code.gson:gson:2.8.2'
//用到库中的协程才要
compile "org.jetbrains.kotlinx:kotlinx-coroutines-android:0.19.2"
}
init it in your Application.class
override fun onCreate() {
super.onCreate()
Utils.init(this)
}
Readme Progress
- request permission
- open local alubm
- EasyNotifyAdapter
- ImageUtils
- ToastUtils
First create an activity extend AlbumPickerActivity
//获取权限
Permission.STORAGE.doAfterGet(this){
//选择照片
AlbumPicker.with(this).selectedPicAndHandle { path ->
print("this is the path of the photo you choose $path")
}
}
//easy to save
Preference.save("settings") {
"key" - "value"
"key1" - "value1"
//...
}
//easy to get
Preference.get("settings","key" to "defaultValue")
first you need to extends PermissionActivity or PermissionCompatActivity
class MyActivity : PermissionActivity() {
}
Permission中有所有的危险权限组
下面用读写权限举例
你可以获取他:
Permission.STORAGE.get(this){
//isPassed是回调,通过的话是true
isPassed -> if(isPassed) showToast("ok") else showToast("no")
}
你可以指定一段代码在获取某个权限后执行:
Permission.STORAGE.doAfterGet(this){
//只有权限痛过才会执行,保证安全
showToast("66666")
}
你也可以单独检查是否获得某个权限:
Permission.STORAGE.has()