From 8b7f8a75a0a44f3d60e8432fe9f857e6c03a017b Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 10 Jun 2017 17:09:35 -0700 Subject: a --- .../kotlin/ca/allanwang/kau/utils/ContextUtils.kt | 2 +- .../kotlin/ca/allanwang/kau/utils/Kotterknife.kt | 64 +++++++++++----------- .../main/kotlin/ca/allanwang/kau/utils/Utils.kt | 4 +- .../kotlin/ca/allanwang/kau/utils/ViewUtils.kt | 9 --- 4 files changed, 35 insertions(+), 44 deletions(-) (limited to 'library') diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt index d27a609..1bb8b52 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt @@ -86,7 +86,7 @@ fun Context.showChangelog(@XmlRes xmlRes: Int) { }).start() } -val isNetworkAvailable = fun Context.(): Boolean { +fun Context.isNetworkAvailable(): Boolean { val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager val activeNetworkInfo = connectivityManager.activeNetworkInfo return activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt index bd68b03..a8ddd2a 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt @@ -18,72 +18,72 @@ import kotlin.reflect.KProperty import android.support.v4.app.DialogFragment as SupportDialogFragment import android.support.v4.app.Fragment as SupportFragment -public fun View.bindView(id: Int) +fun View.bindView(id: Int) : ReadOnlyProperty = required(id, viewFinder) -public fun Activity.bindView(id: Int) +fun Activity.bindView(id: Int) : ReadOnlyProperty = required(id, viewFinder) -public fun Dialog.bindView(id: Int) +fun Dialog.bindView(id: Int) : ReadOnlyProperty = required(id, viewFinder) -public fun DialogFragment.bindView(id: Int) +fun DialogFragment.bindView(id: Int) : ReadOnlyProperty = required(id, viewFinder) -public fun android.support.v4.app.DialogFragment.bindView(id: Int) +fun android.support.v4.app.DialogFragment.bindView(id: Int) : ReadOnlyProperty = required(id, viewFinder) -public fun Fragment.bindView(id: Int) +fun Fragment.bindView(id: Int) : ReadOnlyProperty = required(id, viewFinder) -public fun android.support.v4.app.Fragment.bindView(id: Int) +fun android.support.v4.app.Fragment.bindView(id: Int) : ReadOnlyProperty = required(id, viewFinder) -public fun ViewHolder.bindView(id: Int) +fun ViewHolder.bindView(id: Int) : ReadOnlyProperty = required(id, viewFinder) -public fun View.bindOptionalView(id: Int) +fun View.bindOptionalView(id: Int) : ReadOnlyProperty = optional(id, viewFinder) -public fun Activity.bindOptionalView(id: Int) +fun Activity.bindOptionalView(id: Int) : ReadOnlyProperty = optional(id, viewFinder) -public fun Dialog.bindOptionalView(id: Int) +fun Dialog.bindOptionalView(id: Int) : ReadOnlyProperty = optional(id, viewFinder) -public fun DialogFragment.bindOptionalView(id: Int) +fun DialogFragment.bindOptionalView(id: Int) : ReadOnlyProperty = optional(id, viewFinder) -public fun android.support.v4.app.DialogFragment.bindOptionalView(id: Int) +fun android.support.v4.app.DialogFragment.bindOptionalView(id: Int) : ReadOnlyProperty = optional(id, viewFinder) -public fun Fragment.bindOptionalView(id: Int) +fun Fragment.bindOptionalView(id: Int) : ReadOnlyProperty = optional(id, viewFinder) -public fun android.support.v4.app.Fragment.bindOptionalView(id: Int) +fun android.support.v4.app.Fragment.bindOptionalView(id: Int) : ReadOnlyProperty = optional(id, viewFinder) -public fun ViewHolder.bindOptionalView(id: Int) +fun ViewHolder.bindOptionalView(id: Int) : ReadOnlyProperty = optional(id, viewFinder) -public fun View.bindViews(vararg ids: Int) +fun View.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -public fun Activity.bindViews(vararg ids: Int) +fun Activity.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -public fun Dialog.bindViews(vararg ids: Int) +fun Dialog.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -public fun DialogFragment.bindViews(vararg ids: Int) +fun DialogFragment.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -public fun android.support.v4.app.DialogFragment.bindViews(vararg ids: Int) +fun android.support.v4.app.DialogFragment.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -public fun Fragment.bindViews(vararg ids: Int) +fun Fragment.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -public fun android.support.v4.app.Fragment.bindViews(vararg ids: Int) +fun android.support.v4.app.Fragment.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -public fun ViewHolder.bindViews(vararg ids: Int) +fun ViewHolder.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -public fun View.bindOptionalViews(vararg ids: Int) +fun View.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) -public fun Activity.bindOptionalViews(vararg ids: Int) +fun Activity.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) -public fun Dialog.bindOptionalViews(vararg ids: Int) +fun Dialog.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) -public fun DialogFragment.bindOptionalViews(vararg ids: Int) +fun DialogFragment.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) -public fun android.support.v4.app.DialogFragment.bindOptionalViews(vararg ids: Int) +fun android.support.v4.app.DialogFragment.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) -public fun Fragment.bindOptionalViews(vararg ids: Int) +fun Fragment.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) -public fun android.support.v4.app.Fragment.bindOptionalViews(vararg ids: Int) +fun android.support.v4.app.Fragment.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) -public fun ViewHolder.bindOptionalViews(vararg ids: Int) +fun ViewHolder.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) private val View.viewFinder: View.(Int) -> View? diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt index c7ff9f2..79f80f3 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt @@ -6,6 +6,6 @@ import android.content.res.Resources * Created by Allan Wang on 2017-05-28. */ -val dpToPx = fun Int.(): Int = (this * Resources.getSystem().displayMetrics.density).toInt() +fun Int.dpToPx(): Int = (this * Resources.getSystem().displayMetrics.density).toInt() -val pxToDp = fun Int.(): Int = (this / Resources.getSystem().displayMetrics.density).toInt() +fun Int.pxToDp(px: Int) = (px / android.content.res.Resources.getSystem().displayMetrics.density).toInt() \ No newline at end of file diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt index a5204aa..bd8478d 100644 --- a/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt +++ b/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt @@ -44,15 +44,6 @@ fun View.matchParent() { } } -fun ProgressBar.tintRes(@ColorRes id: Int) = tint(ContextCompat.getColor(context, id)) - -fun ProgressBar.tint(@ColorInt color: Int) { - val sl = ColorStateList.valueOf(color) - progressTintList = sl - secondaryProgressTintList = sl - indeterminateTintList = sl -} - fun View.snackbar(text: String, duration: Int = Snackbar.LENGTH_LONG, builder: (Snackbar) -> Unit = {}) { val snackbar = Snackbar.make(this, text, duration) builder.invoke(snackbar) -- cgit v1.2.3