Skip to content

Releases: NightGoat/KEXtensions-android

1.0.2

30 Jun 18:15
Compare
Choose a tag to compare
Merge remote-tracking branch 'origin/master'

0.1.4

30 Nov 17:03
744f15b
Compare
Choose a tag to compare
  • inlined Try method
  • ifNotEmpty, ifNotBlank ext
  • toOrZero ext

0.1.3.4

20 Nov 19:54
Compare
Choose a tag to compare
gradle 7 maven fix 5

0.1.1

16 Sep 13:55
a9a02ba
Compare
Choose a tag to compare
  • loggD
  • Try fix
  • fun Date.rebuildWithFormat

0.1.0

29 Aug 11:01
b41c4be
Compare
Choose a tag to compare
  • Try class
  • some Numeric ext

0.0.9.1

31 Jul 13:51
Compare
Choose a tag to compare
  • updated libraries and graddle
  • View, Activity, Fragment show/hide keyboard ext
  • fragment window width ext
  • HorisontalScrollView ext
  • New extentions for working with dates
  • missleading naming improvments

0.0.8

24 Jul 14:00
0e3f960
Compare
Choose a tag to compare
  • Boolean to string and vice versa transformations
  • MutableList swapping methods
  • Date to String map
  • Numeric to Boolean transofrmations
  • MutableLiveData extentions
  • Constants classes: KexConstants and DateFormats
  • Option to turn off that nasty logging everywhere

0.0.7

04 Jul 16:41
d76dd97
Compare
Choose a tag to compare
  • LongExt
fun Long?.orZero(): Long = this ?: 0L
fun Long.toNegative(): Long = -abs(this)
fun Long.toPositive(): Long = abs(this)
fun Long.reverse(): Long = this.unaryMinus()
fun Long.takeIfZero(): Long? = this.takeIf { it == 0L }
fun Long.takeIfNotZero(): Long? = this.takeIf { it != 0L }
fun Long?.toStringOrEmpty() = this?.toString().orEmpty()
fun Long.takeIfZeroOrEmpty() = this.takeIf { it == 0L }?.toStringOrEmpty()
  • DoubleExt
fun Double.toNegative() = -abs(this)
fun Double.toPositive() = abs(this)

fun Double.reverse() = this.unaryMinus()

fun Double.takeIfZero() = this.takeIf { it == 0.0 }
fun Double.takeIfNotZero() = this.takeIf { it != 0.0 }
  • IntExt
fun Int?.toStringOrEmpty() = this?.toString().orEmpty()
fun Int.takeIfZeroOrEmpty() = this.takeIf { it == 0 }?.toStringOrEmpty()
  • CollectionsExt
fun <T, R> List<T>.mapAndFind(map: (T) -> R, find: (R) -> Boolean) = this.asSequence()
    .map(map)
    .find(find)
  • BooleanExt
fun Boolean.doIfTrue(doFun: () -> Unit): Boolean {
    if (this) {
        doFun.invoke()
    }
    return this
}

fun Boolean.doIfFalse(doFun: () -> Unit): Boolean {
    if (!this) {
        doFun.invoke()
    }
    return this
}
  • ScrollViewExt

fun ScrollView.smoothScrollToTop() {
    smoothScrollTo(0, 0)
}

fun ScrollView.scrollToTop() {
    scrollTo(0, 0)
}

fun ScrollView.smoothScrollToBottom() {
    smoothScrollTo(this.right, this.bottom)
}

fun ScrollView.scrollToBottom() {
    scrollTo(this.right, this.bottom)
}
  • BottomNavigationViewExt
fun BottomNavigationView.setChecked(numberItemChecked: Int) {
    this.menu.getItem(numberItemChecked).isChecked = true
}
  • FragmentExt
fun <T> Fragment.wakeUpLiveData(vararg liveData: LiveData<T>) {
    liveData.forEach {
        it.activate(viewLifecycleOwner)
    }
}

inline fun <reified T> Fragment.argument(argumentKey: String): Lazy<T?> = unsafeLazy {
    arguments?.get(argumentKey) as? T
}

inline fun <reified T> DialogFragment.argument(argumentKey: String): Lazy<T?> = unsafeLazy {
    arguments?.get(argumentKey) as? T
}

inline fun <reified T> Fragment.argumentOrDefault(argumentKey: String, defaultValue: T): Lazy<T> =
    unsafeLazy {
        arguments?.get(argumentKey) as? T ?: defaultValue
    }

inline fun <reified T> DialogFragment.argumentOrDefault(
    argumentKey: String,
    defaultValue: T
): Lazy<T> = unsafeLazy {
    arguments?.get(argumentKey) as? T ?: defaultValue
}

fun Fragment.showShortToast(text: String) {
    Toast.makeText(requireContext(), text, Toast.LENGTH_SHORT).show()
}

fun Fragment.showShortToast(text: () -> String) {
    Toast.makeText(requireContext(), text.invoke(), Toast.LENGTH_SHORT).show()
}

fun Fragment.showLongToast(text: String) {
    Toast.makeText(requireContext(), text, Toast.LENGTH_LONG).show()
}

fun Fragment.showLongToast(text: () -> String) {
    Toast.makeText(requireContext(), text.invoke(), Toast.LENGTH_LONG).show()
}

0.0.5

14 Jun 18:21
a6bd7d3
Compare
Choose a tag to compare

Whole library rename, plus some StringExt

0.0.4

08 Jun 09:11
b8063c9
Compare
Choose a tag to compare

Appropriate logging settings, plus testing of main extentions