From 01058912580a3ecfe77eaf6af209e1c46a97f2d7 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 13 Jun 2019 01:14:21 -0700 Subject: Initial fastadapter update --- about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt | 2 +- .../src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt | 8 ++++---- about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt | 6 +++--- about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'about') diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt index 79077c5..cc0eb91 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt @@ -128,7 +128,7 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde * Open hook called just before the main page view is returned * Feel free to add your own items to the adapter in here */ - open fun postInflateMainPage(adapter: FastItemThemedAdapter>) { + open fun postInflateMainPage(adapter: FastItemThemedAdapter>) { } /** diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt index 924a771..814fd64 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt @@ -48,11 +48,11 @@ interface AboutPanelContract { /** * Model list to be added to [adapter] */ - var items: List>? + var items: List>? /** * The adapter, will be late initialized as it depends on configs */ - var adapter: FastItemThemedAdapter> + var adapter: FastItemThemedAdapter> /** * Reference to the recyclerview, will be used to stop scrolling upon exit */ @@ -90,9 +90,9 @@ interface AboutPanelContract { abstract class AboutPanelRecycler : AboutPanelContract { - override var items: List>? = null + override var items: List>? = null - override lateinit var adapter: FastItemThemedAdapter> + override lateinit var adapter: FastItemThemedAdapter> override var recycler: RecyclerView? = null diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt index 755ac81..8ae445d 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt @@ -41,14 +41,14 @@ class FaqIItem(val content: FaqItem) : KauIItem>) { + fun bindEvents(fastAdapter: FastAdapter>) { fastAdapter.withSelectable(false) - .withEventHook(object : ClickEventHook>() { + .withEventHook(object : ClickEventHook>() { override fun onBind(viewHolder: RecyclerView.ViewHolder): View? = (viewHolder as? ViewHolder)?.questionContainer - override fun onClick(v: View, position: Int, adapter: FastAdapter>, item: IItem<*, *>) { + override fun onClick(v: View, position: Int, adapter: FastAdapter>, item: IItem<*>) { if (item !is FaqIItem) return item.isExpanded = !item.isExpanded v.parentViewGroup.findViewById(R.id.faq_item_answer) diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt index 33aac09..dbff49a 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt @@ -39,7 +39,7 @@ class LibraryIItem(val lib: Library) : KauIItem>) { + fun bindEvents(fastAdapter: FastAdapter>) { fastAdapter.withSelectable(false) .withOnClickListener { v, _, item, _ -> if (item !is LibraryIItem) -- cgit v1.2.3 From 99f1e76a4d8d35d4d3ca1aadf68bbc227a70ba01 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 27 Jul 2019 17:56:41 -0700 Subject: Migrate some items --- about/build.gradle | 4 ++- .../main/kotlin/ca/allanwang/kau/about/FaqIItem.kt | 9 +++--- .../kotlin/ca/allanwang/kau/about/LibraryIItem.kt | 23 ++++++++------- .../kotlin/ca/allanwang/kau/iitems/CardIItem.kt | 6 ++-- .../kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt | 2 +- .../allanwang/kau/mediapicker/MediaActionItem.kt | 13 +++++---- .../ca/allanwang/kau/mediapicker/MediaItem.kt | 34 +++++++++++++--------- 7 files changed, 53 insertions(+), 38 deletions(-) (limited to 'about') diff --git a/about/build.gradle b/about/build.gradle index b970530..274ef5c 100644 --- a/about/build.gradle +++ b/about/build.gradle @@ -1,3 +1,5 @@ +import kau.Dependencies + apply from: '../android-lib.gradle' android { @@ -10,7 +12,7 @@ dependencies { implementation project(':core-ui') implementation project(':fastadapter') - api kau.Dependencies.aboutLibraries + api Dependencies.aboutLibraries } apply from: '../artifacts.gradle' diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt index 8ae445d..4873f6e 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt @@ -32,23 +32,24 @@ import ca.allanwang.kau.xml.FaqItem import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.listeners.ClickEventHook +import com.mikepenz.fastadapter.select.getSelectExtension /** * Created by Allan Wang on 2017-08-02. */ -class FaqIItem(val content: FaqItem) : KauIItem( +class FaqIItem(val content: FaqItem) : KauIItem< FaqIItem.ViewHolder>( R.layout.kau_iitem_faq, ::ViewHolder, R.id.kau_item_faq ), ThemableIItem by ThemableIItemDelegate() { companion object { fun bindEvents(fastAdapter: FastAdapter>) { - fastAdapter.withSelectable(false) - .withEventHook(object : ClickEventHook>() { + fastAdapter.getSelectExtension().isSelectable = true + fastAdapter.addEventHook(object : ClickEventHook>() { override fun onBind(viewHolder: RecyclerView.ViewHolder): View? = (viewHolder as? ViewHolder)?.questionContainer - override fun onClick(v: View, position: Int, adapter: FastAdapter>, item: IItem<*>) { + override fun onClick(v: View, position: Int, fastAdapter: FastAdapter>, item: IItem<*>) { if (item !is FaqIItem) return item.isExpanded = !item.isExpanded v.parentViewGroup.findViewById(R.id.faq_item_answer) diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt index dbff49a..445d435 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt @@ -30,26 +30,27 @@ import ca.allanwang.kau.utils.visible import com.mikepenz.aboutlibraries.entity.Library import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.IItem +import com.mikepenz.fastadapter.select.getSelectExtension /** * Created by Allan Wang on 2017-06-27. */ -class LibraryIItem(val lib: Library) : KauIItem( +class LibraryIItem(val lib: Library) : KauIItem( R.layout.kau_iitem_library, ::ViewHolder, R.id.kau_item_library ), ThemableIItem by ThemableIItemDelegate() { companion object { fun bindEvents(fastAdapter: FastAdapter>) { - fastAdapter.withSelectable(false) - .withOnClickListener { v, _, item, _ -> - if (item !is LibraryIItem) - false - else - with(item.lib) { - v!!.context.startLink(libraryWebsite, repositoryLink, authorWebsite) - true - } - } + fastAdapter.getSelectExtension().isSelectable = true + fastAdapter.onClickListener = { v, _, item, _ -> + if (item !is LibraryIItem) + false + else + with(item.lib) { + v!!.context.startLink(libraryWebsite, repositoryLink, authorWebsite) + true + } + } } } diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt index 47c465c..f9f06b9 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt @@ -46,18 +46,18 @@ import com.mikepenz.iconics.typeface.IIcon */ class CardIItem( val builder: Config.() -> Unit = {} -) : KauIItem( +) : KauIItem< CardIItem.ViewHolder>( R.layout.kau_iitem_card, ::ViewHolder, R.id.kau_item_card ), ThemableIItem by ThemableIItemDelegate() { companion object { fun bindClickEvents(fastAdapter: FastAdapter>) { - fastAdapter.withEventHook(object : ClickEventHook>() { + fastAdapter.addEventHook(object : ClickEventHook>() { override fun onBindMany(viewHolder: RecyclerView.ViewHolder): List? { return if (viewHolder is ViewHolder) listOf(viewHolder.card, viewHolder.button) else null } - override fun onClick(v: View, position: Int, adapter: FastAdapter>, item: IItem<*>) { + override fun onClick(v: View, position: Int, fastAdapter: FastAdapter>, item: IItem<*>) { if (item !is CardIItem) return with(item.configs) { when (v.id) { diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt index 2c488b1..551cb59 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt @@ -34,7 +34,7 @@ import ca.allanwang.kau.utils.string class HeaderIItem( text: String? = null, var textRes: Int = INVALID_ID -) : KauIItem( +) : KauIItem( R.layout.kau_iitem_header, { ViewHolder(it) }, R.id.kau_item_header_big_margin_top ), ThemableIItem by ThemableIItemDelegate() { diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt index a365e13..55b448e 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt @@ -26,7 +26,6 @@ import ca.allanwang.kau.permissions.PERMISSION_WRITE_EXTERNAL_STORAGE import ca.allanwang.kau.permissions.kauRequestPermissions import ca.allanwang.kau.utils.materialDialog import ca.allanwang.kau.utils.string -import com.mikepenz.google_material_typeface_library.GoogleMaterial import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial import java.io.File @@ -37,18 +36,22 @@ import java.io.File class MediaActionItem( val action: MediaAction, val mediaType: MediaType -) : KauIItem( +) : KauIItem( R.layout.kau_iitem_image_basic, { MediaItemBasic.ViewHolder(it) }, R.id.kau_item_media_action ) { - override fun isSelectable(): Boolean = false - override fun bindView(holder: MediaItemBasic.ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) holder.image.apply { - setImageDrawable(MediaPickerCore.getIconDrawable(context, action.iicon(this@MediaActionItem), action.color)) + setImageDrawable( + MediaPickerCore.getIconDrawable( + context, + action.iicon(this@MediaActionItem), + action.color + ) + ) setOnClickListener { action(context, this@MediaActionItem) } } } diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt index 5d3e7b9..5d47590 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt @@ -24,33 +24,37 @@ import com.bumptech.glide.load.engine.GlideException import com.bumptech.glide.request.RequestListener import com.bumptech.glide.request.target.Target import com.mikepenz.fastadapter.FastAdapter +import com.mikepenz.fastadapter.select.getSelectExtension /** * Created by Allan Wang on 2017-07-04. */ class MediaItem(val data: MediaModel) : - KauIItem(R.layout.kau_iitem_image, { ViewHolder(it) }), + KauIItem(R.layout.kau_iitem_image, { ViewHolder(it) }), GlideContract by GlideDelegate() { private var failedToLoad = false companion object { fun bindEvents(fastAdapter: FastAdapter) { - fastAdapter.withMultiSelect(true) - .withSelectable(true) - //adapter selector occurs before the on click event - .withOnClickListener { v, _, item, _ -> - val image = v as BlurredImageView - if (item.isSelected) image.blur() - else image.removeBlur() - true - } + fastAdapter.getSelectExtension().apply { + isSelectable = true + multiSelect = true + } + fastAdapter.onClickListener = { v, _, item, _ -> + val image = v as BlurredImageView + if (item.isSelected) image.blur() + else image.removeBlur() + true + } } } - override fun isSelectable(): Boolean = !failedToLoad + override var isSelectable: Boolean + get() = !failedToLoad + set(value) {} - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) glide(holder.itemView) .load(data.data) @@ -63,7 +67,11 @@ class MediaItem(val data: MediaModel) : isFirstResource: Boolean ): Boolean { failedToLoad = true - holder.container.imageBase.setImageDrawable(MediaPickerCore.getErrorDrawable(holder.itemView.context)) + holder.container.imageBase.setImageDrawable( + MediaPickerCore.getErrorDrawable( + holder.itemView.context + ) + ) return true } -- cgit v1.2.3 From 63f6b70cc81ec9dc6e92b6521dfd78fa72fe70a5 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 27 Jul 2019 18:59:14 -0700 Subject: Fix compile errors --- .../ca/allanwang/kau/about/AboutPanelDelegate.kt | 8 +-- .../kotlin/ca/allanwang/kau/about/CutoutIItem.kt | 6 ++- .../kotlin/ca/allanwang/kau/about/LibraryIItem.kt | 4 +- android-lib.gradle | 1 + .../ca/allanwang/kau/permissions/Permissions.kt | 3 ++ .../kotlin/ca/allanwang/kau/utils/Kotterknife.kt | 6 +-- .../ca/allanwang/kau/adapters/AdapterUtils.kt | 7 +-- .../kau/adapters/FastItemThemedAdapter.kt | 34 ++++++------ .../kau/adapters/RepeatedClickListener.kt | 18 ++++--- .../allanwang/kau/kpref/activity/KPrefActivity.kt | 13 +++-- .../kau/kpref/activity/items/KPrefCheckbox.kt | 5 +- .../kau/kpref/activity/items/KPrefColorPicker.kt | 10 ++-- .../kau/kpref/activity/items/KPrefHeader.kt | 8 +-- .../kau/kpref/activity/items/KPrefItemBase.kt | 8 +-- .../kau/kpref/activity/items/KPrefItemCore.kt | 4 +- .../kau/kpref/activity/items/KPrefPlainText.kt | 3 +- .../kau/kpref/activity/items/KPrefSeekbar.kt | 11 ++-- .../kau/kpref/activity/items/KPrefSubItems.kt | 6 ++- .../kau/kpref/activity/items/KPrefText.kt | 8 +-- .../kau/kpref/activity/items/KPrefTimePicker.kt | 17 ++++-- .../allanwang/kau/mediapicker/BlurredImageView.kt | 33 ++++++------ .../allanwang/kau/mediapicker/MediaActionItem.kt | 4 ++ .../ca/allanwang/kau/mediapicker/MediaItem.kt | 2 +- .../ca/allanwang/kau/mediapicker/MediaItemBasic.kt | 21 ++++---- .../ca/allanwang/kau/mediapicker/MediaModel.kt | 2 + .../kau/mediapicker/MediaPickerActivityBase.kt | 30 ++++++++--- .../mediapicker/MediaPickerActivityOverlayBase.kt | 2 +- .../allanwang/kau/mediapicker/MediaPickerCore.kt | 63 ++++++++++++---------- sample/build.gradle | 1 + .../ca/allanwang/kau/sample/AdapterActivity.kt | 2 +- .../kotlin/ca/allanwang/kau/sample/AnimActivity.kt | 10 +++- .../kotlin/ca/allanwang/kau/sample/MainActivity.kt | 2 +- .../ca/allanwang/kau/sample/PermissionCheckbox.kt | 2 +- .../ca/allanwang/kau/searchview/SearchItem.kt | 4 +- .../ca/allanwang/kau/searchview/SearchView.kt | 48 ++++++++++++----- 35 files changed, 255 insertions(+), 151 deletions(-) (limited to 'about') diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt index aae6cb0..512516d 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt @@ -48,7 +48,7 @@ interface AboutPanelContract { /** * Model list to be added to [adapter] */ - var items: List>? + var items: List> /** * The adapter, will be late initialized as it depends on configs */ @@ -90,7 +90,7 @@ interface AboutPanelContract { abstract class AboutPanelRecycler : AboutPanelContract { - override var items: List>? = null + override var items: List> = emptyList() override lateinit var adapter: FastItemThemedAdapter> @@ -116,7 +116,9 @@ abstract class AboutPanelRecycler : AboutPanelContract { } override fun addItems(activity: AboutActivityBase, position: Int) { - if (items == null) return + if (items.isEmpty()) { + return + } activity.pageStatus[position] = 2 postDelayed(300) { addItemsImpl(activity, position) } } diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt index b51c9c8..d51db46 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt @@ -27,11 +27,13 @@ import ca.allanwang.kau.ui.views.CutoutView * * Just a cutout item with some defaults in [R.layout.kau_iitem_cutout] */ -class CutoutIItem(val config: CutoutView.() -> Unit = {}) : KauIItem( +class CutoutIItem(val config: CutoutView.() -> Unit = {}) : KauIItem( R.layout.kau_iitem_cutout, ::ViewHolder, R.id.kau_item_cutout ), ThemableIItem by ThemableIItemDelegate() { - override fun isSelectable(): Boolean = false + override var isSelectable: Boolean + get() = false + set(_) {} override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt index 445d435..dcc0874 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt @@ -54,7 +54,9 @@ class LibraryIItem(val lib: Library) : KauIItem( } } - override fun isSelectable(): Boolean = false + override var isSelectable: Boolean + get() = false + set(_) {} override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) diff --git a/android-lib.gradle b/android-lib.gradle index 90ec6bf..486b4ed 100644 --- a/android-lib.gradle +++ b/android-lib.gradle @@ -59,6 +59,7 @@ android { packagingOptions { pickFirst 'META-INF/core_release.kotlin_module' pickFirst 'META-INF/library_release.kotlin_module' + pickFirst 'META-INF/library-core_release.kotlin_module' } compileOptions { diff --git a/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt b/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt index 3c90b05..f649cc6 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package ca.allanwang.kau.permissions import android.Manifest @@ -76,6 +77,8 @@ const val PERMISSION_READ_CALL_LOG = Manifest.permission.READ_CALL_LOG const val PERMISSION_WRITE_CALL_LOG = Manifest.permission.WRITE_CALL_LOG const val PERMISSION_ADD_VOICEMAIL = Manifest.permission.ADD_VOICEMAIL const val PERMISSION_USE_SIP = Manifest.permission.USE_SIP +@Deprecated(level = DeprecationLevel.WARNING, message = "Permission is deprecated") +@Suppress("DEPRECATION") const val PERMISSION_PROCESS_OUTGOING_CALLS = Manifest.permission.PROCESS_OUTGOING_CALLS @RequiresApi(Build.VERSION_CODES.KITKAT_WATCH) diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt index 8765c69..aaef160 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt @@ -116,11 +116,11 @@ private inline val Dialog.viewFinder: Dialog.(Int) -> View? private inline val DialogFragment.viewFinder: DialogFragment.(Int) -> View? get() = { dialog.findViewById(it) } private inline val SupportDialogFragment.viewFinder: SupportDialogFragment.(Int) -> View? - get() = { dialog.findViewById(it) } + get() = { dialog?.findViewById(it) } private inline val Fragment.viewFinder: Fragment.(Int) -> View? - get() = { view!!.findViewById(it) } + get() = { view?.findViewById(it) } private inline val SupportFragment.viewFinder: SupportFragment.(Int) -> View? - get() = { view!!.findViewById(it) } + get() = { view?.findViewById(it) } private inline val ViewHolder.viewFinder: ViewHolder.(Int) -> View? get() = { itemView.findViewById(it) } diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt index 42fe1a2..14fdc9d 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt @@ -31,14 +31,11 @@ import com.mikepenz.fastadapter.select.SelectExtension fun > fastAdapter(vararg adapter: IAdapter) = FastAdapter.with>(adapter.toList()) -inline fun , Item : IItem<*>> FastAdapter.getExtension(): T? = - getExtension(T::class.java) - /** * Returns selection size, or -1 if selection is disabled */ inline val > IAdapter.selectionSize: Int - get() = fastAdapter?.getExtension, Item>()?.selections?.size ?: -1 + get() = fastAdapter?.getExtension>()?.selections?.size ?: -1 inline val > IAdapter.selectedItems: Set - get() = fastAdapter?.getExtension, Item>()?.selectedItems ?: emptySet() + get() = fastAdapter?.getExtension>()?.selectedItems ?: emptySet() diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt index 01ac0e5..e6d4b24 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt @@ -24,6 +24,7 @@ import androidx.annotation.RequiresApi import ca.allanwang.kau.ui.createSimpleRippleDrawable import ca.allanwang.kau.utils.adjustAlpha import com.mikepenz.fastadapter.IItem +import com.mikepenz.fastadapter.IItemAdapter import com.mikepenz.fastadapter.adapters.FastItemAdapter /** @@ -40,7 +41,11 @@ class FastItemThemedAdapter>( backgroundColor: Int? = null, accentColor: Int? = null ) : FastItemAdapter() { - constructor(colors: ThemableIItemColors) : this(colors.textColor, colors.backgroundColor, colors.accentColor) + constructor(colors: ThemableIItemColors) : this( + colors.textColor, + colors.backgroundColor, + colors.accentColor + ) var textColor: Int? = textColor set(value) { @@ -73,46 +78,41 @@ class FastItemThemedAdapter>( notifyAdapterDataSetChanged() } - override fun add(position: Int, items: List): FastItemAdapter { + override fun add(position: Int, items: List): IItemAdapter { injectTheme(items) return super.add(position, items) } - override fun add(position: Int, item: Item): FastItemAdapter { - injectTheme(item) - return super.add(position, item) + override fun add(position: Int, vararg items: Item): IItemAdapter { + injectTheme(items.toList()) + return super.add(position, *items) } - override fun add(item: Item): FastItemAdapter { - injectTheme(item) - return super.add(item) + override fun add(vararg items: Item): IItemAdapter { + injectTheme(items.toList()) + return super.add(*items) } - override fun add(items: List?): FastItemAdapter { + override fun add(items: List): IItemAdapter { injectTheme(items) return super.add(items) } - override fun set(items: List?): FastItemAdapter { + override fun set(items: List): IItemAdapter { injectTheme(items) return super.set(items) } - override fun set(position: Int, item: Item): FastItemAdapter { + override fun set(position: Int, item: Item): IItemAdapter { injectTheme(item) return super.set(position, item) } - override fun setNewList(items: List?, retainFilter: Boolean): FastItemAdapter { + override fun setNewList(items: List, retainFilter: Boolean): IItemAdapter { injectTheme(items) return super.setNewList(items, retainFilter) } - override fun setNewList(items: List?): FastItemAdapter { - injectTheme(items) - return super.setNewList(items) - } - private fun injectTheme(items: Collection?>?) { items?.forEach { injectTheme(it) } } diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt index 3e7d707..99c367b 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt @@ -17,10 +17,10 @@ package ca.allanwang.kau.adapters import android.view.View import androidx.annotation.IntRange +import com.mikepenz.fastadapter.ClickListener import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.IAdapter import com.mikepenz.fastadapter.IItem -import com.mikepenz.fastadapter.listeners.OnClickListener /** * Created by Allan Wang on 26/12/17. @@ -28,9 +28,11 @@ import com.mikepenz.fastadapter.listeners.OnClickListener fun > FastAdapter.withOnRepeatedClickListener( count: Int, duration: Long, - event: OnClickListener -) = - withOnClickListener(RepeatedClickListener(count, duration, event)) + event: ClickListener +): FastAdapter { + onClickListener = RepeatedClickListener(count, duration, event) + return this +} /** * Registers and skips each click until the designated [count] clicks are triggered, @@ -40,8 +42,8 @@ fun > FastAdapter.withOnRepeatedClickListener( private class RepeatedClickListener>( @IntRange(from = 1) val count: Int, @IntRange(from = 1) val duration: Long, - val event: OnClickListener -) : OnClickListener { + val event: ClickListener +) : ClickListener { init { if (count <= 0) @@ -53,7 +55,7 @@ private class RepeatedClickListener>( private var chain = 0 private var time = -1L - override fun onClick(v: View?, adapter: IAdapter, item: Item, position: Int): Boolean { + override fun invoke(v: View?, adapter: IAdapter, item: Item, position: Int): Boolean { val now = System.currentTimeMillis() if (time - now < duration) chain++ @@ -62,7 +64,7 @@ private class RepeatedClickListener>( time = now if (chain == count) { chain = 0 - event.onClick(v, adapter, item, position) + event(v, adapter, item, position) return true } return false diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt index b701a07..f11afde 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt @@ -32,6 +32,7 @@ import ca.allanwang.kau.utils.resolveColor import ca.allanwang.kau.utils.statusBarColor import ca.allanwang.kau.utils.withLinearAdapter import com.mikepenz.fastadapter.adapters.FastItemAdapter +import com.mikepenz.fastadapter.select.getSelectExtension import kotlinx.android.synthetic.main.kau_pref_activity.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -82,7 +83,8 @@ abstract class KPrefActivity : KauBaseActivity(), KPrefActivityContract { toolbar.setNavigationOnClickListener { onBackPressed() } setDisplayShowTitleEnabled(false) } - window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + window.decorView.systemUiVisibility = + View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN statusBarColor = 0x30000000 kau_toolbar_ripple.set(resolveColor(R.attr.colorPrimary)) kau_ripple.set(resolveColor(android.R.attr.colorBackground)) @@ -92,8 +94,13 @@ abstract class KPrefActivity : KauBaseActivity(), KPrefActivityContract { core.builder() globalOptions = GlobalOptions(core, this) kau_recycler.withLinearAdapter(adapter) - adapter.withSelectable(false) - .withOnClickListener { v, _, item, _ -> item.onClick(v!!); true } + adapter.apply { + getSelectExtension().isSelectable = true + onClickListener = { v, _, item, _ -> + item.onClick(v!!) + true + } + } showNextPrefs(R.string.kau_settings, onCreateKPrefs(savedInstanceState), true) } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt index 0f025a6..f4f4a65 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt @@ -34,7 +34,7 @@ open class KPrefCheckbox(builder: BaseContract) : KPrefItemBase) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) val checkbox = holder.bindInnerView(R.layout.kau_pref_checkbox) withAccentColor(checkbox::tint) @@ -42,5 +42,6 @@ open class KPrefCheckbox(builder: BaseContract) : KPrefItemBase(builder) { - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) if (builder.showPreview) { val preview = holder.bindInnerView(R.layout.kau_pref_color) @@ -63,7 +63,7 @@ open class KPrefColorPicker(open val builder: KPrefColorContract) : KPrefItemBas /** * Extension of the base contract and [ColorContract] along with a showPreview option */ - interface KPrefColorContract : KPrefItemBase.BaseContract, ColorContract { + interface KPrefColorContract : BaseContract, ColorContract { var showPreview: Boolean var dialogBuilder: MaterialDialog.() -> Unit } @@ -76,11 +76,13 @@ open class KPrefColorPicker(open val builder: KPrefColorContract) : KPrefItemBas titleId: Int, getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit - ) : KPrefColorContract, KPrefItemBase.BaseContract by BaseBuilder(globalOptions, titleId, getter, setter), + ) : KPrefColorContract, + BaseContract by BaseBuilder(globalOptions, titleId, getter, setter), ColorContract by ColorBuilder() { override var showPreview: Boolean = true override var dialogBuilder: MaterialDialog.() -> Unit = {} } - override fun getType(): Int = R.id.kau_item_pref_color_picker + override val type: Int + get() = R.id.kau_item_pref_color_picker } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt index 7d73322..ca70b61 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefHeader.kt @@ -25,12 +25,14 @@ import ca.allanwang.kau.kpref.activity.R */ open class KPrefHeader(builder: CoreContract) : KPrefItemCore(builder) { - override fun getLayoutRes(): Int = R.layout.kau_pref_header + override val layoutRes: Int + get() = R.layout.kau_pref_header - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) withAccentColor(holder.title::setTextColor) } - override fun getType() = R.id.kau_item_pref_header + override val type: Int + get() = R.id.kau_item_pref_header } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt index c597b63..9197057 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt @@ -46,7 +46,7 @@ abstract class KPrefItemBase(protected val base: BaseContract) : KPrefItem } @CallSuper - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) _enabled = base.enabler() with(holder) { @@ -77,12 +77,14 @@ abstract class KPrefItemBase(protected val base: BaseContract) : KPrefItem super.unbindView(holder) holder.container?.apply { isEnabled = true - background = holder.itemView.context.resolveDrawable(android.R.attr.selectableItemBackground) + background = + holder.itemView.context.resolveDrawable(android.R.attr.selectableItemBackground) alpha = 1.0f } } - final override fun getLayoutRes(): Int = R.layout.kau_pref_core + final override val layoutRes: Int + get() = R.layout.kau_pref_core /** * Extension of the core contract diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt index 36bf670..79b7e82 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt @@ -48,7 +48,7 @@ import com.mikepenz.iconics.typeface.IIcon * Core class containing nothing but the view items */ -abstract class KPrefItemCore(val core: CoreContract) : AbstractItem(), KPrefItemActions by core, +abstract class KPrefItemCore(val core: CoreContract) : AbstractItem(), KPrefItemActions by core, ThemableIItem by ThemableIItemDelegate() { final override fun getViewHolder(v: View) = ViewHolder(v) @@ -70,7 +70,7 @@ abstract class KPrefItemCore(val core: CoreContract) : AbstractItem) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) with(holder) { updateTitle() diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt index 6a0aaf5..7381a07 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefPlainText.kt @@ -36,5 +36,6 @@ open class KPrefPlainText(open val builder: KPrefPlainTextBuilder) : KPrefItemBa titleId: Int ) : BaseContract by BaseBuilder(globalOptions, titleId, {}, {}) - override fun getType(): Int = R.id.kau_item_pref_plain_text + override val type: Int + get() = R.id.kau_item_pref_plain_text } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt index a582ec4..5de1f83 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSeekbar.kt @@ -37,7 +37,7 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( override fun KClick.defaultOnClick() = Unit - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) val text = holder.bindInnerView(R.layout.kau_pref_seekbar_text) withTextColor(text::setTextColor) @@ -60,7 +60,8 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( }) } withAccentColor(seekbar::tint) - text.text = builder.toText(seekbar.progress.fromProgress) //set initial text in case no change occurs + text.text = + builder.toText(seekbar.progress.fromProgress) //set initial text in case no change occurs seekbar.progress = pref.toProgress seekbar.isEnabled = builder.enabler() } @@ -87,7 +88,8 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( titleId: Int, getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit - ) : KPrefSeekbarContract, BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { + ) : KPrefSeekbarContract, + BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { override var min: Int = 0 @@ -118,5 +120,6 @@ open class KPrefSeekbar(val builder: KPrefSeekbarContract) : KPrefItemBase( protected inline val Int.fromProgress: Int get() = this * increment + min - override fun getType(): Int = R.id.kau_item_pref_seekbar + override val type: Int + get() = R.id.kau_item_pref_seekbar } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt index 1fa528b..8474627 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefSubItems.kt @@ -33,7 +33,8 @@ open class KPrefSubItems(open val builder: KPrefSubItemsContract) : KPrefItemCor builder.globalOptions.showNextPrefs(builder.titleFun(), builder.itemBuilder) } - override fun getLayoutRes(): Int = R.layout.kau_pref_core + override val layoutRes: Int + get() = R.layout.kau_pref_core /** * Extension of the base contract with an optional text getter @@ -51,5 +52,6 @@ open class KPrefSubItems(open val builder: KPrefSubItemsContract) : KPrefItemCor override val itemBuilder: KPrefAdapterBuilder.() -> Unit ) : KPrefSubItemsContract, CoreContract by CoreBuilder(globalOptions, titleId) - override fun getType(): Int = R.id.kau_item_pref_sub_item + override val type: Int + get() = R.id.kau_item_pref_sub_item } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt index 76c9e20..50f0c62 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefText.kt @@ -46,7 +46,7 @@ open class KPrefText(open val builder: KPrefTextContract) : KPrefItemBase< context.toast("No click function set") } - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) val textView = holder.bindInnerView(R.layout.kau_pref_text) withTextColor(textView::setTextColor) @@ -68,9 +68,11 @@ open class KPrefText(open val builder: KPrefTextContract) : KPrefItemBase< titleId: Int, getter: () -> T, setter: KPrefItemActions.(value: T) -> Unit - ) : KPrefTextContract, BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { + ) : KPrefTextContract, + BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { override var textGetter: (T) -> String? = { it?.toString() } } - override fun getType(): Int = R.id.kau_item_pref_text + override val type: Int + get() = R.id.kau_item_pref_text } diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt index f50397c..318b630 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefTimePicker.kt @@ -33,7 +33,8 @@ import java.util.Locale */ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText(builder) { - interface KPrefTimeContract : KPrefText.KPrefTextContract, TimePickerDialog.OnTimeSetListener { + interface KPrefTimeContract : KPrefText.KPrefTextContract, + TimePickerDialog.OnTimeSetListener { var use24HourFormat: Boolean } @@ -50,7 +51,8 @@ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText< titleId: Int, getter: () -> Int, setter: KPrefItemActions.(value: Int) -> Unit - ) : KPrefTimeContract, BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { + ) : KPrefTimeContract, + BaseContract by BaseBuilder(globalOptions, titleId, getter, setter) { override var use24HourFormat: Boolean = false @@ -64,11 +66,18 @@ open class KPrefTimePicker(override val builder: KPrefTimeContract) : KPrefText< if (use24HourFormat) String.format(Locale.CANADA, "%d:%02d", hour, min) else - String.format(Locale.CANADA, "%d:%02d %s", hour % 12, min, if (hour >= 12) "PM" else "AM") + String.format( + Locale.CANADA, + "%d:%02d %s", + hour % 12, + min, + if (hour >= 12) "PM" else "AM" + ) } } - override fun getType(): Int = R.id.kau_item_pref_time_picker + override val type: Int + get() = R.id.kau_item_pref_time_picker } private val Int.splitTime: Pair diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt index 739bf47..e430dff 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/BlurredImageView.kt @@ -28,7 +28,7 @@ import ca.allanwang.kau.utils.scaleXY import ca.allanwang.kau.utils.setBackgroundColorRes import ca.allanwang.kau.utils.setIcon import ca.allanwang.kau.utils.visible -import com.mikepenz.google_material_typeface_library.GoogleMaterial +import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial import jp.wasabeef.blurry.internal.BlurFactor import jp.wasabeef.blurry.internal.BlurTask import kotlinx.android.synthetic.main.kau_blurred_imageview.view.* @@ -48,7 +48,9 @@ class BlurredImageView @JvmOverloads constructor( defStyleAttr: Int = 0 ) : FrameLayout(context, attrs, defStyleAttr), MeasureSpecContract by MeasureSpecDelegate() { - private var blurred = false + var isBlurred = false + private set + val imageBase: ImageView get() = image_base init { @@ -69,20 +71,19 @@ class BlurredImageView @JvmOverloads constructor( image_foreground.clearAnimation() } - private fun View.scaleAnimate(scale: Float) = animate().scaleXY(scale).setDuration(ANIMATION_DURATION) - private fun View.alphaAnimate(alpha: Float) = animate().alpha(alpha).setDuration(ANIMATION_DURATION) + private fun View.scaleAnimate(scale: Float) = + animate().scaleXY(scale).setDuration(ANIMATION_DURATION) - fun isBlurred(): Boolean { - return blurred - } + private fun View.alphaAnimate(alpha: Float) = + animate().alpha(alpha).setDuration(ANIMATION_DURATION) /** * Applies a blur and fills the blur image asynchronously * When ready, scales the image down and shows the blur & foreground */ fun blur() { - if (blurred) return - blurred = true + if (isBlurred) return + isBlurred = true val factor = BlurFactor() factor.width = width factor.height = height @@ -100,7 +101,7 @@ class BlurredImageView @JvmOverloads constructor( * is still asynchronous and takes time */ fun blurInstantly() { - blurred = true + isBlurred = true clearAnimation() val factor = BlurFactor() factor.width = width @@ -117,8 +118,8 @@ class BlurredImageView @JvmOverloads constructor( * Animate view back to original state and remove drawable when finished */ fun removeBlur() { - if (!blurred) return - blurred = false + if (!isBlurred) return + isBlurred = false scaleAnimate(1.0f).start() image_blur.alphaAnimate(0f).withEndAction { image_blur.setImageDrawable(null) }.start() image_foreground.alphaAnimate(0f).start() @@ -128,7 +129,7 @@ class BlurredImageView @JvmOverloads constructor( * Clear all animations and unblur the image */ fun removeBlurInstantly() { - blurred = false + isBlurred = false clearAnimation() scaleX = 1.0f scaleX = 1.0f @@ -143,9 +144,9 @@ class BlurredImageView @JvmOverloads constructor( * @return true if new state is blurred; false otherwise */ fun toggleBlur(): Boolean { - if (blurred) removeBlur() + if (isBlurred) removeBlur() else blur() - return blurred + return isBlurred } /** @@ -162,7 +163,7 @@ class BlurredImageView @JvmOverloads constructor( */ fun fullReset() { reset() - fullAction({ it.visible().background = null }) + fullAction { it.visible().background = null } image_foreground.setBackgroundColorRes(R.color.kau_blurred_image_selection_overlay) image_foreground.setIcon(GoogleMaterial.Icon.gmd_check, 30, Color.WHITE) } diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt index 55b448e..552bf0f 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt @@ -42,6 +42,10 @@ class MediaActionItem( R.id.kau_item_media_action ) { + override var isSelectable: Boolean + get() = false + set(_) {} + override fun bindView(holder: MediaItemBasic.ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) holder.image.apply { diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt index 5d47590..88a304f 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt @@ -52,7 +52,7 @@ class MediaItem(val data: MediaModel) : override var isSelectable: Boolean get() = !failedToLoad - set(value) {} + set(_) {} override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt index 73647b8..873289f 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt @@ -27,29 +27,32 @@ import com.bumptech.glide.load.engine.GlideException import com.bumptech.glide.request.RequestListener import com.bumptech.glide.request.target.Target import com.mikepenz.fastadapter.FastAdapter +import com.mikepenz.fastadapter.select.getSelectExtension /** * Created by Allan Wang on 2017-07-04. */ class MediaItemBasic(val data: MediaModel) : - KauIItem(R.layout.kau_iitem_image_basic, { ViewHolder(it) }), + KauIItem(R.layout.kau_iitem_image_basic, { ViewHolder(it) }), GlideContract by GlideDelegate() { companion object { @SuppressLint("NewApi") fun bindEvents(activity: Activity, fastAdapter: FastAdapter) { - fastAdapter.withSelectable(false) - //add image data and return right away - .withOnClickListener { _, _, item, _ -> - activity.finish(arrayListOf(item.data)) - true - } + fastAdapter.getSelectExtension().isSelectable = true + //add image data and return right away + fastAdapter.onClickListener = { _, _, item, _ -> + activity.finish(arrayListOf(item.data)) + true + } } } - override fun isSelectable(): Boolean = false + override var isSelectable: Boolean + get() = false + set(_) {} - override fun bindView(holder: ViewHolder, payloads: List) { + override fun bindView(holder: ViewHolder, payloads: MutableList) { super.bindView(holder, payloads) glide(holder.itemView) .load(data.data) diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt index edd6199..1ba8041 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt @@ -85,6 +85,8 @@ data class MediaModel( } companion object CREATOR : Parcelable.Creator { + @Suppress("DEPRECATION") + // TODO verify data deprecation val projection = arrayOf( MediaStore.MediaColumns.DATA, MediaStore.MediaColumns.MIME_TYPE, diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt index 5e5d1ed..c7cff55 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt @@ -26,7 +26,9 @@ import ca.allanwang.kau.utils.setIcon import ca.allanwang.kau.utils.toDrawable import ca.allanwang.kau.utils.toast import com.google.android.material.appbar.AppBarLayout -import com.mikepenz.google_material_typeface_library.GoogleMaterial +import com.mikepenz.fastadapter.ISelectionListener +import com.mikepenz.fastadapter.select.selectExtension +import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial import kotlinx.android.synthetic.main.kau_activity_image_picker.* /** @@ -46,21 +48,37 @@ abstract class MediaPickerActivityBase( setContentView(R.layout.kau_activity_image_picker) - kau_selection_count.setCompoundDrawables(null, null, GoogleMaterial.Icon.gmd_image.toDrawable(this, 18), null) + kau_selection_count.setCompoundDrawables( + null, + null, + GoogleMaterial.Icon.gmd_image.toDrawable(this, 18), + null + ) setSupportActionBar(kau_toolbar) supportActionBar?.apply { setDisplayHomeAsUpEnabled(true) setDisplayShowHomeEnabled(true) - setHomeAsUpIndicator(GoogleMaterial.Icon.gmd_close.toDrawable(this@MediaPickerActivityBase, 18)) + setHomeAsUpIndicator( + GoogleMaterial.Icon.gmd_close.toDrawable( + this@MediaPickerActivityBase, + 18 + ) + ) } kau_toolbar.setNavigationOnClickListener { onBackPressed() } initializeRecycler(kau_recyclerview) - MediaItem.bindEvents(adapter.fastAdapter) - adapter.fastAdapter.withSelectionListener { _, _ -> - kau_selection_count.text = adapter.selectionSize.toString() + adapter.fastAdapter!!.let { + MediaItem.bindEvents(it) + it.selectExtension { + selectionListener = object : ISelectionListener { + override fun onSelectionChanged(item: MediaItem?, selected: Boolean) { + kau_selection_count.text = adapter.selectionSize.toString() + } + } + } } kau_fab.apply { diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt index a7ee63d..df47688 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt @@ -39,7 +39,7 @@ abstract class MediaPickerActivityOverlayBase( super.onCreate(savedInstanceState) setContentView(R.layout.kau_activity_image_picker_overlay) initializeRecycler(kau_recyclerview) - MediaItemBasic.bindEvents(this, adapter.fastAdapter) + MediaItemBasic.bindEvents(this, adapter.fastAdapter!!) kau_draggable.addExitListener(this, R.transition.kau_image_exit_bottom, R.transition.kau_image_exit_top) kau_draggable.setOnClickListener { finishAfterTransition() } diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt index c928e04..116f511 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt @@ -46,13 +46,10 @@ import com.bumptech.glide.Glide import com.bumptech.glide.RequestManager import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.adapters.ItemAdapter -import com.mikepenz.iconics.IconicsDrawable -import com.mikepenz.iconics.colorInt -import com.mikepenz.iconics.paddingPx -import com.mikepenz.iconics.sizePx +import com.mikepenz.iconics.dsl.ExperimentalIconicsDSL +import com.mikepenz.iconics.dsl.iconicsDrawable import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial -import com.mikepenz.iconics.utils.toIconicsColor import kotlinx.coroutines.CancellationException import java.io.File @@ -91,16 +88,19 @@ abstract class MediaPickerCore>( /** * Create error tile for a given item */ + @ExperimentalIconicsDSL fun getErrorDrawable(context: Context) = getIconDrawable(context, GoogleMaterial.Icon.gmd_error, accentColor) + @ExperimentalIconicsDSL fun getIconDrawable(context: Context, iicon: IIcon, color: Int): Drawable { - val sizePx = MediaPickerCore.computeViewSize(context) - return IconicsDrawable(context, iicon) - .sizePx(sizePx) - .backgroundColor(color.toIconicsColor()) - .paddingPx(sizePx / 3) - .colorInt(Color.WHITE) + val sizePx = computeViewSize(context) + return context.iconicsDrawable(iicon) { + size = sizePx(sizePx) + backgroundColor = colorInt(color) + padding = sizePx(sizePx / 3) + this.color = colorInt(Color.WHITE) + } } var accentColor: Int = 0xff666666.toInt() @@ -110,12 +110,12 @@ abstract class MediaPickerCore>( * This is used for both single and multiple photo picks */ fun onMediaPickerResult(resultCode: Int, data: Intent?): List { - if (resultCode != Activity.RESULT_OK || data == null || !data.hasExtra( - MEDIA_PICKER_RESULT - ) - ) + if (resultCode != Activity.RESULT_OK || + data?.hasExtra(MEDIA_PICKER_RESULT) != true + ) { return emptyList() - return data.getParcelableArrayListExtra(MEDIA_PICKER_RESULT) + } + return data.getParcelableArrayListExtra(MEDIA_PICKER_RESULT) ?: emptyList() } /** @@ -278,8 +278,8 @@ abstract class MediaPickerCore>( override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { if (resultCode != RESULT_OK) { - if (tempPath != null) { - val f = File(tempPath) + tempPath?.let { + val f = File(it) if (f.exists()) f.delete() tempPath = null } @@ -295,14 +295,18 @@ abstract class MediaPickerCore>( private fun onCameraResult(data: Intent?) { val f: File - if (tempPath != null) { - f = File(tempPath) - tempPath = null - } else if (data?.data != null) { - f = File(data.data!!.path) - } else { - KL.d { "Media camera no file found" } - return + val tempPath = tempPath + val dataPath = data?.data?.path + when { + tempPath != null -> { + f = File(tempPath) + this.tempPath = null + } + dataPath != null -> f = File(dataPath) + else -> { + KL.d { "Media camera no file found" } + return + } } if (f.exists()) { KL.v { "Media camera path found: ${f.absolutePath}" } @@ -315,9 +319,10 @@ abstract class MediaPickerCore>( private fun onPickerResult(data: Intent?) { val items = mutableListOf() - if (data?.data != null) { - KL.v { "Media picker data uri: ${data.data!!.path}" } - items.add(data.data!!) + val _data = data?.data + if (_data != null) { + KL.v { "Media picker data uri: ${_data.path}" } + items.add(_data) } else if (data != null) { val clip = data.clipData if (clip != null) { diff --git a/sample/build.gradle b/sample/build.gradle index cacd21f..1441cf0 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -76,6 +76,7 @@ android { packagingOptions { pickFirst 'META-INF/core_release.kotlin_module' pickFirst 'META-INF/library_release.kotlin_module' + pickFirst 'META-INF/library-core_release.kotlin_module' } compileOptions { diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt index 8c35c77..2fedbeb 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt @@ -22,7 +22,7 @@ import ca.allanwang.kau.ui.activities.ElasticRecyclerActivity import ca.allanwang.kau.utils.toast import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.adapters.ItemAdapter -import com.mikepenz.google_material_typeface_library.GoogleMaterial +import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial /** * Created by Allan Wang on 2017-07-17. diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt index aaa6143..f6d5ccc 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt @@ -43,14 +43,20 @@ class AnimActivity : KauBaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val adapter = FastItemAdapter() - setContentView(fullLinearRecycler(adapter).apply { setBackgroundColor(KPrefSample.bgColor.withAlpha(255)) }) + setContentView(fullLinearRecycler(adapter).apply { + setBackgroundColor( + KPrefSample.bgColor.withAlpha( + 255 + ) + ) + }) adapter.add(listOf( PERMISSION_ACCESS_COARSE_LOCATION, PERMISSION_ACCESS_FINE_LOCATION, PERMISSION_CAMERA ).map { PermissionCheckbox(it) }) - adapter.withOnClickListener { _, _, item, _ -> + adapter.onClickListener = { _, _, item, _ -> KL.d { "Perm Click" } kauRequestPermissions(item.permission) { granted, _ -> toast("${item.permission} enabled: $granted") diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt index f4a09cf..11d19e5 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -39,7 +39,7 @@ import ca.allanwang.kau.utils.toast import ca.allanwang.kau.utils.withSceneTransitionAnimation import ca.allanwang.kau.xml.showChangelog import com.afollestad.materialdialogs.input.input -import com.mikepenz.google_material_typeface_library.GoogleMaterial +import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial class MainActivity : KPrefActivity() { diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt index 025179d..7cf6cc1 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt @@ -25,7 +25,7 @@ import ca.allanwang.kau.utils.hasPermission /** * Created by Allan Wang on 2017-07-03. */ -class PermissionCheckbox(val permission: String) : KauIItem( +class PermissionCheckbox(val permission: String) : KauIItem( R.layout.permission_checkbox, { ViewHolder(it) }) { override fun bindView(holder: ViewHolder, payloads: MutableList) { diff --git a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt index 7747d81..7bf01b3 100644 --- a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt +++ b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt @@ -32,7 +32,7 @@ import ca.allanwang.kau.utils.setIcon import ca.allanwang.kau.utils.setRippleBackground import ca.allanwang.kau.utils.visible import com.mikepenz.iconics.typeface.IIcon -import com.mikepenz.google_material_typeface_library.GoogleMaterial +import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial /** * Created by Allan Wang on 2017-06-23. @@ -47,7 +47,7 @@ class SearchItem( val description: String? = null, val iicon: IIcon? = GoogleMaterial.Icon.gmd_search, val image: Drawable? = null -) : KauIItem( +) : KauIItem( R.layout.kau_search_iitem, { ViewHolder(it) }, R.id.kau_item_search diff --git a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt index 18eb675..da06ec4 100644 --- a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt +++ b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt @@ -63,8 +63,9 @@ import ca.allanwang.kau.utils.toDrawable import ca.allanwang.kau.utils.visible import ca.allanwang.kau.utils.withLinearAdapter import com.mikepenz.fastadapter.adapters.FastItemAdapter +import com.mikepenz.fastadapter.select.selectExtension import com.mikepenz.iconics.typeface.IIcon -import com.mikepenz.google_material_typeface_library.GoogleMaterial +import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial import kotlinx.android.synthetic.main.kau_search_view.view.* /** @@ -255,7 +256,11 @@ class SearchView @JvmOverloads constructor( val list = if (value.isEmpty() && configs.noResultsFound != INVALID_ID) listOf(SearchItem("", context.string(configs.noResultsFound), iicon = null)) else value - if (configs.highlightQueryText && value.isNotEmpty()) list.forEach { it.withHighlights(kau_search_edit_text.text?.toString()) } + if (configs.highlightQueryText && value.isNotEmpty()) list.forEach { + it.withHighlights( + kau_search_edit_text.text?.toString() + ) + } cardTransition() adapter.setNewList(list) } @@ -297,7 +302,8 @@ class SearchView @JvmOverloads constructor( View.inflate(context, R.layout.kau_search_view, this) z = 99f kau_search_nav.setSearchIcon(configs.navIcon).setOnClickListener { revealClose() } - kau_search_clear.setSearchIcon(configs.clearIcon).setOnClickListener { kau_search_edit_text.text?.clear() } + kau_search_clear.setSearchIcon(configs.clearIcon) + .setOnClickListener { kau_search_edit_text.text?.clear() } tintForeground(configs.foregroundColor) tintBackground(configs.backgroundColor) with(kau_search_recycler) { @@ -312,11 +318,18 @@ class SearchView @JvmOverloads constructor( itemAnimator = null } with(adapter) { - withSelectable(true) - withOnClickListener { _, _, item, position -> - if (item.key.isNotBlank()) configs.onItemClick(position, item.key, item.content, this@SearchView); true + selectExtension { + isSelectable = true + } + onClickListener = { _, _, item, position -> + if (item.key.isNotBlank()) configs.onItemClick( + position, + item.key, + item.content, + this@SearchView + ); true } - withOnLongClickListener { _, _, item, position -> + onLongClickListener = { _, _, item, position -> if (item.key.isNotBlank()) configs.onItemLongClick( position, item.key, @@ -420,7 +433,8 @@ class SearchView @JvmOverloads constructor( menuX = (locations[0] + view.width / 2) menuHalfHeight = view.height / 2 menuY = (locations[1] + menuHalfHeight) - kau_search_cardview.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener { + kau_search_cardview.viewTreeObserver.addOnPreDrawListener(object : + ViewTreeObserver.OnPreDrawListener { override fun onPreDraw(): Boolean { view.viewTreeObserver.removeOnPreDrawListener(this) kau_search_cardview.setMarginTop(menuY - kau_search_cardview.height / 2) @@ -474,7 +488,11 @@ class SearchView @JvmOverloads constructor( configs.openListener?.invoke(this@SearchView) kau_search_shadow.fadeIn() kau_search_edit_text.showKeyboard() - kau_search_cardview.circularReveal(menuX, menuHalfHeight, duration = configs.revealDuration) { + kau_search_cardview.circularReveal( + menuX, + menuHalfHeight, + duration = configs.revealDuration + ) { cardTransition() kau_search_recycler.visible() } @@ -487,7 +505,9 @@ class SearchView @JvmOverloads constructor( kau_search_shadow.fadeOut(duration = configs.transitionDuration) cardTransition { addEndListener { - kau_search_cardview.circularHide(menuX, menuHalfHeight, duration = configs.revealDuration, + kau_search_cardview.circularHide(menuX, + menuHalfHeight, + duration = configs.revealDuration, onFinish = { configs.closeListener?.invoke(this@SearchView) if (configs.shouldClearOnClose) kau_search_edit_text.text?.clear() @@ -512,7 +532,8 @@ fun Activity.bindSearchView( @IdRes id: Int, @ColorInt menuIconColor: Int = Color.WHITE, config: Configs.() -> Unit = {} -): SearchView = findViewById(android.R.id.content).bindSearchView(menu, id, menuIconColor, config) +): SearchView = + findViewById(android.R.id.content).bindSearchView(menu, id, menuIconColor, config) /** * Bind searchView to a menu item; call this in [Activity.onCreateOptionsMenu] @@ -528,7 +549,10 @@ fun ViewGroup.bindSearchView( ): SearchView { val searchView = SearchView(context) searchView.layoutParams = - FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT) + FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, + FrameLayout.LayoutParams.MATCH_PARENT + ) addView(searchView) searchView.bind(menu, id, menuIconColor, config) return searchView -- cgit v1.2.3 From 6a599e553a467f15be7ed60c554f43aeac5936ca Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 27 Jul 2019 19:16:00 -0700 Subject: Fix theme injection --- .../main/kotlin/ca/allanwang/kau/about/FaqIItem.kt | 27 ++++++++------ docs/Changelog.md | 3 ++ .../kau/adapters/FastItemThemedAdapter.kt | 42 ++++------------------ sample/src/main/res/xml/kau_changelog.xml | 5 +++ 4 files changed, 31 insertions(+), 46 deletions(-) (limited to 'about') diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt index 4873f6e..96b9884 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt @@ -37,7 +37,7 @@ import com.mikepenz.fastadapter.select.getSelectExtension /** * Created by Allan Wang on 2017-08-02. */ -class FaqIItem(val content: FaqItem) : KauIItem< FaqIItem.ViewHolder>( +class FaqIItem(val content: FaqItem) : KauIItem( R.layout.kau_iitem_faq, ::ViewHolder, R.id.kau_item_faq ), ThemableIItem by ThemableIItemDelegate() { @@ -46,16 +46,21 @@ class FaqIItem(val content: FaqItem) : KauIItem< FaqIItem.ViewHolder>( fastAdapter.getSelectExtension().isSelectable = true fastAdapter.addEventHook(object : ClickEventHook>() { - override fun onBind(viewHolder: RecyclerView.ViewHolder): View? = - (viewHolder as? ViewHolder)?.questionContainer + override fun onBind(viewHolder: RecyclerView.ViewHolder): View? = + (viewHolder as? ViewHolder)?.questionContainer - override fun onClick(v: View, position: Int, fastAdapter: FastAdapter>, item: IItem<*>) { - if (item !is FaqIItem) return - item.isExpanded = !item.isExpanded - v.parentViewGroup.findViewById(R.id.faq_item_answer) - .setExpanded(item.isExpanded) - } - }) + override fun onClick( + v: View, + position: Int, + fastAdapter: FastAdapter>, + item: IItem<*> + ) { + if (item !is FaqIItem) return + item.isExpanded = !item.isExpanded + v.parentViewGroup.findViewById(R.id.faq_item_answer) + .setExpanded(item.isExpanded) + } + }) } } @@ -70,7 +75,7 @@ class FaqIItem(val content: FaqItem) : KauIItem< FaqIItem.ViewHolder>( answer.setExpanded(isExpanded, false) if (accentColor != null) answer.setLinkTextColor(accentColor!!) answer.text = content.answer - answer.post { answer.setPaddingLeft(16.dpToPx + number.width) } + answer.post { answer.setPaddingLeft(16.dpToPx + number.width) } // TODO not performant at all; and doesn't align across all items bindTextColor(number, question) bindTextColorSecondary(answer) val bg2 = backgroundColor?.colorToForeground(0.1f) diff --git a/docs/Changelog.md b/docs/Changelog.md index f8287ca..0078430 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,5 +1,8 @@ # Changelog +## v5.2.0 +* :fastadapter: Migrate fastadapter to v4.x.x + ## v5.1.0 * :adapter: Moved fastadapter elements to new module, :fastadapter:. To migrate, simply rename the dependency. If you don't use fast adapter, no changes are necessary * :adapter: Make NoAnimatorChange an object; previously a class diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt index e6d4b24..24a37c4 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt @@ -47,6 +47,13 @@ class FastItemThemedAdapter>( colors.accentColor ) + init { + itemAdapter.interceptor = { + injectTheme(it) + it + } + } + var textColor: Int? = textColor set(value) { if (field == value) return @@ -78,41 +85,6 @@ class FastItemThemedAdapter>( notifyAdapterDataSetChanged() } - override fun add(position: Int, items: List): IItemAdapter { - injectTheme(items) - return super.add(position, items) - } - - override fun add(position: Int, vararg items: Item): IItemAdapter { - injectTheme(items.toList()) - return super.add(position, *items) - } - - override fun add(vararg items: Item): IItemAdapter { - injectTheme(items.toList()) - return super.add(*items) - } - - override fun add(items: List): IItemAdapter { - injectTheme(items) - return super.add(items) - } - - override fun set(items: List): IItemAdapter { - injectTheme(items) - return super.set(items) - } - - override fun set(position: Int, item: Item): IItemAdapter { - injectTheme(item) - return super.set(position, item) - } - - override fun setNewList(items: List, retainFilter: Boolean): IItemAdapter { - injectTheme(items) - return super.setNewList(items, retainFilter) - } - private fun injectTheme(items: Collection?>?) { items?.forEach { injectTheme(it) } } diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml index 62614ed..de73b41 100644 --- a/sample/src/main/res/xml/kau_changelog.xml +++ b/sample/src/main/res/xml/kau_changelog.xml @@ -6,6 +6,11 @@ --> + + + + + -- cgit v1.2.3 From df1f578cdffb5314bde26c7ffbedc6b1a1d96692 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 27 Jul 2019 19:45:00 -0700 Subject: Us genericitem where applicable --- .../ca/allanwang/kau/about/AboutActivityBase.kt | 3 ++- .../ca/allanwang/kau/about/AboutPanelDelegate.kt | 9 +++++---- .../main/kotlin/ca/allanwang/kau/about/FaqIItem.kt | 9 +++++---- .../kotlin/ca/allanwang/kau/about/LibraryIItem.kt | 3 ++- android-lib.gradle | 23 ++++++++++++---------- build.gradle | 19 ++++++++++-------- .../ca/allanwang/kau/adapters/AdapterUtils.kt | 7 ++++--- .../kau/adapters/FastItemThemedAdapter.kt | 7 ++++--- .../kau/adapters/RepeatedClickListener.kt | 5 +++-- .../kotlin/ca/allanwang/kau/iitems/CardIItem.kt | 7 ++++--- .../allanwang/kau/mediapicker/MediaPickerCore.kt | 5 +++-- .../ca/allanwang/kau/sample/AboutActivity.kt | 3 ++- .../ca/allanwang/kau/sample/AdapterActivity.kt | 4 ++-- 13 files changed, 60 insertions(+), 44 deletions(-) (limited to 'about') diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt index cc0eb91..d346090 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt @@ -33,6 +33,7 @@ import ca.allanwang.kau.utils.INVALID_ID import ca.allanwang.kau.utils.dimenPixelSize import com.mikepenz.aboutlibraries.Libs import com.mikepenz.aboutlibraries.entity.Library +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IItem import kotlinx.android.synthetic.main.kau_activity_about.* @@ -128,7 +129,7 @@ abstract class AboutActivityBase(val rClass: Class<*>?, private val configBuilde * Open hook called just before the main page view is returned * Feel free to add your own items to the adapter in here */ - open fun postInflateMainPage(adapter: FastItemThemedAdapter>) { + open fun postInflateMainPage(adapter: FastItemThemedAdapter) { } /** diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt index 512516d..24f1c48 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt @@ -34,6 +34,7 @@ import ca.allanwang.kau.utils.string import ca.allanwang.kau.utils.withMarginDecoration import ca.allanwang.kau.xml.kauParseFaq import com.mikepenz.aboutlibraries.Libs +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IItem import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -48,11 +49,11 @@ interface AboutPanelContract { /** * Model list to be added to [adapter] */ - var items: List> + var items: List /** * The adapter, will be late initialized as it depends on configs */ - var adapter: FastItemThemedAdapter> + var adapter: FastItemThemedAdapter /** * Reference to the recyclerview, will be used to stop scrolling upon exit */ @@ -90,9 +91,9 @@ interface AboutPanelContract { abstract class AboutPanelRecycler : AboutPanelContract { - override var items: List> = emptyList() + override var items: List = emptyList() - override lateinit var adapter: FastItemThemedAdapter> + override lateinit var adapter: FastItemThemedAdapter override var recycler: RecyclerView? = null diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt index 96b9884..0a570f8 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt @@ -30,6 +30,7 @@ import ca.allanwang.kau.utils.parentViewGroup import ca.allanwang.kau.utils.setPaddingLeft import ca.allanwang.kau.xml.FaqItem import com.mikepenz.fastadapter.FastAdapter +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.listeners.ClickEventHook import com.mikepenz.fastadapter.select.getSelectExtension @@ -42,9 +43,9 @@ class FaqIItem(val content: FaqItem) : KauIItem( ), ThemableIItem by ThemableIItemDelegate() { companion object { - fun bindEvents(fastAdapter: FastAdapter>) { + fun bindEvents(fastAdapter: FastAdapter) { fastAdapter.getSelectExtension().isSelectable = true - fastAdapter.addEventHook(object : ClickEventHook>() { + fastAdapter.addEventHook(object : ClickEventHook() { override fun onBind(viewHolder: RecyclerView.ViewHolder): View? = (viewHolder as? ViewHolder)?.questionContainer @@ -52,8 +53,8 @@ class FaqIItem(val content: FaqItem) : KauIItem( override fun onClick( v: View, position: Int, - fastAdapter: FastAdapter>, - item: IItem<*> + fastAdapter: FastAdapter, + item: GenericItem ) { if (item !is FaqIItem) return item.isExpanded = !item.isExpanded diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt index dcc0874..8f93422 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt @@ -29,6 +29,7 @@ import ca.allanwang.kau.utils.startLink import ca.allanwang.kau.utils.visible import com.mikepenz.aboutlibraries.entity.Library import com.mikepenz.fastadapter.FastAdapter +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.select.getSelectExtension @@ -40,7 +41,7 @@ class LibraryIItem(val lib: Library) : KauIItem( ), ThemableIItem by ThemableIItemDelegate() { companion object { - fun bindEvents(fastAdapter: FastAdapter>) { + fun bindEvents(fastAdapter: FastAdapter) { fastAdapter.getSelectExtension().isSelectable = true fastAdapter.onClickListener = { v, _, item, _ -> if (item !is LibraryIItem) diff --git a/android-lib.gradle b/android-lib.gradle index 486b4ed..196cc1b 100644 --- a/android-lib.gradle +++ b/android-lib.gradle @@ -1,3 +1,6 @@ +import kau.Dependencies +import kau.Versions + apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' @@ -6,15 +9,15 @@ apply plugin: 'com.getkeepsafe.dexcount' group = "ca.allanwang" android { - compileSdkVersion kau.Versions.targetSdk - buildToolsVersion kau.Versions.buildTools + compileSdkVersion Versions.targetSdk + buildToolsVersion Versions.buildTools androidGitVersion { codeFormat = 'MMNNPPXX' format = '%tag%%.count%%-commit%' } - def kauMinSdk = kau.Versions.minSdk + def kauMinSdk = Versions.minSdk if (project.hasProperty('kauSubModuleMinSdk')) kauMinSdk = kauSubModuleMinSdk @@ -26,7 +29,7 @@ android { defaultConfig { minSdkVersion kauMinSdk - targetSdkVersion kau.Versions.targetSdk + targetSdkVersion Versions.targetSdk versionName androidGitVersion.name() versionCode androidGitVersion.code() consumerProguardFiles 'progress-proguard.txt' @@ -88,11 +91,11 @@ android { } dependencies { - testImplementation kau.Dependencies.kotlinTest - testImplementation kau.Dependencies.junit + testImplementation Dependencies.kotlinTest + testImplementation Dependencies.junit - androidTestImplementation kau.Dependencies.kotlinTest - androidTestImplementation kau.Dependencies.espresso - androidTestImplementation kau.Dependencies.testRules - androidTestImplementation kau.Dependencies.testRunner + androidTestImplementation Dependencies.kotlinTest + androidTestImplementation Dependencies.espresso + androidTestImplementation Dependencies.testRules + androidTestImplementation Dependencies.testRunner } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 81655fb..bc5fadf 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,6 @@ +import kau.ChangelogGenerator +import kau.Plugins + buildscript { repositories { google() @@ -7,13 +10,13 @@ buildscript { } dependencies { - classpath kau.Plugins.android - classpath kau.Plugins.kotlin - classpath kau.Plugins.androidMaven - classpath kau.Plugins.playPublisher - classpath kau.Plugins.dexCount - classpath kau.Plugins.gitVersion - classpath kau.Plugins.spotless + classpath Plugins.android + classpath Plugins.kotlin + classpath Plugins.androidMaven + classpath Plugins.playPublisher + classpath Plugins.dexCount + classpath Plugins.gitVersion + classpath Plugins.spotless } wrapper.setDistributionType(Wrapper.DistributionType.ALL) @@ -24,7 +27,7 @@ task clean(type: Delete) { } task generateChangelogMd { - kau.ChangelogGenerator.generate("${project.rootDir}/sample/src/main/res/xml/kau_changelog.xml", "${project.rootDir}/docs/Changelog.md") + ChangelogGenerator.generate("${project.rootDir}/sample/src/main/res/xml/kau_changelog.xml", "${project.rootDir}/docs/Changelog.md") } subprojects { diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt index 14fdc9d..59832ed 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt @@ -16,6 +16,7 @@ package ca.allanwang.kau.adapters import com.mikepenz.fastadapter.FastAdapter +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IAdapter import com.mikepenz.fastadapter.IAdapterExtension import com.mikepenz.fastadapter.IItem @@ -28,14 +29,14 @@ import com.mikepenz.fastadapter.select.SelectExtension /** * Add kotlin's generic syntax to better support out types */ -fun > fastAdapter(vararg adapter: IAdapter) = +fun fastAdapter(vararg adapter: IAdapter) = FastAdapter.with>(adapter.toList()) /** * Returns selection size, or -1 if selection is disabled */ -inline val > IAdapter.selectionSize: Int +inline val IAdapter.selectionSize: Int get() = fastAdapter?.getExtension>()?.selections?.size ?: -1 -inline val > IAdapter.selectedItems: Set +inline val IAdapter.selectedItems: Set get() = fastAdapter?.getExtension>()?.selectedItems ?: emptySet() diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt index 24a37c4..e3f43ca 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt @@ -23,6 +23,7 @@ import android.widget.TextView import androidx.annotation.RequiresApi import ca.allanwang.kau.ui.createSimpleRippleDrawable import ca.allanwang.kau.utils.adjustAlpha +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.IItemAdapter import com.mikepenz.fastadapter.adapters.FastItemAdapter @@ -36,7 +37,7 @@ import com.mikepenz.fastadapter.adapters.FastItemAdapter * This adapter overrides every method where an item is added * If that item extends [ThemableIItem], then the colors will be set */ -class FastItemThemedAdapter>( +class FastItemThemedAdapter( textColor: Int? = null, backgroundColor: Int? = null, accentColor: Int? = null @@ -85,11 +86,11 @@ class FastItemThemedAdapter>( notifyAdapterDataSetChanged() } - private fun injectTheme(items: Collection?>?) { + private fun injectTheme(items: Collection?) { items?.forEach { injectTheme(it) } } - protected fun injectTheme(item: IItem<*>?) { + protected fun injectTheme(item: GenericItem?) { if (item is ThemableIItem && item.themeEnabled) { item.textColor = textColor item.backgroundColor = backgroundColor diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt index 99c367b..3aca18b 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt @@ -19,13 +19,14 @@ import android.view.View import androidx.annotation.IntRange import com.mikepenz.fastadapter.ClickListener import com.mikepenz.fastadapter.FastAdapter +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IAdapter import com.mikepenz.fastadapter.IItem /** * Created by Allan Wang on 26/12/17. */ -fun > FastAdapter.withOnRepeatedClickListener( +fun FastAdapter.withOnRepeatedClickListener( count: Int, duration: Long, event: ClickListener @@ -39,7 +40,7 @@ fun > FastAdapter.withOnRepeatedClickListener( * each within [duration] from each other. * Only then will the [event] be fired, and everything will be reset. */ -private class RepeatedClickListener>( +private class RepeatedClickListener( @IntRange(from = 1) val count: Int, @IntRange(from = 1) val duration: Long, val event: ClickListener diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt index f9f06b9..040559c 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt @@ -34,6 +34,7 @@ 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.GenericItem import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.listeners.ClickEventHook import com.mikepenz.iconics.typeface.IIcon @@ -51,13 +52,13 @@ class CardIItem( ), ThemableIItem by ThemableIItemDelegate() { companion object { - fun bindClickEvents(fastAdapter: FastAdapter>) { - fastAdapter.addEventHook(object : ClickEventHook>() { + fun bindClickEvents(fastAdapter: FastAdapter) { + fastAdapter.addEventHook(object : ClickEventHook() { override fun onBindMany(viewHolder: RecyclerView.ViewHolder): List? { return if (viewHolder is ViewHolder) listOf(viewHolder.card, viewHolder.button) else null } - override fun onClick(v: View, position: Int, fastAdapter: FastAdapter>, item: IItem<*>) { + override fun onClick(v: View, position: Int, fastAdapter: FastAdapter, item: GenericItem) { if (item !is CardIItem) return with(item.configs) { when (v.id) { diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt index 116f511..47933eb 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt @@ -44,6 +44,7 @@ import ca.allanwang.kau.utils.dimenPixelSize import ca.allanwang.kau.utils.toast import com.bumptech.glide.Glide import com.bumptech.glide.RequestManager +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.adapters.ItemAdapter import com.mikepenz.iconics.dsl.ExperimentalIconicsDSL @@ -58,7 +59,7 @@ import java.io.File * * Container for the main logic behind the both pickers */ -abstract class MediaPickerCore>( +abstract class MediaPickerCore( val mediaType: MediaType, val mediaActions: List ) : KauBaseActivity(), LoaderManager.LoaderCallbacks { @@ -142,7 +143,7 @@ abstract class MediaPickerCore>( fun initializeRecycler(recycler: RecyclerView) { val adapterHeader = ItemAdapter() - val fulladapter = fastAdapter>(adapterHeader, adapter) + val fulladapter = fastAdapter(adapterHeader, adapter) adapterHeader.add(mediaActions.map { MediaActionItem(it, mediaType) }) recycler.apply { val manager = object : GridLayoutManager(context, computeColumnCount(context)) { diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt index db26ef5..89fa2c4 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt @@ -18,6 +18,7 @@ package ca.allanwang.kau.sample import ca.allanwang.kau.about.AboutActivityBase import ca.allanwang.kau.adapters.FastItemThemedAdapter import ca.allanwang.kau.iitems.CardIItem +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IItem /** @@ -33,7 +34,7 @@ class AboutActivity : AboutActivityBase(R.string::class.java, { faqParseNewLine = false }) { - override fun postInflateMainPage(adapter: FastItemThemedAdapter>) { + override fun postInflateMainPage(adapter: FastItemThemedAdapter) { adapter.add(CardIItem { title = "About KAU" descRes = R.string.about_kau diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt index 2fedbeb..b166210 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt @@ -20,7 +20,7 @@ import ca.allanwang.kau.adapters.fastAdapter import ca.allanwang.kau.iitems.CardIItem import ca.allanwang.kau.ui.activities.ElasticRecyclerActivity import ca.allanwang.kau.utils.toast -import com.mikepenz.fastadapter.IItem +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.adapters.ItemAdapter import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial @@ -30,7 +30,7 @@ import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial class AdapterActivity : ElasticRecyclerActivity() { override fun onCreate(savedInstanceState: Bundle?, configs: Configs): Boolean { - val adapter = ItemAdapter>() + val adapter = ItemAdapter() recycler.adapter = fastAdapter(adapter) adapter.add( listOf( -- cgit v1.2.3 From a99e5885a8e67c2609b3c23dff069189c2e62dab Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 27 Jul 2019 19:45:53 -0700 Subject: Apply spotless --- .../kotlin/ca/allanwang/kau/about/AboutActivityBase.kt | 1 - .../kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt | 1 - .../src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt | 1 - .../main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt | 1 - .../kau/ui/widgets/ElasticDragDismissFrameLayout.kt | 1 - .../main/kotlin/ca/allanwang/kau/kpref/KPrefBuilder.kt | 17 ++++++++++++++++- .../ca/allanwang/kau/kpref/KPrefSingleDelegate.kt | 2 +- .../kotlin/ca/allanwang/kau/permissions/Permissions.kt | 3 +-- .../kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt | 2 -- .../ca/allanwang/kau/adapters/FastItemThemedAdapter.kt | 2 -- .../ca/allanwang/kau/adapters/RepeatedClickListener.kt | 1 - .../main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt | 1 - .../ca/allanwang/kau/mediapicker/MediaPickerCore.kt | 1 - .../kotlin/ca/allanwang/kau/sample/AboutActivity.kt | 1 - 14 files changed, 18 insertions(+), 17 deletions(-) (limited to 'about') diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt index d346090..452d28c 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt @@ -34,7 +34,6 @@ import ca.allanwang.kau.utils.dimenPixelSize import com.mikepenz.aboutlibraries.Libs import com.mikepenz.aboutlibraries.entity.Library import com.mikepenz.fastadapter.GenericItem -import com.mikepenz.fastadapter.IItem import kotlinx.android.synthetic.main.kau_activity_about.* /** diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt index 24f1c48..ba7330c 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt @@ -35,7 +35,6 @@ import ca.allanwang.kau.utils.withMarginDecoration import ca.allanwang.kau.xml.kauParseFaq import com.mikepenz.aboutlibraries.Libs import com.mikepenz.fastadapter.GenericItem -import com.mikepenz.fastadapter.IItem import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt index 0a570f8..977b7ff 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt @@ -31,7 +31,6 @@ import ca.allanwang.kau.utils.setPaddingLeft import ca.allanwang.kau.xml.FaqItem import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.GenericItem -import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.listeners.ClickEventHook import com.mikepenz.fastadapter.select.getSelectExtension diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt index 8f93422..275945b 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt @@ -30,7 +30,6 @@ import ca.allanwang.kau.utils.visible import com.mikepenz.aboutlibraries.entity.Library import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.GenericItem -import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.select.getSelectExtension /** diff --git a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt index 2cf005a..52672fa 100644 --- a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt +++ b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt @@ -29,7 +29,6 @@ import ca.allanwang.kau.logging.KL import ca.allanwang.kau.ui.R import ca.allanwang.kau.utils.AnimHolder import ca.allanwang.kau.utils.dimen -import ca.allanwang.kau.utils.dpToPx import ca.allanwang.kau.utils.isNavBarOnBottom import ca.allanwang.kau.utils.navigationBarColor import ca.allanwang.kau.utils.scaleXY diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBuilder.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBuilder.kt index 4dd3012..8f6d0c5 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBuilder.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBuilder.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2019 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.kpref interface KPrefBuilder { @@ -72,4 +87,4 @@ object KPrefBuilderInMemory : KPrefBuilder { KPrefDelegateInMemory(key, fallback, this, postSetter) override fun KPref.kprefSingle(key: String) = KPrefSingleDelegateInMemory(key, this) -} \ No newline at end of file +} diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt index ef59e78..ae1f855 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefSingleDelegate.kt @@ -110,4 +110,4 @@ class KPrefSingleDelegateInMemory internal constructor( override fun isInitialized(): Boolean = _value != null override fun toString(): String = if (isInitialized()) value.toString() else "Lazy kPref $key not initialized yet." -} \ No newline at end of file +} diff --git a/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt b/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt index f649cc6..ee4f5ef 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018 Allan Wang + * Copyright 2019 Allan Wang * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package ca.allanwang.kau.permissions import android.Manifest diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt index 59832ed..655b355 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt @@ -18,8 +18,6 @@ package ca.allanwang.kau.adapters import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IAdapter -import com.mikepenz.fastadapter.IAdapterExtension -import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.select.SelectExtension /** diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt index e3f43ca..5531f59 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt @@ -24,8 +24,6 @@ import androidx.annotation.RequiresApi import ca.allanwang.kau.ui.createSimpleRippleDrawable import ca.allanwang.kau.utils.adjustAlpha import com.mikepenz.fastadapter.GenericItem -import com.mikepenz.fastadapter.IItem -import com.mikepenz.fastadapter.IItemAdapter import com.mikepenz.fastadapter.adapters.FastItemAdapter /** diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt index 3aca18b..1eba2e0 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt @@ -21,7 +21,6 @@ import com.mikepenz.fastadapter.ClickListener import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IAdapter -import com.mikepenz.fastadapter.IItem /** * Created by Allan Wang on 26/12/17. diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt index 040559c..1a2e6cb 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt @@ -35,7 +35,6 @@ import ca.allanwang.kau.utils.toDrawable import ca.allanwang.kau.utils.visible import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.GenericItem -import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.listeners.ClickEventHook import com.mikepenz.iconics.typeface.IIcon diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt index 47933eb..d21b33f 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt @@ -45,7 +45,6 @@ import ca.allanwang.kau.utils.toast import com.bumptech.glide.Glide import com.bumptech.glide.RequestManager import com.mikepenz.fastadapter.GenericItem -import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.adapters.ItemAdapter import com.mikepenz.iconics.dsl.ExperimentalIconicsDSL import com.mikepenz.iconics.dsl.iconicsDrawable diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt index 89fa2c4..ffe769a 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt @@ -19,7 +19,6 @@ import ca.allanwang.kau.about.AboutActivityBase import ca.allanwang.kau.adapters.FastItemThemedAdapter import ca.allanwang.kau.iitems.CardIItem import com.mikepenz.fastadapter.GenericItem -import com.mikepenz.fastadapter.IItem /** * Created by Allan Wang on 2017-06-27. -- cgit v1.2.3