aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/ca/allanwang
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt9
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt2
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt4
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt2
4 files changed, 9 insertions, 8 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt b/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt
index 8b59539..7e0fe70 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt
@@ -1,7 +1,7 @@
package ca.allanwang.kau.kotlin
import android.content.Context
-import android.support.annotation.AnimatorRes
+import android.support.annotation.AnimRes
import android.support.annotation.InterpolatorRes
import android.view.animation.Animation
import android.view.animation.AnimationUtils
@@ -11,14 +11,15 @@ import android.view.animation.Interpolator
* Created by Allan Wang on 2017-05-30.
*
* Lazy retrieval of context based items
- * Items are retrieved using delegateName[context]
+ * Items are retrieved using delegateName(context)
*
*/
fun lazyInterpolator(@InterpolatorRes id: Int) = lazyContext<Interpolator> { AnimationUtils.loadInterpolator(it, id) }
-fun lazyAnimation(@AnimatorRes id: Int) = lazyContext<Animation> { AnimationUtils.loadAnimation(it, id) }
-fun <T : Any> lazyContext(initializer: (context: Context) -> T): LazyContext<T> = LazyContext<T>(initializer)
+fun lazyAnimation(@AnimRes id: Int) = lazyContext<Animation> { AnimationUtils.loadAnimation(it, id) }
+
+fun <T : Any> lazyContext(initializer: (context: Context) -> T): LazyContext<T> = LazyContext(initializer)
class LazyContext<out T : Any>(private val initializer: (context: Context) -> T, lock: Any? = null) {
@Volatile private var _value: Any = UNINITIALIZED
diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt
index 8a582d8..ca3701b 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt
@@ -84,7 +84,7 @@ class KPrefDelegate<T : Any> internal constructor(
else -> throw KPrefException(t)
}
editor.apply()
- postSetter.invoke(t)
+ postSetter(t)
}
}
diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt
index 065f4bb..a8e8ec3 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt
@@ -30,11 +30,11 @@ internal class SwipeBackLayout @JvmOverloads constructor(context: Context, attrs
get() = this
/**
* Threshold of scroll, we will close the activity, when scrollPercent over
- * this value;
+ * this value
*/
override var scrollThreshold = DEFAULT_SCROLL_THRESHOLD
set(value) {
- if (value >= 1.0f || value <= 0) throw IllegalArgumentException("Threshold value should be between 0 and 1.0")
+ if (value >= 1.0f || value <= 0f) throw IllegalArgumentException("Threshold value should be between 0.0 and 1.0")
field = value
}
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt
index 3620a4a..f6a541b 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt
@@ -259,7 +259,7 @@ fun FloatingActionButton.hideOnDownwardsScroll(recycler: RecyclerView) {
recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
- if (newState == android.support.v7.widget.RecyclerView.SCROLL_STATE_IDLE && !isShown) show();
+ if (newState == android.support.v7.widget.RecyclerView.SCROLL_STATE_IDLE && !isShown) show()
}
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {