Skip to content

Commit

Permalink
Merge pull request #8 from netcosports/dev
Browse files Browse the repository at this point in the history
1.0.2
  • Loading branch information
Woffkaa authored Jan 21, 2022
2 parents 584af1b + 3dd0930 commit ec40c00
Show file tree
Hide file tree
Showing 206 changed files with 4,474 additions and 793 deletions.
40 changes: 34 additions & 6 deletions buildSrc/src/main/kotlin/Deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import org.gradle.api.JavaVersion
object Config {

object Build {
const val kotlinVersion = "1.6.0"
const val kotlinVersion = "1.6.10"

const val compileSdk = 31
const val minSdk = 17
const val sampleMinSdk = 21
const val targetSdk = compileSdk

val javaVersion = JavaVersion.VERSION_1_8
val javaVersion = JavaVersion.VERSION_11

const val packageNameDev = "io.github.netcosports.compositeadapter.sample"
const val packageNameProd = "io.github.netcosports.compositeadapter.sample"

const val versionName = "1.0.1"
const val versionName = "1.0.2"
const val versionOffset = 0
}

Expand All @@ -37,16 +37,23 @@ object Config {

object Deps {
object AndroidX {
const val appcompat = "androidx.appcompat:appcompat:1.4.0"
const val appcompat = "androidx.appcompat:appcompat:1.4.1"
const val swipeRefresh = "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
const val recycler = "androidx.recyclerview:recyclerview:1.2.1"
const val lifecycleVersion = "2.4.0"
const val core = "androidx.core:core-ktx:1.7.0"
private const val lifecycleVersion = "2.4.0"
const val lifecycle = "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion"
const val lifecycleViewModelKtx = "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
const val lifecycleLiveDataKtx = "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion"
}

object Material {
const val material = "com.google.android.material:material:1.5.0"
}

object Coroutines {
const val version = "1.5.2"
private const val version = "1.6.0"
const val core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"
const val android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version"
}

Expand All @@ -56,12 +63,33 @@ object Config {
}
}

object Koin {
private const val version = "3.1.5"
const val core = "io.insert-koin:koin-core:$version"
const val android = "io.insert-koin:koin-android:$version"
}

object Kotlin {
const val kotlinJdk8 = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Build.kotlinVersion}"
}

object Libs {
const val compositeAdapter = ":composite-adapter"

const val decorations = ":samples:decorations"
const val differentBindings = ":samples:different-bindings"
const val innerRecyclerview = ":samples:inner-recyclerview"

const val stateAsCells = ":samples:state-as-cells:app"
const val baseCore = ":samples:state-as-cells:features:base:core"
const val baseUI = ":samples:state-as-cells:features:base:ui"
const val homeData = ":samples:state-as-cells:features:home:data"
const val homeCore = ":samples:state-as-cells:features:home:core"
const val homeUI = ":samples:state-as-cells:features:home:ui"
const val storiesCore = ":samples:state-as-cells:features:stories:core"
const val storiesUI = ":samples:state-as-cells:features:stories:ui"
const val newsCore = ":samples:state-as-cells:features:news:core"
const val newsUI = ":samples:state-as-cells:features:news:ui"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,21 @@ abstract class BaseCompositeAdapter<DATA : Cell<*>>(
}

protected open fun storeCellInHolder(holder: RecyclerView.ViewHolder, position: Int) {
holder.itemView.setCompositeAdapterItem(getItem(position))
holder.setCompositeAdapterItem(getItem(position))
}

override fun onViewAttachedToWindow(holder: RecyclerView.ViewHolder) {
super.onViewAttachedToWindow(holder)
holder.itemView.getCompositeAdapterItem<DATA>().onViewAttachedToWindow(holder)
holder.getCompositeAdapterItem<DATA>().onViewAttachedToWindow(holder)
}

override fun onViewDetachedFromWindow(holder: RecyclerView.ViewHolder) {
super.onViewDetachedFromWindow(holder)
holder.itemView.getCompositeAdapterItem<DATA>().onViewDetachedFromWindow(holder)
holder.getCompositeAdapterItem<DATA>().onViewDetachedFromWindow(holder)
}

override fun onViewRecycled(holder: RecyclerView.ViewHolder) {
super.onViewRecycled(holder)
holder.itemView.getCompositeAdapterItem<DATA>().onViewRecycled(holder)
holder.getCompositeAdapterItem<DATA>().onViewRecycled(holder)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import android.view.View
import androidx.recyclerview.widget.RecyclerView

open class SpaceItemDecoration<ITEM>(
val top: Int = 0,
val bottom: Int = 0,
val start: Int = 0,
val end: Int = 0
open val top: Int = 0,
open val bottom: Int = 0,
open val start: Int = 0,
open val end: Int = 0
) : ItemDecoration<ITEM> {

override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State, item: ITEM) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.content.Context
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.originsdigital.compositeadapter.R
import com.originsdigital.compositeadapter.cell.Cell

val RecyclerView.ViewHolder.context: Context get() = itemView.context

Expand All @@ -17,6 +18,22 @@ var View.compositeAdapterViewHolder: RecyclerView.ViewHolder
setTag(R.id.composite_adapter_view_holder_tag, value)
}

fun <CELL : Cell<*>> CELL.getCompositeAdapterItem(viewHolder: RecyclerView.ViewHolder): CELL {
return viewHolder.itemView.getCompositeAdapterItem()
}

fun <CELL : Cell<*>> CELL.getCompositeAdapterItem(root: View): CELL {
return root.getCompositeAdapterItem()
}

fun <ITEM> RecyclerView.ViewHolder.getCompositeAdapterItem(): ITEM {
return itemView.getCompositeAdapterItem()
}

fun <ITEM> RecyclerView.ViewHolder.setCompositeAdapterItem(item: ITEM) {
return itemView.setCompositeAdapterItem(item)
}

fun <ITEM> View.getCompositeAdapterItem(): ITEM {
@Suppress("UNCHECKED_CAST")
return getTag(R.id.composite_adapter_item_tag) as ITEM
Expand All @@ -26,19 +43,28 @@ fun <ITEM> View.setCompositeAdapterItem(item: ITEM) {
setTag(R.id.composite_adapter_item_tag, item)
}

@Deprecated(
level = DeprecationLevel.ERROR,
message = "Get 'ViewBinding' from the 'ViewHolder'"
)
inline fun <reified VIEW_BINDING> RecyclerView.ViewHolder.getViewBinding(
crossinline delegate: (View) -> VIEW_BINDING
): VIEW_BINDING {
val binding = itemView.getTag(R.id.composite_adapter_viewbinding_tag)
return if (binding == null) {
delegate(itemView).also {
@Suppress("DEPRECATION_ERROR")
setViewBinding(it)
}
} else {
binding as VIEW_BINDING
}
}

@Deprecated(
level = DeprecationLevel.ERROR,
message = "Save 'ViewBinding' in the 'ViewHolder'"
)
fun <VIEW_BINDING> RecyclerView.ViewHolder.setViewBinding(binding: VIEW_BINDING) {
itemView.setTag(R.id.composite_adapter_viewbinding_tag, binding)
}
23 changes: 0 additions & 23 deletions sample/src/main/AndroidManifest.xml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit ec40c00

Please sign in to comment.