diff options
Diffstat (limited to 'adapter/src/main/kotlin/ca/allanwang/kau/adapters')
3 files changed, 64 insertions, 16 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 +} |