aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt3
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt9
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt9
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt3
-rw-r--r--android-lib.gradle23
-rw-r--r--build.gradle19
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt7
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt7
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt5
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt7
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt5
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt3
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt4
13 files changed, 60 insertions, 44 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 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<IItem<*>>) {
+ open fun postInflateMainPage(adapter: FastItemThemedAdapter<GenericItem>) {
}
/**
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<IItem<*>>
+ var items: List<GenericItem>
/**
* The adapter, will be late initialized as it depends on configs
*/
- var adapter: FastItemThemedAdapter<IItem<*>>
+ var adapter: FastItemThemedAdapter<GenericItem>
/**
* 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<IItem<*>> = emptyList()
+ override var items: List<GenericItem> = emptyList()
- override lateinit var adapter: FastItemThemedAdapter<IItem<*>>
+ override lateinit var adapter: FastItemThemedAdapter<GenericItem>
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<FaqIItem.ViewHolder>(
), ThemableIItem by ThemableIItemDelegate() {
companion object {
- fun bindEvents(fastAdapter: FastAdapter<IItem<*>>) {
+ fun bindEvents(fastAdapter: FastAdapter<GenericItem>) {
fastAdapter.getSelectExtension().isSelectable = true
- fastAdapter.addEventHook(object : ClickEventHook<IItem<*>>() {
+ fastAdapter.addEventHook(object : ClickEventHook<GenericItem>() {
override fun onBind(viewHolder: RecyclerView.ViewHolder): View? =
(viewHolder as? ViewHolder)?.questionContainer
@@ -52,8 +53,8 @@ class FaqIItem(val content: FaqItem) : KauIItem<FaqIItem.ViewHolder>(
override fun onClick(
v: View,
position: Int,
- fastAdapter: FastAdapter<IItem<*>>,
- item: IItem<*>
+ fastAdapter: FastAdapter<GenericItem>,
+ 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<LibraryIItem.ViewHolder>(
), ThemableIItem by ThemableIItemDelegate() {
companion object {
- fun bindEvents(fastAdapter: FastAdapter<IItem<*>>) {
+ fun bindEvents(fastAdapter: FastAdapter<GenericItem>) {
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 <Item : IItem<*>> fastAdapter(vararg adapter: IAdapter<out Item>) =
+fun <Item : GenericItem> fastAdapter(vararg adapter: IAdapter<out Item>) =
FastAdapter.with<Item, IAdapter<out Item>>(adapter.toList())
/**
* Returns selection size, or -1 if selection is disabled
*/
-inline val <Item : IItem<*>> IAdapter<Item>.selectionSize: Int
+inline val <Item : GenericItem> IAdapter<Item>.selectionSize: Int
get() = fastAdapter?.getExtension<SelectExtension<Item>>()?.selections?.size ?: -1
-inline val <Item : IItem<*>> IAdapter<Item>.selectedItems: Set<Item>
+inline val <Item : GenericItem> IAdapter<Item>.selectedItems: Set<Item>
get() = fastAdapter?.getExtension<SelectExtension<Item>>()?.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<Item : IItem<*>>(
+class FastItemThemedAdapter<Item : GenericItem>(
textColor: Int? = null,
backgroundColor: Int? = null,
accentColor: Int? = null
@@ -85,11 +86,11 @@ class FastItemThemedAdapter<Item : IItem<*>>(
notifyAdapterDataSetChanged()
}
- private fun injectTheme(items: Collection<IItem<*>?>?) {
+ private fun injectTheme(items: Collection<GenericItem?>?) {
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 <Item : IItem<*>> FastAdapter<Item>.withOnRepeatedClickListener(
+fun <Item : GenericItem> FastAdapter<Item>.withOnRepeatedClickListener(
count: Int,
duration: Long,
event: ClickListener<Item>
@@ -39,7 +40,7 @@ fun <Item : IItem<*>> FastAdapter<Item>.withOnRepeatedClickListener(
* each within [duration] from each other.
* Only then will the [event] be fired, and everything will be reset.
*/
-private class RepeatedClickListener<Item : IItem<*>>(
+private class RepeatedClickListener<Item : GenericItem>(
@IntRange(from = 1) val count: Int,
@IntRange(from = 1) val duration: Long,
val event: ClickListener<Item>
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<IItem<*>>) {
- fastAdapter.addEventHook(object : ClickEventHook<IItem<*>>() {
+ fun bindClickEvents(fastAdapter: FastAdapter<GenericItem>) {
+ fastAdapter.addEventHook(object : ClickEventHook<GenericItem>() {
override fun onBindMany(viewHolder: RecyclerView.ViewHolder): List<View>? {
return if (viewHolder is ViewHolder) listOf(viewHolder.card, viewHolder.button) else null
}
- override fun onClick(v: View, position: Int, fastAdapter: FastAdapter<IItem<*>>, item: IItem<*>) {
+ override fun onClick(v: View, position: Int, fastAdapter: FastAdapter<GenericItem>, 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<T : IItem<*>>(
+abstract class MediaPickerCore<T : GenericItem>(
val mediaType: MediaType,
val mediaActions: List<MediaAction>
) : KauBaseActivity(), LoaderManager.LoaderCallbacks<Cursor> {
@@ -142,7 +143,7 @@ abstract class MediaPickerCore<T : IItem<*>>(
fun initializeRecycler(recycler: RecyclerView) {
val adapterHeader = ItemAdapter<MediaActionItem>()
- val fulladapter = fastAdapter<IItem<*>>(adapterHeader, adapter)
+ val fulladapter = fastAdapter<GenericItem>(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<IItem<*>>) {
+ override fun postInflateMainPage(adapter: FastItemThemedAdapter<GenericItem>) {
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<IItem<*>>()
+ val adapter = ItemAdapter<GenericItem>()
recycler.adapter = fastAdapter(adapter)
adapter.add(
listOf(