-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
77 additions
and
16 deletions.
There are no files selected for viewing
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
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
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
14 changes: 14 additions & 0 deletions
14
kotlinknifer/src/main/java/com/devrapid/kotlinknifer/ArrayList.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,14 @@ | ||
package com.devrapid.kotlinknifer | ||
|
||
/** | ||
* @author jieyi | ||
* @since 11/8/17 | ||
*/ | ||
fun <E> ArrayList<E>.removeRange(from: Int, to: Int): Boolean = | ||
if (!(from in 0..size - 1 && to in 0..size - 1 && from > to)) { | ||
false | ||
} | ||
else { | ||
subList(from, to).clear() | ||
true | ||
} |
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
28 changes: 28 additions & 0 deletions
28
kotlinknifer/src/main/java/com/devrapid/kotlinknifer/Keyboard.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,28 @@ | ||
@file:Suppress("NOTHING_TO_INLINE") | ||
|
||
package com.devrapid.kotlinknifer | ||
|
||
import android.content.Context | ||
import android.view.View | ||
import android.view.inputmethod.InputMethodManager | ||
|
||
/** | ||
* @author jieyi | ||
* @since 11/8/17 | ||
*/ | ||
inline fun Context.hideSoftKeyboard() = | ||
(getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager). | ||
toggleSoftInput(InputMethodManager.SHOW_FORCED, 0) | ||
|
||
inline fun View.hideSoftKeyboard() = | ||
(context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager). | ||
hideSoftInputFromWindow(windowToken, 0) | ||
|
||
inline fun View.showSoftKeyboard() = | ||
apply { | ||
isFocusable = true | ||
isFocusableInTouchMode = true | ||
requestFocus() | ||
(context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager). | ||
showSoftInput(this, InputMethodManager.SHOW_FORCED) | ||
} |
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
11 changes: 11 additions & 0 deletions
11
kotlinknifer/src/main/java/com/devrapid/kotlinknifer/String.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,11 @@ | ||
@file:Suppress("NOTHING_TO_INLINE") | ||
|
||
package com.devrapid.kotlinknifer | ||
|
||
import java.text.DecimalFormat | ||
|
||
/** | ||
* @author jieyi | ||
* @since 11/8/17 | ||
*/ | ||
inline fun String.formatToMoneyKarma(): String = DecimalFormat("###,###").format(java.lang.Double.parseDouble(this)) |
9 changes: 9 additions & 0 deletions
9
kotlinknifer/src/main/java/com/devrapid/kotlinknifer/Thread.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,9 @@ | ||
@file:Suppress("NOTHING_TO_INLINE") | ||
|
||
package com.devrapid.kotlinknifer | ||
|
||
/** | ||
* @author jieyi | ||
* @since 11/8/17 | ||
*/ | ||
inline fun threadName(): String = Thread.currentThread().name |
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
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