diff options
author | Allan Wang <me@allanwang.ca> | 2017-07-23 13:13:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-23 13:13:36 -0700 |
commit | 4706b8f6a8d08a6961da6ab34d15881b63356d79 (patch) | |
tree | 3d1e611e43bd589a98a5f1840c5b6f52ff254468 /core/src/main/kotlin/ca | |
parent | 61d87976e8b29ed25061ae98743a6cf4f4274542 (diff) | |
download | kau-4706b8f6a8d08a6961da6ab34d15881b63356d79.tar.gz kau-4706b8f6a8d08a6961da6ab34d15881b63356d79.tar.bz2 kau-4706b8f6a8d08a6961da6ab34d15881b63356d79.zip |
Update kpref-activity's min-sdk and other minor changes (#11)3.1.0
* Move some resources to public
* Lower kpref minsdk
* Remove excess kauUtils annotations
* Allow nullable throwable
* Do not throw null throwable
* Make image picker base abstract again
* Migrate about strings to private
* Update readme
* Update readme
* Update sample tagging
* Update adapter readme
Diffstat (limited to 'core/src/main/kotlin/ca')
3 files changed, 17 insertions, 16 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt b/core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt index 5969fd5..e0f6cae 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/logging/TimberLogger.kt @@ -11,7 +11,7 @@ import timber.log.Timber open class TimberLogger(tag: String) { internal val TAG = "$tag: %s" fun e(s: String) = Timber.e(TAG, s) - fun e(t: Throwable, s: String = "error") = Timber.e(t, TAG, s) + fun e(t: Throwable?, s: String = "error") = if (t == null) e(s) else Timber.e(t, TAG, s) fun d(s: String) = Timber.d(TAG, s) fun i(s: String) = Timber.i(TAG, s) fun v(s: String) = Timber.v(TAG, s) diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/AnimUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/AnimUtils.kt index ed4b7bd..112c8ec 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/AnimUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/AnimUtils.kt @@ -32,13 +32,13 @@ import android.widget.TextView val anim = ViewAnimationUtils.createCircularReveal(this, x, y, 0f, r).setDuration(duration) anim.startDelay = offset anim.addListener(object : AnimatorListenerAdapter() { - override @KauUtils fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator?) { visible() onStart?.invoke() } - override @KauUtils fun onAnimationEnd(animation: Animator?) = onFinish?.invoke() ?: Unit - override @KauUtils fun onAnimationCancel(animation: Animator?) = onFinish?.invoke() ?: Unit + override fun onAnimationEnd(animation: Animator?) = onFinish?.invoke() ?: Unit + override fun onAnimationCancel(animation: Animator?) = onFinish?.invoke() ?: Unit }) anim.start() } @@ -59,14 +59,14 @@ import android.widget.TextView val anim = ViewAnimationUtils.createCircularReveal(this, x, y, r, 0f).setDuration(duration) anim.startDelay = offset anim.addListener(object : AnimatorListenerAdapter() { - override @KauUtils fun onAnimationStart(animation: Animator?) = onStart?.invoke() ?: Unit + override fun onAnimationStart(animation: Animator?) = onStart?.invoke() ?: Unit - override @KauUtils fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator?) { invisible() onFinish?.invoke() ?: Unit } - override @KauUtils fun onAnimationCancel(animation: Animator?) = onFinish?.invoke() ?: Unit + override fun onAnimationCancel(animation: Animator?) = onFinish?.invoke() ?: Unit }) anim.start() } @@ -82,9 +82,9 @@ import android.widget.TextView anim.startOffset = offset anim.duration = duration anim.setAnimationListener(object : Animation.AnimationListener { - override @KauUtils fun onAnimationRepeat(animation: Animation?) {} - override @KauUtils fun onAnimationEnd(animation: Animation?) = onFinish?.invoke() ?: Unit - override @KauUtils fun onAnimationStart(animation: Animation?) { + override fun onAnimationRepeat(animation: Animation?) {} + override fun onAnimationEnd(animation: Animation?) = onFinish?.invoke() ?: Unit + override fun onAnimationStart(animation: Animation?) { visible() onStart?.invoke() } @@ -103,13 +103,13 @@ import android.widget.TextView anim.startOffset = offset anim.duration = duration anim.setAnimationListener(object : Animation.AnimationListener { - override @KauUtils fun onAnimationRepeat(animation: Animation?) {} - override @KauUtils fun onAnimationEnd(animation: Animation?) { + override fun onAnimationRepeat(animation: Animation?) {} + override fun onAnimationEnd(animation: Animation?) { invisible() onFinish?.invoke() } - override @KauUtils fun onAnimationStart(animation: Animation?) { + override fun onAnimationStart(animation: Animation?) { onStart?.invoke() } }) diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt index bf30a91..7a92665 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt @@ -169,13 +169,14 @@ inline val Context.isNavBarOnBottom: Boolean fun Context.hasPermission(permissions: String) = !buildIsMarshmallowAndUp || ContextCompat.checkSelfPermission(this, permissions) == PackageManager.PERMISSION_GRANTED -fun Context.copyToClipboard(text: String, label: String = "Copied Text", showToast: Boolean = true) { +fun Context.copyToClipboard(text: String?, label: String = "Copied Text", showToast: Boolean = true) { val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager - clipboard.primaryClip = ClipData.newPlainText(label, text) + clipboard.primaryClip = ClipData.newPlainText(label, text ?: "") if (showToast) toast(R.string.kau_text_copied) } -fun Context.shareText(text: String) { +fun Context.shareText(text: String?) { + if (text == null) return toast(R.string.kau_text_is_null) val intent = Intent(Intent.ACTION_SEND) intent.type = "text/plain" intent.putExtra(Intent.EXTRA_TEXT, text) |