diff options
author | Allan Wang <me@allanwang.ca> | 2017-07-02 12:27:36 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-07-02 12:27:36 -0700 |
commit | c0decd6f72d825db989275e216aa97741cce412f (patch) | |
tree | 40ae7dde5e46121aff67472eaea65ebce6a1d6a4 /library/src/main/kotlin/ca | |
parent | e1e3b370007340573a61bc3daae18c009ff28a53 (diff) | |
download | kau-c0decd6f72d825db989275e216aa97741cce412f.tar.gz kau-c0decd6f72d825db989275e216aa97741cce412f.tar.bz2 kau-c0decd6f72d825db989275e216aa97741cce412f.zip |
Remove fragmentutils and update snackbar
Diffstat (limited to 'library/src/main/kotlin/ca')
4 files changed, 15 insertions, 18 deletions
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) { |