aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt3
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt11
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt13
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt6
5 files changed, 15 insertions, 22 deletions
diff --git a/README.md b/README.md
index bcb06ab..d58cde5 100644
--- a/README.md
+++ b/README.md
@@ -261,10 +261,6 @@ Be sure to include the activity in your Manifest and have it extend `Kau.Translu
* Show a Changelog by parsing an xml resource
* Check if network is available
-### FragmentUtils
-> Extends Fragment
-* `withBundle` Directly put extras into a fragment; if a bundle does not exist, it will be created
-
### IIconUtils
> Extends [IIcon](https://github.com/mikepenz/Android-Iconics)
* `toDrawable` method that only requires a context; defaults to a white icon of size 24dp and uses a ColorStateList to allow for dimming
diff --git a/library/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt b/library/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt
index 06222a8..83b8726 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt
@@ -1,5 +1,6 @@
package ca.allanwang.kau.adapters
+import android.content.res.ColorStateList
import android.view.View
import android.widget.ImageView
import android.widget.TextView
@@ -183,6 +184,6 @@ class ThemableIItemDelegate : ThemableIItem, ThemableIItemColors by ThemableIIte
override fun bindIconColor(vararg views: ImageView) {
val color = accentColor ?: textColor ?: return
- views.forEach { it.drawable.setTint(color) }
+ views.forEach { it.drawable.setTintList(ColorStateList.valueOf(color)) }
}
} \ No newline at end of file
diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt
index ae486a4..4f95b2c 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt
@@ -4,9 +4,12 @@ import android.app.Activity
import android.content.Intent
import android.graphics.Color
import android.support.annotation.ColorInt
+import android.support.annotation.StringRes
+import android.support.design.widget.Snackbar
import android.view.Menu
import ca.allanwang.kau.R
import com.mikepenz.iconics.typeface.IIcon
+import org.jetbrains.anko.contentView
/**
* Created by Allan Wang on 2017-06-21.
@@ -57,4 +60,10 @@ fun Activity.setMenuIcons(menu: Menu, @ColorInt color: Int = Color.WHITE, vararg
fun Activity.hideKeyboard() = currentFocus.hideKeyboard()
-fun Activity.showKeyboard() = currentFocus.showKeyboard() \ No newline at end of file
+fun Activity.showKeyboard() = currentFocus.showKeyboard()
+
+fun Activity.snackbar(text: String, duration: Int = Snackbar.LENGTH_LONG, builder: Snackbar.() -> Unit = {})
+ = contentView!!.snackbar(text, duration, builder)
+
+fun Activity.snackbar(@StringRes textId: Int, duration: Int = Snackbar.LENGTH_LONG, builder: Snackbar.() -> Unit = {})
+ = contentView!!.snackbar(textId, duration, builder) \ No newline at end of file
diff --git a/library/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt b/library/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt
deleted file mode 100644
index cf0be7d..0000000
--- a/library/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package ca.allanwang.kau.utils
-
-import android.os.Bundle
-import android.support.v4.app.Fragment
-
-/**
- * Created by Allan Wang on 2017-05-29.
- */
-@KauUtils fun <T : Fragment> T.withBundle(builder: Bundle.() -> Unit = {}): T {
- if (this.arguments == null) this.arguments = Bundle()
- this.arguments.builder()
- return this
-} \ 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 3fb8f27..7fa7c0e 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt
@@ -48,13 +48,13 @@ import com.mikepenz.iconics.typeface.IIcon
@KauUtils fun View.isInvisible(): Boolean = visibility == View.INVISIBLE
@KauUtils fun View.isGone(): Boolean = visibility == View.GONE
-fun View.snackbar(text: String, duration: Int = Snackbar.LENGTH_LONG, builder: (Snackbar) -> Unit = {}) {
+fun View.snackbar(text: String, duration: Int = Snackbar.LENGTH_LONG, builder: Snackbar.() -> Unit = {}) {
val snackbar = Snackbar.make(this, text, duration)
- builder.invoke(snackbar)
+ snackbar.builder()
snackbar.show()
}
-fun View.snackbar(@StringRes textId: Int, duration: Int = Snackbar.LENGTH_LONG, builder: (Snackbar) -> Unit = {})
+fun View.snackbar(@StringRes textId: Int, duration: Int = Snackbar.LENGTH_LONG, builder: Snackbar.() -> Unit = {})
= snackbar(context.string(textId), duration, builder)
@KauUtils fun TextView.setTextIfValid(@StringRes id: Int) {