aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.idea/markdown-navigator.xml71
-rw-r--r--.idea/misc.xml68
-rw-r--r--README.md17
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt2
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt64
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt4
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt9
7 files changed, 123 insertions, 112 deletions
diff --git a/.idea/markdown-navigator.xml b/.idea/markdown-navigator.xml
new file mode 100644
index 0000000..838ef39
--- /dev/null
+++ b/.idea/markdown-navigator.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="MarkdownProjectSettings">
+ <PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.25" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="LINE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="true" showSelectionInPreview="true">
+ <PanelProvider>
+ <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
+ </PanelProvider>
+ </PreviewSettings>
+ <ParserSettings gitHubSyntaxChange="false">
+ <PegdownExtensions>
+ <option name="ABBREVIATIONS" value="false" />
+ <option name="ANCHORLINKS" value="true" />
+ <option name="ASIDE" value="false" />
+ <option name="ATXHEADERSPACE" value="true" />
+ <option name="AUTOLINKS" value="true" />
+ <option name="DEFINITIONS" value="false" />
+ <option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
+ <option name="FENCED_CODE_BLOCKS" value="true" />
+ <option name="FOOTNOTES" value="false" />
+ <option name="HARDWRAPS" value="false" />
+ <option name="INSERTED" value="false" />
+ <option name="QUOTES" value="false" />
+ <option name="RELAXEDHRULES" value="true" />
+ <option name="SMARTS" value="false" />
+ <option name="STRIKETHROUGH" value="true" />
+ <option name="SUBSCRIPT" value="false" />
+ <option name="SUPERSCRIPT" value="false" />
+ <option name="SUPPRESS_HTML_BLOCKS" value="false" />
+ <option name="SUPPRESS_INLINE_HTML" value="false" />
+ <option name="TABLES" value="true" />
+ <option name="TASKLISTITEMS" value="true" />
+ <option name="TOC" value="false" />
+ <option name="WIKILINKS" value="true" />
+ </PegdownExtensions>
+ <ParserOptions>
+ <option name="COMMONMARK_LISTS" value="false" />
+ <option name="DUMMY" value="false" />
+ <option name="EMOJI_SHORTCUTS" value="true" />
+ <option name="FLEXMARK_FRONT_MATTER" value="false" />
+ <option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
+ <option name="GFM_TABLE_RENDERING" value="true" />
+ <option name="GITBOOK_URL_ENCODING" value="false" />
+ <option name="GITHUB_EMOJI_URL" value="false" />
+ <option name="GITHUB_LISTS" value="true" />
+ <option name="GITHUB_WIKI_LINKS" value="true" />
+ <option name="JEKYLL_FRONT_MATTER" value="false" />
+ <option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
+ </ParserOptions>
+ </ParserSettings>
+ <HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true">
+ <GeneratorProvider>
+ <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
+ </GeneratorProvider>
+ <headerTop />
+ <headerBottom />
+ <bodyTop />
+ <bodyBottom />
+ </HtmlSettings>
+ <CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssTextEnabled="false" isDynamicPageWidth="true">
+ <StylesheetProvider>
+ <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
+ </StylesheetProvider>
+ <ScriptProviders />
+ <cssText />
+ </CssSettings>
+ <HtmlExportSettings updateOnSave="false" parentDir="$ProjectFileDir$" targetDir="$ProjectFileDir$" cssDir="" scriptDir="" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetExt="" useTargetExt="false" noCssNoScripts="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" />
+ <LinkMapSettings>
+ <textMaps />
+ </LinkMapSettings>
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 8449ce7..085136f 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,74 +3,6 @@
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
- <component name="MarkdownProjectSettings">
- <PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.25" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="LINE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="true" showSelectionInPreview="true">
- <PanelProvider>
- <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
- </PanelProvider>
- </PreviewSettings>
- <ParserSettings gitHubSyntaxChange="false">
- <PegdownExtensions>
- <option name="ABBREVIATIONS" value="false" />
- <option name="ANCHORLINKS" value="true" />
- <option name="ASIDE" value="false" />
- <option name="ATXHEADERSPACE" value="true" />
- <option name="AUTOLINKS" value="true" />
- <option name="DEFINITIONS" value="false" />
- <option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
- <option name="FENCED_CODE_BLOCKS" value="true" />
- <option name="FOOTNOTES" value="false" />
- <option name="HARDWRAPS" value="false" />
- <option name="INSERTED" value="false" />
- <option name="QUOTES" value="false" />
- <option name="RELAXEDHRULES" value="true" />
- <option name="SMARTS" value="false" />
- <option name="STRIKETHROUGH" value="true" />
- <option name="SUBSCRIPT" value="false" />
- <option name="SUPERSCRIPT" value="false" />
- <option name="SUPPRESS_HTML_BLOCKS" value="false" />
- <option name="SUPPRESS_INLINE_HTML" value="false" />
- <option name="TABLES" value="true" />
- <option name="TASKLISTITEMS" value="true" />
- <option name="TOC" value="false" />
- <option name="WIKILINKS" value="true" />
- </PegdownExtensions>
- <ParserOptions>
- <option name="COMMONMARK_LISTS" value="false" />
- <option name="DUMMY" value="false" />
- <option name="EMOJI_SHORTCUTS" value="true" />
- <option name="FLEXMARK_FRONT_MATTER" value="false" />
- <option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
- <option name="GFM_TABLE_RENDERING" value="true" />
- <option name="GITBOOK_URL_ENCODING" value="false" />
- <option name="GITHUB_EMOJI_URL" value="false" />
- <option name="GITHUB_LISTS" value="true" />
- <option name="GITHUB_WIKI_LINKS" value="true" />
- <option name="JEKYLL_FRONT_MATTER" value="false" />
- <option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
- </ParserOptions>
- </ParserSettings>
- <HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true">
- <GeneratorProvider>
- <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
- </GeneratorProvider>
- <headerTop />
- <headerBottom />
- <bodyTop />
- <bodyBottom />
- </HtmlSettings>
- <CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssTextEnabled="false" isDynamicPageWidth="true">
- <StylesheetProvider>
- <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
- </StylesheetProvider>
- <ScriptProviders />
- <cssText />
- </CssSettings>
- <HtmlExportSettings updateOnSave="false" parentDir="$ProjectFileDir$" targetDir="$ProjectFileDir$" cssDir="" scriptDir="" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetExt="" useTargetExt="false" noCssNoScripts="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" />
- <LinkMapSettings>
- <textMaps />
- </LinkMapSettings>
- </component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
diff --git a/README.md b/README.md
index 580717a..30b2a55 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,19 @@
# KAU
+
Kotlin Android Utils
+
+This library contains small helper functions used throughout almost all of my other projects. The goal is to make common interactions executable in a single line.
+
+## Features
+
+## Extension Functions
+
+<sup><sub>"[Extensions](https://kotlinlang.org/docs/reference/extensions.html) provides the ability to extend a class with new functionality without having to inherit from the class"</sub></sup>
+
+### AnimUtils - Extensions for Views
+Extends Views
+* Fade In/Fade Out/Circle Reveal with callbacks
+* Switch texts in a TextView with a fade transition
+
+### ColorUtils - Extensions for Int
+
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 <V : View> View.bindView(id: Int)
+fun <V : View> View.bindView(id: Int)
: ReadOnlyProperty<View, V> = required(id, viewFinder)
-public fun <V : View> Activity.bindView(id: Int)
+fun <V : View> Activity.bindView(id: Int)
: ReadOnlyProperty<Activity, V> = required(id, viewFinder)
-public fun <V : View> Dialog.bindView(id: Int)
+fun <V : View> Dialog.bindView(id: Int)
: ReadOnlyProperty<Dialog, V> = required(id, viewFinder)
-public fun <V : View> DialogFragment.bindView(id: Int)
+fun <V : View> DialogFragment.bindView(id: Int)
: ReadOnlyProperty<DialogFragment, V> = required(id, viewFinder)
-public fun <V : View> android.support.v4.app.DialogFragment.bindView(id: Int)
+fun <V : View> android.support.v4.app.DialogFragment.bindView(id: Int)
: ReadOnlyProperty<android.support.v4.app.DialogFragment, V> = required(id, viewFinder)
-public fun <V : View> Fragment.bindView(id: Int)
+fun <V : View> Fragment.bindView(id: Int)
: ReadOnlyProperty<Fragment, V> = required(id, viewFinder)
-public fun <V : View> android.support.v4.app.Fragment.bindView(id: Int)
+fun <V : View> android.support.v4.app.Fragment.bindView(id: Int)
: ReadOnlyProperty<android.support.v4.app.Fragment, V> = required(id, viewFinder)
-public fun <V : View> ViewHolder.bindView(id: Int)
+fun <V : View> ViewHolder.bindView(id: Int)
: ReadOnlyProperty<ViewHolder, V> = required(id, viewFinder)
-public fun <V : View> View.bindOptionalView(id: Int)
+fun <V : View> View.bindOptionalView(id: Int)
: ReadOnlyProperty<View, V?> = optional(id, viewFinder)
-public fun <V : View> Activity.bindOptionalView(id: Int)
+fun <V : View> Activity.bindOptionalView(id: Int)
: ReadOnlyProperty<Activity, V?> = optional(id, viewFinder)
-public fun <V : View> Dialog.bindOptionalView(id: Int)
+fun <V : View> Dialog.bindOptionalView(id: Int)
: ReadOnlyProperty<Dialog, V?> = optional(id, viewFinder)
-public fun <V : View> DialogFragment.bindOptionalView(id: Int)
+fun <V : View> DialogFragment.bindOptionalView(id: Int)
: ReadOnlyProperty<DialogFragment, V?> = optional(id, viewFinder)
-public fun <V : View> android.support.v4.app.DialogFragment.bindOptionalView(id: Int)
+fun <V : View> android.support.v4.app.DialogFragment.bindOptionalView(id: Int)
: ReadOnlyProperty<android.support.v4.app.DialogFragment, V?> = optional(id, viewFinder)
-public fun <V : View> Fragment.bindOptionalView(id: Int)
+fun <V : View> Fragment.bindOptionalView(id: Int)
: ReadOnlyProperty<Fragment, V?> = optional(id, viewFinder)
-public fun <V : View> android.support.v4.app.Fragment.bindOptionalView(id: Int)
+fun <V : View> android.support.v4.app.Fragment.bindOptionalView(id: Int)
: ReadOnlyProperty<android.support.v4.app.Fragment, V?> = optional(id, viewFinder)
-public fun <V : View> ViewHolder.bindOptionalView(id: Int)
+fun <V : View> ViewHolder.bindOptionalView(id: Int)
: ReadOnlyProperty<ViewHolder, V?> = optional(id, viewFinder)
-public fun <V : View> View.bindViews(vararg ids: Int)
+fun <V : View> View.bindViews(vararg ids: Int)
: ReadOnlyProperty<View, List<V>> = required(ids, viewFinder)
-public fun <V : View> Activity.bindViews(vararg ids: Int)
+fun <V : View> Activity.bindViews(vararg ids: Int)
: ReadOnlyProperty<Activity, List<V>> = required(ids, viewFinder)
-public fun <V : View> Dialog.bindViews(vararg ids: Int)
+fun <V : View> Dialog.bindViews(vararg ids: Int)
: ReadOnlyProperty<Dialog, List<V>> = required(ids, viewFinder)
-public fun <V : View> DialogFragment.bindViews(vararg ids: Int)
+fun <V : View> DialogFragment.bindViews(vararg ids: Int)
: ReadOnlyProperty<DialogFragment, List<V>> = required(ids, viewFinder)
-public fun <V : View> android.support.v4.app.DialogFragment.bindViews(vararg ids: Int)
+fun <V : View> android.support.v4.app.DialogFragment.bindViews(vararg ids: Int)
: ReadOnlyProperty<android.support.v4.app.DialogFragment, List<V>> = required(ids, viewFinder)
-public fun <V : View> Fragment.bindViews(vararg ids: Int)
+fun <V : View> Fragment.bindViews(vararg ids: Int)
: ReadOnlyProperty<Fragment, List<V>> = required(ids, viewFinder)
-public fun <V : View> android.support.v4.app.Fragment.bindViews(vararg ids: Int)
+fun <V : View> android.support.v4.app.Fragment.bindViews(vararg ids: Int)
: ReadOnlyProperty<android.support.v4.app.Fragment, List<V>> = required(ids, viewFinder)
-public fun <V : View> ViewHolder.bindViews(vararg ids: Int)
+fun <V : View> ViewHolder.bindViews(vararg ids: Int)
: ReadOnlyProperty<ViewHolder, List<V>> = required(ids, viewFinder)
-public fun <V : View> View.bindOptionalViews(vararg ids: Int)
+fun <V : View> View.bindOptionalViews(vararg ids: Int)
: ReadOnlyProperty<View, List<V>> = optional(ids, viewFinder)
-public fun <V : View> Activity.bindOptionalViews(vararg ids: Int)
+fun <V : View> Activity.bindOptionalViews(vararg ids: Int)
: ReadOnlyProperty<Activity, List<V>> = optional(ids, viewFinder)
-public fun <V : View> Dialog.bindOptionalViews(vararg ids: Int)
+fun <V : View> Dialog.bindOptionalViews(vararg ids: Int)
: ReadOnlyProperty<Dialog, List<V>> = optional(ids, viewFinder)
-public fun <V : View> DialogFragment.bindOptionalViews(vararg ids: Int)
+fun <V : View> DialogFragment.bindOptionalViews(vararg ids: Int)
: ReadOnlyProperty<DialogFragment, List<V>> = optional(ids, viewFinder)
-public fun <V : View> android.support.v4.app.DialogFragment.bindOptionalViews(vararg ids: Int)
+fun <V : View> android.support.v4.app.DialogFragment.bindOptionalViews(vararg ids: Int)
: ReadOnlyProperty<android.support.v4.app.DialogFragment, List<V>> = optional(ids, viewFinder)
-public fun <V : View> Fragment.bindOptionalViews(vararg ids: Int)
+fun <V : View> Fragment.bindOptionalViews(vararg ids: Int)
: ReadOnlyProperty<Fragment, List<V>> = optional(ids, viewFinder)
-public fun <V : View> android.support.v4.app.Fragment.bindOptionalViews(vararg ids: Int)
+fun <V : View> android.support.v4.app.Fragment.bindOptionalViews(vararg ids: Int)
: ReadOnlyProperty<android.support.v4.app.Fragment, List<V>> = optional(ids, viewFinder)
-public fun <V : View> ViewHolder.bindOptionalViews(vararg ids: Int)
+fun <V : View> ViewHolder.bindOptionalViews(vararg ids: Int)
: ReadOnlyProperty<ViewHolder, List<V>> = 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)