aboutsummaryrefslogtreecommitdiff
path: root/adapter
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-12-24 01:17:31 -0500
committerGitHub <noreply@github.com>2018-12-24 01:17:31 -0500
commitfb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b (patch)
treecc6d67461b6caa256043b9482f7646831d528a08 /adapter
parenta380adea1052d39f23c9c4d432a9380ce347d6c4 (diff)
downloadkau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.tar.gz
kau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.tar.bz2
kau-fb90c4a4ab23f2fd246c29c1dde4d6e155a2e38b.zip
Enhancement/ktlint (#179)
* Add spotless dependency * Apply ktlint * Add license headers
Diffstat (limited to 'adapter')
-rw-r--r--adapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt19
-rw-r--r--adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt25
-rw-r--r--adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt36
-rw-r--r--adapter/src/main/kotlin/ca/allanwang/kau/animators/AnimatorInterfaces.kt21
-rw-r--r--adapter/src/main/kotlin/ca/allanwang/kau/animators/DefaultAnimator.kt18
-rw-r--r--adapter/src/main/kotlin/ca/allanwang/kau/animators/FadeScaleAnimator.kt32
-rw-r--r--adapter/src/main/kotlin/ca/allanwang/kau/animators/KauAnimator.kt32
-rw-r--r--adapter/src/main/kotlin/ca/allanwang/kau/animators/NoAnimator.kt26
-rw-r--r--adapter/src/main/kotlin/ca/allanwang/kau/animators/SlideAnimator.kt29
-rw-r--r--adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt33
-rw-r--r--adapter/src/main/kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt25
-rw-r--r--adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt25
12 files changed, 260 insertions, 61 deletions
diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt
index b754cb4..17fd09f 100644
--- a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt
+++ b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.adapters
import com.mikepenz.fastadapter.FastAdapter
@@ -14,10 +29,10 @@ import com.mikepenz.fastadapter.select.SelectExtension
* Add kotlin's generic syntax to better support out types
*/
fun <Item : IItem<*, *>> fastAdapter(vararg adapter: IAdapter<out Item>) =
- FastAdapter.with<Item, IAdapter<out Item>>(adapter.toList())!!
+ FastAdapter.with<Item, IAdapter<out Item>>(adapter.toList())!!
inline fun <reified T : IAdapterExtension<Item>, Item : IItem<*, *>> FastAdapter<Item>.getExtension(): T? =
- getExtension(T::class.java)
+ getExtension(T::class.java)
/**
* Returns selection size, or -1 if selection is disabled
diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt
index 75cf876..152982f 100644
--- a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt
+++ b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt
@@ -1,11 +1,26 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.adapters
import android.content.res.ColorStateList
import android.os.Build
-import androidx.annotation.RequiresApi
import android.view.View
import android.widget.ImageView
import android.widget.TextView
+import androidx.annotation.RequiresApi
import ca.allanwang.kau.ui.createSimpleRippleDrawable
import ca.allanwang.kau.utils.adjustAlpha
import com.mikepenz.fastadapter.IItem
@@ -21,9 +36,9 @@ import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter
* If that item extends [ThemableIItem], then the colors will be set
*/
class FastItemThemedAdapter<Item : IItem<*, *>>(
- textColor: Int? = null,
- backgroundColor: Int? = null,
- accentColor: Int? = null
+ textColor: Int? = null,
+ backgroundColor: Int? = null,
+ accentColor: Int? = null
) : FastItemAdapter<Item>() {
constructor(colors: ThemableIItemColors) : this(colors.textColor, colors.backgroundColor, colors.accentColor)
@@ -183,4 +198,4 @@ class ThemableIItemDelegate : ThemableIItem, ThemableIItemColors by ThemableIIte
val color = accentColor ?: textColor ?: return
views.forEach { it?.drawable?.setTintList(ColorStateList.valueOf(color)) }
}
-} \ No newline at end of file
+}
diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt
index a23ac37..40b4774 100644
--- a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt
+++ b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt
@@ -1,7 +1,22 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.adapters
-import androidx.annotation.IntRange
import android.view.View
+import androidx.annotation.IntRange
import com.mikepenz.fastadapter.FastAdapter
import com.mikepenz.fastadapter.IAdapter
import com.mikepenz.fastadapter.IItem
@@ -10,10 +25,12 @@ import com.mikepenz.fastadapter.listeners.OnClickListener
/**
* Created by Allan Wang on 26/12/17.
*/
-fun <Item : IItem<*, *>> FastAdapter<Item>.withOnRepeatedClickListener(count: Int,
- duration: Long,
- event: OnClickListener<Item>) =
- withOnClickListener(RepeatedClickListener(count, duration, event))
+fun <Item : IItem<*, *>> FastAdapter<Item>.withOnRepeatedClickListener(
+ count: Int,
+ duration: Long,
+ event: OnClickListener<Item>
+) =
+ withOnClickListener(RepeatedClickListener(count, duration, event))
/**
* Registers and skips each click until the designated [count] clicks are triggered,
@@ -21,9 +38,10 @@ fun <Item : IItem<*, *>> FastAdapter<Item>.withOnRepeatedClickListener(count: In
* Only then will the [event] be fired, and everything will be reset.
*/
private class RepeatedClickListener<Item : IItem<*, *>>(
- @IntRange(from = 1) val count: Int,
- @IntRange(from = 1) val duration: Long,
- val event: OnClickListener<Item>) : OnClickListener<Item> {
+ @IntRange(from = 1) val count: Int,
+ @IntRange(from = 1) val duration: Long,
+ val event: OnClickListener<Item>
+) : OnClickListener<Item> {
init {
if (count <= 0)
@@ -49,4 +67,4 @@ private class RepeatedClickListener<Item : IItem<*, *>>(
}
return false
}
-} \ No newline at end of file
+}
diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/animators/AnimatorInterfaces.kt b/adapter/src/main/kotlin/ca/allanwang/kau/animators/AnimatorInterfaces.kt
index 15c3b41..b83a2d0 100644
--- a/adapter/src/main/kotlin/ca/allanwang/kau/animators/AnimatorInterfaces.kt
+++ b/adapter/src/main/kotlin/ca/allanwang/kau/animators/AnimatorInterfaces.kt
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.animators
import android.view.View
@@ -25,7 +40,11 @@ interface KauAnimatorRemove {
}
interface KauAnimatorChange {
- fun changeOldAnimation(holder: RecyclerView.ViewHolder, changeInfo: BaseItemAnimator.ChangeInfo): ViewPropertyAnimator.() -> Unit
+ fun changeOldAnimation(
+ holder: RecyclerView.ViewHolder,
+ changeInfo: BaseItemAnimator.ChangeInfo
+ ): ViewPropertyAnimator.() -> Unit
+
fun changeNewAnimation(holder: RecyclerView.ViewHolder): ViewPropertyAnimator.() -> Unit
fun changeAnimationCleanup(holder: RecyclerView.ViewHolder): View.() -> Unit
}
diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/animators/DefaultAnimator.kt b/adapter/src/main/kotlin/ca/allanwang/kau/animators/DefaultAnimator.kt
index f2b6353..4e342ab 100644
--- a/adapter/src/main/kotlin/ca/allanwang/kau/animators/DefaultAnimator.kt
+++ b/adapter/src/main/kotlin/ca/allanwang/kau/animators/DefaultAnimator.kt
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.animators
import android.view.ViewPropertyAnimator
@@ -59,5 +74,4 @@ open class DefaultAnimator : BaseItemAnimator() {
override fun changeAnimationCleanup(holder: RecyclerView.ViewHolder) {
holder.itemView.alpha = 1f
}
-
-} \ No newline at end of file
+}
diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/animators/FadeScaleAnimator.kt b/adapter/src/main/kotlin/ca/allanwang/kau/animators/FadeScaleAnimator.kt
index dec5f79..9113b0e 100644
--- a/adapter/src/main/kotlin/ca/allanwang/kau/animators/FadeScaleAnimator.kt
+++ b/adapter/src/main/kotlin/ca/allanwang/kau/animators/FadeScaleAnimator.kt
@@ -1,14 +1,30 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.animators
-import androidx.recyclerview.widget.RecyclerView
import android.view.View
import android.view.ViewPropertyAnimator
+import androidx.recyclerview.widget.RecyclerView
import ca.allanwang.kau.utils.scaleXY
/**
* Created by Allan Wang on 2017-07-11.
*/
-class FadeScaleAnimatorAdd(val scaleFactor: Float = 1.0f, override var itemDelayFactor: Float = 0.125f) : KauAnimatorAdd {
+class FadeScaleAnimatorAdd(val scaleFactor: Float = 1.0f, override var itemDelayFactor: Float = 0.125f) :
+ KauAnimatorAdd {
override fun animationPrepare(holder: RecyclerView.ViewHolder): View.() -> Unit = {
scaleXY = scaleFactor
@@ -26,10 +42,10 @@ class FadeScaleAnimatorAdd(val scaleFactor: Float = 1.0f, override var itemDelay
}
override fun getDelay(remove: Long, move: Long, change: Long): Long = 0L
-
}
-class FadeScaleAnimatorRemove(val scaleFactor: Float = 1.0f, override var itemDelayFactor: Float = 0.125f) : KauAnimatorRemove {
+class FadeScaleAnimatorRemove(val scaleFactor: Float = 1.0f, override var itemDelayFactor: Float = 0.125f) :
+ KauAnimatorRemove {
override fun animation(holder: RecyclerView.ViewHolder): ViewPropertyAnimator.() -> Unit = {
scaleXY(scaleFactor)
@@ -46,10 +62,12 @@ class FadeScaleAnimatorRemove(val scaleFactor: Float = 1.0f, override var itemDe
class FadeAnimatorChange : KauAnimatorChange {
- override fun changeOldAnimation(holder: RecyclerView.ViewHolder, changeInfo: BaseItemAnimator.ChangeInfo): ViewPropertyAnimator.() -> Unit = { alpha(0f) }
+ override fun changeOldAnimation(
+ holder: RecyclerView.ViewHolder,
+ changeInfo: BaseItemAnimator.ChangeInfo
+ ): ViewPropertyAnimator.() -> Unit = { alpha(0f) }
override fun changeNewAnimation(holder: RecyclerView.ViewHolder): ViewPropertyAnimator.() -> Unit = { alpha(1f) }
override fun changeAnimationCleanup(holder: RecyclerView.ViewHolder): View.() -> Unit = { alpha = 1f }
-
-} \ No newline at end of file
+}
diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/animators/KauAnimator.kt b/adapter/src/main/kotlin/ca/allanwang/kau/animators/KauAnimator.kt
index a088273..b9df946 100644
--- a/adapter/src/main/kotlin/ca/allanwang/kau/animators/KauAnimator.kt
+++ b/adapter/src/main/kotlin/ca/allanwang/kau/animators/KauAnimator.kt
@@ -1,7 +1,22 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.animators
-import androidx.recyclerview.widget.RecyclerView
import android.view.ViewPropertyAnimator
+import androidx.recyclerview.widget.RecyclerView
import ca.allanwang.kau.utils.KAU_BOTTOM
import ca.allanwang.kau.utils.KAU_RIGHT
@@ -9,12 +24,13 @@ import ca.allanwang.kau.utils.KAU_RIGHT
* Created by Allan Wang on 2017-06-27.
*/
open class KauAnimator(
- val addAnimator: KauAnimatorAdd = SlideAnimatorAdd(KAU_BOTTOM),
- val removeAnimator: KauAnimatorRemove = SlideAnimatorRemove(KAU_RIGHT),
- val changeAnimator: KauAnimatorChange = FadeAnimatorChange()
+ val addAnimator: KauAnimatorAdd = SlideAnimatorAdd(KAU_BOTTOM),
+ val removeAnimator: KauAnimatorRemove = SlideAnimatorRemove(KAU_RIGHT),
+ val changeAnimator: KauAnimatorChange = FadeAnimatorChange()
) : BaseItemAnimator() {
- open fun startDelay(holder: RecyclerView.ViewHolder, duration: Long, factor: Float) = Math.max(0L, (holder.adapterPosition * duration * factor).toLong())
+ open fun startDelay(holder: RecyclerView.ViewHolder, duration: Long, factor: Float) =
+ Math.max(0L, (holder.adapterPosition * duration * factor).toLong())
override fun removeAnimation(holder: RecyclerView.ViewHolder): ViewPropertyAnimator {
return holder.itemView.animate().apply {
@@ -29,7 +45,8 @@ open class KauAnimator(
holder.itemView.apply { removeAnimator.animationCleanup(holder)() }
}
- override fun getRemoveDelay(remove: Long, move: Long, change: Long): Long = removeAnimator.getDelay(remove, move, change)
+ override fun getRemoveDelay(remove: Long, move: Long, change: Long): Long =
+ removeAnimator.getDelay(remove, move, change)
override fun addAnimationPrepare(holder: RecyclerView.ViewHolder) {
holder.itemView.apply { addAnimator.animationPrepare(holder)() }
@@ -69,5 +86,4 @@ open class KauAnimator(
override fun changeAnimationCleanup(holder: RecyclerView.ViewHolder) {
holder.itemView.apply { changeAnimator.changeAnimationCleanup(holder)() }
}
-
-} \ No newline at end of file
+}
diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/animators/NoAnimator.kt b/adapter/src/main/kotlin/ca/allanwang/kau/animators/NoAnimator.kt
index ea0c123..cca8a25 100644
--- a/adapter/src/main/kotlin/ca/allanwang/kau/animators/NoAnimator.kt
+++ b/adapter/src/main/kotlin/ca/allanwang/kau/animators/NoAnimator.kt
@@ -1,8 +1,23 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.animators
-import androidx.recyclerview.widget.RecyclerView
import android.view.View
import android.view.ViewPropertyAnimator
+import androidx.recyclerview.widget.RecyclerView
/**
* Created by Allan Wang on 2017-08-02.
@@ -16,7 +31,6 @@ class NoAnimatorAdd(override var itemDelayFactor: Float = 0f) : KauAnimatorAdd {
override fun animationCleanup(holder: RecyclerView.ViewHolder): View.() -> Unit = { }
override fun getDelay(remove: Long, move: Long, change: Long): Long = 0L
-
}
class NoAnimatorRemove(override var itemDelayFactor: Float = 0f) : KauAnimatorRemove {
@@ -30,10 +44,12 @@ class NoAnimatorRemove(override var itemDelayFactor: Float = 0f) : KauAnimatorRe
class NoAnimatorChange : KauAnimatorChange {
- override fun changeOldAnimation(holder: RecyclerView.ViewHolder, changeInfo: BaseItemAnimator.ChangeInfo): ViewPropertyAnimator.() -> Unit = { }
+ override fun changeOldAnimation(
+ holder: RecyclerView.ViewHolder,
+ changeInfo: BaseItemAnimator.ChangeInfo
+ ): ViewPropertyAnimator.() -> Unit = { }
override fun changeNewAnimation(holder: RecyclerView.ViewHolder): ViewPropertyAnimator.() -> Unit = { }
override fun changeAnimationCleanup(holder: RecyclerView.ViewHolder): View.() -> Unit = { alpha = 1f }
-
-} \ No newline at end of file
+}
diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/animators/SlideAnimator.kt b/adapter/src/main/kotlin/ca/allanwang/kau/animators/SlideAnimator.kt
index 01ad1ff..55d5b2e 100644
--- a/adapter/src/main/kotlin/ca/allanwang/kau/animators/SlideAnimator.kt
+++ b/adapter/src/main/kotlin/ca/allanwang/kau/animators/SlideAnimator.kt
@@ -1,8 +1,23 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.animators
-import androidx.recyclerview.widget.RecyclerView
import android.view.View
import android.view.ViewPropertyAnimator
+import androidx.recyclerview.widget.RecyclerView
import ca.allanwang.kau.utils.KAU_BOTTOM
import ca.allanwang.kau.utils.KAU_LEFT
import ca.allanwang.kau.utils.KAU_RIGHT
@@ -11,7 +26,8 @@ import ca.allanwang.kau.utils.KAU_TOP
/**
* Created by Allan Wang on 2017-07-11.
*/
-class SlideAnimatorAdd(val fromEdge: Int, val slideFactor: Float = 1f, override var itemDelayFactor: Float = 0.125f) : KauAnimatorAdd {
+class SlideAnimatorAdd(val fromEdge: Int, val slideFactor: Float = 1f, override var itemDelayFactor: Float = 0.125f) :
+ KauAnimatorAdd {
override fun animationPrepare(holder: RecyclerView.ViewHolder): View.() -> Unit = {
when (fromEdge) {
@@ -37,10 +53,13 @@ class SlideAnimatorAdd(val fromEdge: Int, val slideFactor: Float = 1f, override
}
override fun getDelay(remove: Long, move: Long, change: Long): Long = 0L
-
}
-class SlideAnimatorRemove(val fromEdge: Int, val slideFactor: Float = 1f, override var itemDelayFactor: Float = 0.125f) : KauAnimatorRemove {
+class SlideAnimatorRemove(
+ val fromEdge: Int,
+ val slideFactor: Float = 1f,
+ override var itemDelayFactor: Float = 0.125f
+) : KauAnimatorRemove {
override fun animation(holder: RecyclerView.ViewHolder): ViewPropertyAnimator.() -> Unit = {
with(holder.itemView) {
when (fromEdge) {
@@ -61,4 +80,4 @@ class SlideAnimatorRemove(val fromEdge: Int, val slideFactor: Float = 1f, overri
}
override fun getDelay(remove: Long, move: Long, change: Long): Long = 0L
-} \ No newline at end of file
+}
diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt
index 784dd3c..6e33833 100644
--- a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt
+++ b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt
@@ -1,18 +1,38 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.iitems
import android.graphics.Color
import android.graphics.drawable.Drawable
-import androidx.recyclerview.widget.RecyclerView
import android.view.View
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.cardview.widget.CardView
+import androidx.recyclerview.widget.RecyclerView
import ca.allanwang.kau.adapter.R
import ca.allanwang.kau.adapters.ThemableIItem
import ca.allanwang.kau.adapters.ThemableIItemDelegate
-import ca.allanwang.kau.utils.*
+import ca.allanwang.kau.utils.INVALID_ID
+import ca.allanwang.kau.utils.drawable
+import ca.allanwang.kau.utils.gone
+import ca.allanwang.kau.utils.string
+import ca.allanwang.kau.utils.toDrawable
+import ca.allanwang.kau.utils.visible
import com.mikepenz.fastadapter.FastAdapter
import com.mikepenz.fastadapter.IItem
import com.mikepenz.fastadapter.listeners.ClickEventHook
@@ -25,9 +45,9 @@ import com.mikepenz.iconics.typeface.IIcon
* The icon and button are hidden by default unless values are given
*/
class CardIItem(
- val builder: Config.() -> Unit = {}
+ val builder: Config.() -> Unit = {}
) : KauIItem<CardIItem, CardIItem.ViewHolder>(
- R.layout.kau_iitem_card, ::ViewHolder, R.id.kau_item_card
+ R.layout.kau_iitem_card, ::ViewHolder, R.id.kau_item_card
), ThemableIItem by ThemableIItemDelegate() {
companion object {
@@ -83,7 +103,7 @@ class CardIItem(
}
val icon = drawable(imageRes) {
imageIIcon?.toDrawable(this@context, sizeDp = 24, color = imageIIconColor)
- ?: image
+ ?: image
}
if (icon != null) holder.icon.visible().setImageDrawable(icon)
}
@@ -117,5 +137,4 @@ class CardIItem(
val bottomRow: LinearLayout = v.findViewById(R.id.kau_card_bottom_row)
val button: Button = v.findViewById(R.id.kau_card_button)
}
-
-} \ No newline at end of file
+}
diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt
index 098f017..2c488b1 100644
--- a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt
+++ b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt
@@ -1,9 +1,24 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.iitems
-import androidx.recyclerview.widget.RecyclerView
import android.view.View
import android.widget.TextView
import androidx.cardview.widget.CardView
+import androidx.recyclerview.widget.RecyclerView
import ca.allanwang.kau.adapter.R
import ca.allanwang.kau.adapters.ThemableIItem
import ca.allanwang.kau.adapters.ThemableIItemDelegate
@@ -17,9 +32,10 @@ import ca.allanwang.kau.utils.string
* Contains only one text view
*/
class HeaderIItem(
- text: String? = null, var textRes: Int = INVALID_ID
+ text: String? = null,
+ var textRes: Int = INVALID_ID
) : KauIItem<HeaderIItem, HeaderIItem.ViewHolder>(
- R.layout.kau_iitem_header, { ViewHolder(it) }, R.id.kau_item_header_big_margin_top
+ R.layout.kau_iitem_header, { ViewHolder(it) }, R.id.kau_item_header_big_margin_top
), ThemableIItem by ThemableIItemDelegate() {
var text: String = text ?: "Header Placeholder"
@@ -40,5 +56,4 @@ class HeaderIItem(
val text: TextView = v.findViewById(R.id.kau_header_text)
val container: CardView = v.findViewById(R.id.kau_header_container)
}
-
-} \ No newline at end of file
+}
diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt
index 205d388..c66dc01 100644
--- a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt
+++ b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt
@@ -1,9 +1,24 @@
+/*
+ * Copyright 2018 Allan Wang
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package ca.allanwang.kau.iitems
import android.annotation.SuppressLint
+import android.view.View
import androidx.annotation.LayoutRes
import androidx.recyclerview.widget.RecyclerView
-import android.view.View
import com.mikepenz.fastadapter.IClickable
import com.mikepenz.fastadapter.IItem
import com.mikepenz.fastadapter.items.AbstractItem
@@ -15,13 +30,13 @@ import com.mikepenz.fastadapter.items.AbstractItem
* If only one iitem type extends the given [layoutRes], you may use it as the type and not worry about another id
*/
open class KauIItem<Item, VH : RecyclerView.ViewHolder>(
- @param:LayoutRes private val layoutRes: Int,
- private val viewHolder: (v: View) -> VH,
- private val type: Int = layoutRes
+ @param:LayoutRes private val layoutRes: Int,
+ private val viewHolder: (v: View) -> VH,
+ private val type: Int = layoutRes
) : AbstractItem<Item, VH>() where Item : IItem<*, *>, Item : IClickable<*> {
@SuppressLint("ResourceType")
final override fun getType(): Int = type
final override fun getViewHolder(v: View): VH = viewHolder(v)
final override fun getLayoutRes(): Int = layoutRes
-} \ No newline at end of file
+}