@deprecated
XMLレイアウト時代に @okuzawatsさんが管理してくれていたライブラリです。Composeレイアウトになっていたり、メンテナーがいなくなっていたりで利用を推奨していません。
a small library extending Kotlin for Android.
include maven to your project build.gradle.
allprojects {
repositories {
maven {
url 'https://fuller-inc.github.io/yakan/repository'
}
}
}
then include implementation to your app/build.gradle or something.
dependencies {
implementation "jp.co.fuller:yakan:x.y.x"
// View extensions
implementation "jp.co.fuller:yakan.view:x.y.x"
// LiveData extensions
implementation "jp.co.fuller:yakan.livedata:x.y.x"
}
unwrap() unwraps nullable value.
any.unwrap()isNull() returns true if null.
any.isNull()isNotNull() returns true if not null.
any.isNotNull()isTrue() returns true if not null and true.
boolean.isTrue()isFalse() returns true if not null and false.
boolean.isFalse()succ() returns successor.
int.succ()safeSucc() returns successor or throw exception if the value is Int.MAX_VALUE.
int.safeSucc()pred() and safePred() is the predecessor version of succ() and safeSucc(). Also, you can use hasSucc() and hasPred() to check if successor or predecessor exists.
isEven and isOdd returns a boolean that represents the number is even or odd.
int.isEven
int.isOddtoStringWithSeparator() returns to string with specified country's separators.
if the value is 123456, and locale is jp, returns to "123,456".
default locale is Locale.US
int.toStringWithSeparator(locale = Locale.JAPAN)same as Int.
View.setOnSingleClickListener set view a click listener that ignores "double click" event.
button.setOnSingleClickListener {
// some events
}EventLiveData<T> is a subtype of MutableLiveData that do not hold a value after emitting a value.
val liveData = EventLiveData<Boolean>()
liveData.value = true // emitting once, and don't hold a value.LiveData<T>.filter filter LiveData that emits value by predicate.
liveData.filter { it == true }merge merges any number of LiveData and emits latest values.
val mergedData = merge(liveData1, liveData2)
liveData1.value = true // mergedData emits `true`.map converts LiveData the type parameter T to R.
liveData.value = 123
val convertedData = liveData.map { it.toString() } // convertedData emits "123", String type.combineLatest combines some LiveData and emits a new value.
val combinedData = combineLatest(liveData1, liveData2) { live1, live2 ->
"${live1} and ${live2}"
}
liveData1.value = "test"
liveData2.value = true // combinedData emits "test and true".