From 7a3165ac7404381eb85ea40525db1a7a7d980761 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 26 Dec 2017 04:01:23 -0500 Subject: Update/kpref activity (#113) * Revamp kpref * Clean up data * Fix script * Test emulator * Test google api * Test again * Test gpg * Update dependencies --- core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt | 9 +++++---- core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt | 2 +- core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt | 4 ++-- core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) (limited to 'core/src/main/kotlin/ca/allanwang') 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 { AnimationUtils.loadInterpolator(it, id) } -fun lazyAnimation(@AnimatorRes id: Int) = lazyContext { AnimationUtils.loadAnimation(it, id) } -fun lazyContext(initializer: (context: Context) -> T): LazyContext = LazyContext(initializer) +fun lazyAnimation(@AnimRes id: Int) = lazyContext { AnimationUtils.loadAnimation(it, id) } + +fun lazyContext(initializer: (context: Context) -> T): LazyContext = LazyContext(initializer) class LazyContext(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 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) { -- cgit v1.2.3