android kotlin extensions.
Step 1. Add Jitpack repository to your project build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add dependency to your app build.gradle
dependencies {
implementation 'com.github.yusuke-na:android-nay-ktex:1.0.0'
}
One Shot LiveData. Notified to the observer when calling a call
method.
val showEvent = LiveEvent<Boolean>()
fun callShowEvent(isShow: Boolean) {
showEvent.call(isShow)
}
Activity and Fragment create Observer with this LiveEvent tag.
viewModel.showEvent.observe(this, "tag") { isShow ->
// add your code.
}
Create a lifecycleScope easily.
Lifecycle's Event Trigger Propagating LifecycleObserver.
this@MainActivity.lifecycle.addObserver {
doOnStart { registerReceiver(receiver, IntentFilter(BROADCAST_DEFAULT_ALBUM_CHANGED)) }
doOnStop { unregisterReceiver(receiver) }
}
Create a BroadcastReceiver easily.
val receiver = broadcastReceiver { context, intent ->
when (intent?.action) {
BROADCAST_DEFAULT_ALBUM_CHANGED -> handleAlbumChanged()
BROADCAST_CHANGE_TYPE_CHANGED -> handleChangeTypeChanged()
}
}
- NonNullCheck functions
- TimerUtil (ex.. Format timeInMillis to 'HH:mm:ss' or 'HH:mm:ss.SSS'.
- ByteArray
- Collection
- Context
- Double
- Float
- Int
- Short
- String
- Uri
- View