Skip to content

Commit

Permalink
* add "appendComponents" api
Browse files Browse the repository at this point in the history
* update dependencies
  • Loading branch information
flopshot committed Jul 2, 2020
1 parent 2f2bfad commit 4623a43
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
Expand Down
8 changes: 8 additions & 0 deletions example/src/main/java/com/seannajera/dkouple/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,13 @@ class MainActivity : AppCompatActivity() {
Log.i(tag, "Non existent item was updated: $nonExistentItemUpdated") // "Non existent item was updated: false"

}, 5000)

Handler(Looper.getMainLooper()).postDelayed({

componentAdapter.appendComponents(
listOf(ItemComponent("2", "But I am in the components now"))
)

}, 10000)
}
}
2 changes: 1 addition & 1 deletion example/src/main/res/layout/component_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_component_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:textSize="16sp"
android:textStyle="bold"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
5 changes: 2 additions & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ group='com.github.Mariana-Tek.DKouple'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
buildToolsVersion "29.0.3"


defaultConfig {
Expand Down Expand Up @@ -44,8 +44,7 @@ dependencies {

implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation "androidx.recyclerview:recyclerview:1.1.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ class ComponentAdapter(private val componentFactory: ComponentFactory) :
return isComponentInList
}

fun appendComponents(components: List<Component>) {
val updatedComponents: List<Component> = ArrayList(currentList).also { it.addAll(components) }

submitList(updatedComponents)
}

companion object {
val componentDiffer = object : DiffUtil.ItemCallback<Component>() {
override fun areItemsTheSame(
Expand Down

0 comments on commit 4623a43

Please sign in to comment.