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 --- .../kotlin/ca/allanwang/kau/about/AboutActivityBase.kt | 2 +- .../kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt | 8 ++++---- about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt | 6 +++--- .../src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt | 2 +- adapter/build.gradle | 2 +- .../main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt | 14 +++++++------- .../ca/allanwang/kau/adapters/FastItemThemedAdapter.kt | 8 ++++---- .../ca/allanwang/kau/adapters/RepeatedClickListener.kt | 4 ++-- .../src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt | 6 +++--- .../src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt | 2 +- buildSrc/src/main/kotlin/kau/Dependencies.kt | 4 +--- buildSrc/src/main/kotlin/kau/Versions.kt | 2 +- .../ca/allanwang/kau/kpref/activity/KPrefActivity.kt | 2 +- .../kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt | 4 ++-- .../main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt | 2 +- .../main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt | 2 +- .../main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt | 2 +- .../main/kotlin/ca/allanwang/kau/searchview/SearchView.kt | 2 +- 18 files changed, 36 insertions(+), 38 deletions(-) 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) diff --git a/adapter/build.gradle b/adapter/build.gradle index de42b6c..4f38eae 100644 --- a/adapter/build.gradle +++ b/adapter/build.gradle @@ -6,7 +6,7 @@ dependencies { implementation project(':core') api kau.Dependencies.fastAdapter - api kau.Dependencies.fastAdapterCommons + api kau.Dependencies.fastAdapter('utils') } apply from: '../artifacts.gradle' diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt index 17fd09f..42fe1a2 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt @@ -28,17 +28,17 @@ import com.mikepenz.fastadapter.select.SelectExtension /** * Add kotlin's generic syntax to better support out types */ -fun > fastAdapter(vararg adapter: IAdapter) = - FastAdapter.with>(adapter.toList())!! +fun > fastAdapter(vararg adapter: IAdapter) = + FastAdapter.with>(adapter.toList()) -inline fun , Item : IItem<*, *>> FastAdapter.getExtension(): T? = +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 +inline val > IAdapter.selectionSize: Int + get() = fastAdapter?.getExtension, Item>()?.selections?.size ?: -1 -inline val > IAdapter.selectedItems: Set - get() = fastAdapter.getExtension, Item>()?.selectedItems ?: emptySet() +inline val > IAdapter.selectedItems: Set + get() = fastAdapter?.getExtension, Item>()?.selectedItems ?: emptySet() diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt index 152982f..01ac0e5 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt @@ -24,7 +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.commons.adapters.FastItemAdapter +import com.mikepenz.fastadapter.adapters.FastItemAdapter /** * Created by Allan Wang on 2017-06-29. @@ -35,7 +35,7 @@ import com.mikepenz.fastadapter.commons.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 @@ -113,11 +113,11 @@ class FastItemThemedAdapter>( return super.setNewList(items) } - private fun injectTheme(items: Collection?>?) { + private fun injectTheme(items: Collection?>?) { items?.forEach { injectTheme(it) } } - protected fun injectTheme(item: IItem<*, *>?) { + protected fun injectTheme(item: IItem<*>?) { if (item is ThemableIItem && item.themeEnabled) { item.textColor = textColor item.backgroundColor = backgroundColor diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt index 40b4774..3e7d707 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt @@ -25,7 +25,7 @@ import com.mikepenz.fastadapter.listeners.OnClickListener /** * Created by Allan Wang on 26/12/17. */ -fun > FastAdapter.withOnRepeatedClickListener( +fun > FastAdapter.withOnRepeatedClickListener( count: Int, duration: Long, event: OnClickListener @@ -37,7 +37,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: OnClickListener diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt index 6e33833..47c465c 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt @@ -51,13 +51,13 @@ class CardIItem( ), ThemableIItem by ThemableIItemDelegate() { companion object { - fun bindClickEvents(fastAdapter: FastAdapter>) { - fastAdapter.withEventHook(object : ClickEventHook>() { + fun bindClickEvents(fastAdapter: FastAdapter>) { + fastAdapter.withEventHook(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, adapter: FastAdapter>, item: IItem<*>) { if (item !is CardIItem) return with(item.configs) { when (v.id) { diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt index c66dc01..853d388 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt @@ -33,7 +33,7 @@ open class KauIItem( @param:LayoutRes private val layoutRes: Int, private val viewHolder: (v: View) -> VH, private val type: Int = layoutRes -) : AbstractItem() where Item : IItem<*, *>, Item : IClickable<*> { +) : AbstractItem() where Item : IItem<*>, Item : IClickable<*> { @SuppressLint("ResourceType") final override fun getType(): Int = type diff --git a/buildSrc/src/main/kotlin/kau/Dependencies.kt b/buildSrc/src/main/kotlin/kau/Dependencies.kt index c704500..6634851 100644 --- a/buildSrc/src/main/kotlin/kau/Dependencies.kt +++ b/buildSrc/src/main/kotlin/kau/Dependencies.kt @@ -43,9 +43,7 @@ object Dependencies { const val fastAdapter = "com.mikepenz:fastadapter:${Versions.fastAdapter}" @JvmStatic - fun fastAdapter(type: String) = "com.mikepenz:fastadapter-$type:${Versions.fastAdapter}" - @JvmField - val fastAdapterCommons = fastAdapter("commons") + fun fastAdapter(type: String) = "com.mikepenz:fastadapter-extensions-$type:${Versions.fastAdapter}" const val bugsnag = "com.bugsnag:bugsnag-android:${Versions.bugsnag}" diff --git a/buildSrc/src/main/kotlin/kau/Versions.kt b/buildSrc/src/main/kotlin/kau/Versions.kt index a9c6674..d3718b6 100644 --- a/buildSrc/src/main/kotlin/kau/Versions.kt +++ b/buildSrc/src/main/kotlin/kau/Versions.kt @@ -36,7 +36,7 @@ object Versions { const val blurry = "3.0.0" // https://github.com/mikepenz/FastAdapter#using-maven - const val fastAdapter = "3.3.1" + const val fastAdapter = "4.0.0" // https://github.com/bumptech/glide/releases const val glide = "4.9.0" 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 edaf347..b701a07 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 @@ -31,7 +31,7 @@ import ca.allanwang.kau.utils.KAU_RIGHT import ca.allanwang.kau.utils.resolveColor import ca.allanwang.kau.utils.statusBarColor import ca.allanwang.kau.utils.withLinearAdapter -import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter +import com.mikepenz.fastadapter.adapters.FastItemAdapter import kotlinx.android.synthetic.main.kau_pref_activity.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch 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 ae1d9d6..bf681eb 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt @@ -64,7 +64,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 { @@ -141,7 +141,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 928070e..db26ef5 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt @@ -33,7 +33,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 a851c1d..2fedbeb 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt @@ -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( 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 349e3d1..aaa6143 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt @@ -30,7 +30,7 @@ import ca.allanwang.kau.utils.startActivity import ca.allanwang.kau.utils.toast import ca.allanwang.kau.utils.withAlpha import ca.allanwang.kau.utils.withSlideOut -import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter +import com.mikepenz.fastadapter.adapters.FastItemAdapter /** * Created by Allan Wang on 2017-06-12. 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 709dbad..39e0d28 100644 --- a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt +++ b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt @@ -62,7 +62,7 @@ import ca.allanwang.kau.utils.tint import ca.allanwang.kau.utils.toDrawable import ca.allanwang.kau.utils.visible import ca.allanwang.kau.utils.withLinearAdapter -import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter +import com.mikepenz.fastadapter.adapters.FastItemAdapter import com.mikepenz.iconics.typeface.IIcon import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial import kotlinx.android.synthetic.main.kau_search_view.view.* -- cgit v1.2.3