Skip to content

Releases: skydoves/WhatIf

1.0.6

07 Aug 12:45
9453bde
Compare
Choose a tag to compare

🎉 Released a new version 1.0.6! 🎉

What's New?

  • The previous module separated into whatIf and whatIf-android.
    The whatIf module can be used in the kotlin project (non-Android project).
    The whatIf-android module is related to Android extensions.

1.0.5

31 Jul 15:57
63b2361
Compare
Choose a tag to compare

🎉 Released a new version 1.0.5! 🎉

What's New?

  • Added whatIfElse.
    An expression for invoking whatIf lambda when the target boolean is not null and false.
nullableBoolean.whatIfElse {
  log("nullableBoolean is not null and false")
}
  • Added whatIfAnd, whatIfOr.
    An expression for invoking whatIf lambda when the target boolean is true and/or a predicate receiver is true.
nullableBoolean.whatIfAnd(predicate) {
  log("nullableBoolean is true and the predicate is also true")
}

nullableBoolean.whatIfOr(predicate) {
  log("nullableBoolean is true or the predicate is true")
}

WhatIf for Android fragment

  • whatIfNotNullContext.
    An expression for invoking whatIf lambda when the Context is not null.
class WhatIfFragment : Fragment() {

  override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)

    whatIfNotNullContext {
      Toast.makeText(it, "context is not null!", Toast.LENGTH_SHORT).show()
    }
  }
}
  • whatIfNotNullArguments
An expression for invoking whatIf when the Fragment.getArguments is not null.

whatIfNotNullArguments {
  it.getString("name").whatIfNotNull {
    log("my name is $it")
  }
}
  • whatIfNotNullActivity
whatIfNotNullActivity { activity ->
  activity.supportFragmentManager.addOnBackStackChangedListener {
    // .. //
  }
}

1.0.4

17 Sep 12:26
68a2e19
Compare
Choose a tag to compare

Released version 1.0.4.

WhatIfHasExtras

An expression for invoking whatIf lambda when the Activity's intent extras is not null and not empty.

var foo: String? = null
this@MainActivity.whatIfHasExtras {
  foo = "${it.getString("foo")}"
}

And we can handle the null case.

this@MainActivity.whatIfHasExtras(
   whatIf = { foo = "${it.getString("foo")}" },
   whatIfNot = { log("intent extras is null or empty.") }
)

1.0.3

12 Sep 10:44
c6102bd
Compare
Choose a tag to compare

Released version 1.0.3.

Implemented whatIfNotNullOrEmpty for string type.
We can execute a single lambda if the string is not null and not empty.

val nullableString: String? = "NotNullOrEmpty"
nullableString.whatIfNotNullOrEmpty { 
  log("$it is not null and not empty")
}

Or we can handle the null or empty case.

nullableString.whatIfNotNullOrEmpty(
  whatIf = { nullableString = it },
  whatIfNot = { nullableString = "NullOrEmpty" }
)

1.0.2

10 Sep 10:28
970f392
Compare
Choose a tag to compare

Version 1.0.2 is released.

Changed whatIfNotNullOrEmpty collections separated toList and Set.
In whatIfNotNullOrEmpty, whatIf lambda will receive not-null type collection type.

Implemented whatIfNotNullAs.
If the target is not null, the receiver will get a casted type.

var nullableIntList: MutableList<Int>? = null
nullableIntList.whatIfNotNullAs<List<Int>> {
  nullableInt = it.size
}

1.0.1

09 Sep 15:26
62ef67d
Compare
Choose a tag to compare

Version 1.0.1 is released.

Implemented below functionality extensions.

  • whatIfNotNullOrEmpty for array type and collections.

Array type : Array, ByteArray, ShortArray, IntArray, LongArray, FloatArray, DoubleArray, BooleanArray, CharArray
Collections: List, Map, Set

1.0.0

08 Sep 05:08
Compare
Choose a tag to compare

🎉🎉Published first version 1.0.0.🎉🎉