aboutsummaryrefslogtreecommitdiff
path: root/library/src/main/kotlin
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-11 19:10:05 -0700
committerAllan Wang <me@allanwang.ca>2017-06-11 19:10:05 -0700
commitaa747a2b154cebfdcdde93b68b674d776d964558 (patch)
tree749c39b002bdc4be080bad2032220b3cfe7cc68c /library/src/main/kotlin
parentced1a5b5acb763e914f62ad1ad338c9877e606e6 (diff)
downloadkau-aa747a2b154cebfdcdde93b68b674d776d964558.tar.gz
kau-aa747a2b154cebfdcdde93b68b674d776d964558.tar.bz2
kau-aa747a2b154cebfdcdde93b68b674d776d964558.zip
finalize Pref layout
Diffstat (limited to 'library/src/main/kotlin')
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/changelog/Changelog.kt2
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt2
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt3
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt9
4 files changed, 7 insertions, 9 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/changelog/Changelog.kt b/library/src/main/kotlin/ca/allanwang/kau/changelog/Changelog.kt
index 14b8c4e..7f71195 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/changelog/Changelog.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/changelog/Changelog.kt
@@ -34,7 +34,7 @@ internal class ChangelogAdapter(val items: List<Pair<String, ChangelogType>>) :
override fun getItemCount() = items.size
internal class ChangelogVH(itemView: View) : RecyclerView.ViewHolder(itemView) {
- val text: TextView = itemView.findViewById(R.id.kau_changelog_text) as TextView
+ val text: TextView = itemView.findViewById<TextView>(R.id.kau_changelog_text)
}
}
diff --git a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt
index dcb9dc5..8d5eca2 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/items/KPrefItemCore.kt
@@ -42,7 +42,7 @@ abstract class KPrefItemCore(val builder: KPrefAdapterBuilder,
desc?.visible()?.setText(description)
else
desc?.gone()
- if (iicon != null) icon?.visible()?.setIcon(iicon, 48)
+ if (iicon != null) icon?.visible()?.setIcon(iicon, 24)
else icon?.gone()
innerFrame?.removeAllViews()
val textColor = builder.textColor?.invoke()
diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt
index d47d133..4bb72a8 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt
@@ -11,9 +11,10 @@ import com.mikepenz.iconics.typeface.IIcon
/**
* Created by Allan Wang on 2017-05-29.
*/
-fun IIcon.toDrawable(c: Context, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE): Drawable {
+fun IIcon.toDrawable(c: Context, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE, builder: IconicsDrawable.() -> Unit = {}): Drawable {
val state = ColorStateList.valueOf(color)
val icon = IconicsDrawable(c).icon(this).sizeDp(sizeDp)
icon.setTintList(state)
+ icon.builder()
return icon
} \ 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 bd8478d..72b8573 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt
@@ -1,17 +1,14 @@
package ca.allanwang.kau.utils
-import android.content.res.ColorStateList
import android.graphics.Color
import android.support.annotation.ColorInt
-import android.support.annotation.ColorRes
import android.support.annotation.StringRes
import android.support.design.widget.Snackbar
-import android.support.v4.content.ContextCompat
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
-import android.widget.ProgressBar
import android.widget.TextView
+import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.iconics.typeface.IIcon
@@ -57,8 +54,8 @@ fun TextView.setTextIfValid(@StringRes id: Int) {
if (id > 0) text = context.string(id)
}
-fun ImageView.setIcon(icon: IIcon?, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE) {
+fun ImageView.setIcon(icon: IIcon?, sizeDp: Int = 24, @ColorInt color: Int = Color.WHITE, builder: IconicsDrawable.() -> Unit = {}) {
if (icon == null) return
- setImageDrawable(icon.toDrawable(context, sizeDp, color))
+ setImageDrawable(icon.toDrawable(context, sizeDp = sizeDp, color = color, builder = builder))
}