Skip to content

HelpfulUtils

Jacob Rein edited this page May 5, 2020 · 16 revisions

implementation 'com.github.jakepurple13.HelpfulTools:helpfulutils:{version}'

There are lots of utilities here. These are ones that don't fit into the other categories but aren't considered "fun".

requestPermissions(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE) {
    println(it.isGranted)
    println(it.grantedPermissions)
    println(it.deniedPermissions)
}
BiometricBuilder.biometricBuilder(/*FragmentActivity*/) {

    authSuccess {
        "Success"
    }

    authError { _, _ ->
        "Error"
    }

    authFailed {
        "Failed"
    }

    error {
        "Error"
    }

    promptInfo {
        title = "Testing"
        subtitle = "Tester"
        description = "Test"
        negativeButton = null
        confirmationRequired = true
        deviceCredentialAllowed = true
    }
}
val time: BroadcastReceiver = Context.timeTick { _, _ -> println("Runs every minute") }

val batteryInfo: BroadcastReceiver = Context.battery { info: Battery -> println(info) } 

val screenOff: BroadcastReceiver = Context.screenOff { _,_ -> println("Screen turned off") } 
val screenOn: BroadcastReceiver = Context.screenOn { _,_ -> println("Screen turned on") } 
var Context.key: String? by sharedPrefDelegate()

val Context.sharedPref get() = defaultSharedPref

You can dynamically add items at anytime

recyclerView.quickAdapter(R.layout.support_simple_spinner_dropdown_item, "Hello", "World") {
    //this is to render the view
    println(it)
}
recyclerView.quickAdapter(R.layout.support_simple_spinner_dropdown_item, "Jake", "Purple") {
    //this is to render the view
    println(it)
}
Clone this wiki locally