The Wayback Machine - https://web.archive.org/web/20221031151910/https://github.com/costular/kotlin-android-utils
Skip to content

costular/kotlin-android-utils

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

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

Logo

Build Status Download license

Android utilities for easier and faster Kotlin programming.

Download

Gradle

compile 'com.costular:kotlin-utils:0.1'

How to use

It depends on utilities. Some of them just work as function extensions and you don't have to do anything special, just call a method like another one.

API

Activity

setFullScreen()
showToolbar() // Support and native
hideToolbar() // Support and native

Context

getClipboardManager()
copyTextToClipboard(value: String)
copyUriToClipboard(uri: Uri)
getTextFromClipboard(): CharSequence
getUriFromClipboard(): Uri?
getPreferences(): SharedPreferences
getPreferences(name: String, mode: Int): SharedPreferences

SharedPreferences

SharedPreferences.use(lambda)

It automatically applies after lambda execution

val sharedPrefs = context.getPreferences()
sharedPrefs.edit {
    putBoolean("first_use", false) // This refers to sharedPrefs instance
}

Versions

These methods are static.

doWithVersion(version: Int, lambda) // ==
doWithAtLeastVersion(version: Int, lambda) // >=
doWithHigherVersion(version: Int, lambda) // >
doWithLowerVersion(version: Int, lambda) // <

Example

doWithAtLeastVersion(21) {
    // Do something on Lollipop version or higher
}