Skip to content

Commit

Permalink
Added more api and upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
pokk committed Nov 8, 2017
1 parent 9365977 commit 7e93733
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 16 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ The library has util tools as below:
7. Observer of RxJava
8. View
9. Time
10. ArrayList
11. Keyboard
12. String
13. Thread

# Download

Expand All @@ -35,7 +39,7 @@ allprojects {
And add our dependency to your app `bundle.gradle`.

```gradle
compile 'com.devrapid.jieyi:kotlinknifer:1.0.13'
compile 'com.devrapid.jieyi:kotlinknifer:1.0.14'
```

Then you can use it!!!
Expand All @@ -53,8 +57,8 @@ Then you can use it!!!

# Also Included Library

1. Gson 2.8.1
2. RxJava 2.1.3
1. Gson 2.8.2
2. RxJava 2.1.6
3. RxKotlin 2.1.0

# Feature
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ proj_name=kotlinknifer
proj_libname=KotlinKnifer
proj_group=com.devrapid.jieyi
proj_artifactid=kotlinknifer
proj_version=1.0.13
proj_version=1.0.14
proj_description=For developing an Android conveniently and rapidly.
proj_websiteurl=https://github.com/pokk/KotlinKnifer
proj_issuetrackerurl=https://github.com/pokk/KotlinKnifer/issues
Expand Down
4 changes: 2 additions & 2 deletions kotlinknifer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ android {

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.1'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
compile "io.reactivex.rxjava2:rxkotlin:2.1.0"
compile "io.reactivex.rxjava2:rxjava:2.1.3"
compile "io.reactivex.rxjava2:rxjava:2.1.6"
compile "com.android.support:appcompat-v7:25.3.1"
}

Expand Down
14 changes: 14 additions & 0 deletions kotlinknifer/src/main/java/com/devrapid/kotlinknifer/ArrayList.kt
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
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import kotlin.reflect.KProperty
* @author jieyi
* @since 6/12/17
*/

/**
* Delegate [WeakReference] for the variables.
*/
/** Delegate [WeakReference] for the variables. */
class WeakRef<T>(default: T? = null): ReadWriteProperty<Any?, T?> {
var variable: WeakReference<T>?

Expand All @@ -31,9 +28,7 @@ class WeakRef<T>(default: T? = null): ReadWriteProperty<Any?, T?> {
}
}

/**
* Delegate the shared preferences variable.
*/
/** Delegate the shared preferences variable. */
class SharedPrefs<T>(var defaultValue: T, val objectType: Class<T>? = null, var onChange: (() -> Unit)? = null):
ReadWriteProperty<Any, T> {
companion object {
Expand Down
28 changes: 28 additions & 0 deletions kotlinknifer/src/main/java/com/devrapid/kotlinknifer/Keyboard.kt
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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import android.util.Log
* @author Jieyi
* @since 8/1/15
*/

fun logv(vararg msg: Any?): Unit = Logs.v(*msg)

fun logd(vararg msg: Any?): Unit = Logs.d(*msg)
Expand Down
11 changes: 11 additions & 0 deletions kotlinknifer/src/main/java/com/devrapid/kotlinknifer/String.kt
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))
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
4 changes: 3 additions & 1 deletion kotlinknifer/src/main/java/com/devrapid/kotlinknifer/Time.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("NOTHING_TO_INLINE")

package com.devrapid.kotlinknifer

/**
Expand All @@ -6,6 +8,6 @@ package com.devrapid.kotlinknifer
* @author jieyi
* @since 9/8/17
*/
fun Int.format(digits: Int) = String.format("%0${digits}d", this)
inline fun Int.format(digits: Int) = String.format("%0${digits}d", this)

inline fun Int.toTimeString(): String = "${(this / 60).format(2)}:${(this % 60).format(2)}"
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import com.example.kotlinknifer.R
* @author jieyi
* @since 4/12/17
*/

inline fun View.resizeView(width: Int? = null, height: Int? = null) = this.layoutParams?.apply {
height?.let {
this.height = it
Expand Down

0 comments on commit 7e93733

Please sign in to comment.