-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature add base class extensions (#2)
- Loading branch information
1 parent
f203766
commit ed1a380
Showing
9 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
klobalx/src/main/java/com/mobillium/klobalx/nativeext/BooleanExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.mobillium.klobalx.nativeext | ||
|
||
val Boolean?.orFalse: Boolean | ||
get() = this ?: false |
4 changes: 4 additions & 0 deletions
4
klobalx/src/main/java/com/mobillium/klobalx/nativeext/DoubleExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.mobillium.klobalx.nativeext | ||
|
||
val Double?.orZero: Double | ||
get() = this ?: 0.0 |
4 changes: 4 additions & 0 deletions
4
klobalx/src/main/java/com/mobillium/klobalx/nativeext/FloatExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.mobillium.klobalx.nativeext | ||
|
||
val Float?.orZero: Float | ||
get() = this ?: 0.0f |
4 changes: 4 additions & 0 deletions
4
klobalx/src/main/java/com/mobillium/klobalx/nativeext/IntExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.mobillium.klobalx.nativeext | ||
|
||
val Int?.orZero: Int | ||
get() = this ?: 0 |
4 changes: 4 additions & 0 deletions
4
klobalx/src/main/java/com/mobillium/klobalx/nativeext/LongExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.mobillium.klobalx.nativeext | ||
|
||
val Long?.orZero: Long | ||
get() = this ?: 0L |
26 changes: 25 additions & 1 deletion
26
klobalx/src/main/java/com/mobillium/klobalx/nativeext/StringExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,28 @@ | ||
package com.mobillium.klobalx.nativeext | ||
|
||
import android.text.Spannable | ||
import android.text.SpannableString | ||
import android.text.style.ForegroundColorSpan | ||
|
||
const val EMPTY_STRING = "" | ||
const val SPACE_STRING = " " | ||
const val SPACE_STRING = " " | ||
|
||
fun String.getColorizedSpannable( | ||
vararg strings: String, | ||
color: Int, | ||
flags: Int = Spannable.SPAN_EXCLUSIVE_EXCLUSIVE | ||
): SpannableString { | ||
return SpannableString(this).apply { | ||
strings.forEach { string -> | ||
val startIndex = this.indexOf(string) | ||
val endIndex = startIndex + string.length | ||
|
||
setSpan( | ||
ForegroundColorSpan(color), | ||
startIndex, | ||
endIndex, | ||
flags | ||
) | ||
} | ||
} | ||
} |