From 01da1e056193f202d2cf66618fe12e8905e8c27a Mon Sep 17 00:00:00 2001 From: William Kranich Date: Wed, 13 Dec 2017 11:35:31 -0500 Subject: [PATCH 1/4] Update Paging Library to alpha 4. Update sample to reflect new version and breaking changes. (#358) --- blessedDeps.gradle | 2 +- epoxy-pagingsample/build.gradle | 4 +- .../epoxy/pagingsample/DataBaseSetup.kt | 15 ++++-- .../pagingsample/PagingSampleActivity.kt | 50 ++++++++++--------- 4 files changed, 42 insertions(+), 29 deletions(-) diff --git a/blessedDeps.gradle b/blessedDeps.gradle index d4585509c1..303c5ceedb 100644 --- a/blessedDeps.gradle +++ b/blessedDeps.gradle @@ -18,7 +18,7 @@ rootProject.ext.MIN_SDK_VERSION_LITHO = 15 rootProject.ext.ANDROID_BUILD_TOOLS_VERSION = "26.0.2" rootProject.ext.ANDROID_SUPPORT_LIBS_VERSION = "26.1.0" rootProject.ext.ANDROID_DATA_BINDING = "1.3.1" -rootProject.ext.ANDROID_PAGING = "1.0.0-alpha2" +rootProject.ext.ANDROID_PAGING = "1.0.0-alpha4" rootProject.ext.BUTTERKNIFE_VERSION = "8.8.1" rootProject.ext.SQUARE_JAVAPOET_VERSION = "1.9.0" rootProject.ext.SQUARE_KOTLINPOET_VERSION = "0.5.0" diff --git a/epoxy-pagingsample/build.gradle b/epoxy-pagingsample/build.gradle index edeed0d2f3..5bb5713d17 100644 --- a/epoxy-pagingsample/build.gradle +++ b/epoxy-pagingsample/build.gradle @@ -24,8 +24,8 @@ dependencies { compile rootProject.deps.kotlin compile "org.jetbrains.anko:anko-coroutines:0.10.1" - compile 'android.arch.persistence.room:runtime:1.0.0-beta1' - kapt 'android.arch.persistence.room:compiler:1.0.0-beta1' + compile 'android.arch.persistence.room:runtime:1.0.0' + kapt 'android.arch.persistence.room:compiler:1.0.0' compile project(':epoxy-adapter') compile project(':epoxy-paging') diff --git a/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/DataBaseSetup.kt b/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/DataBaseSetup.kt index 1ecdf68033..2c1a54b1c6 100644 --- a/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/DataBaseSetup.kt +++ b/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/DataBaseSetup.kt @@ -1,7 +1,16 @@ package com.airbnb.epoxy.pagingsample -import android.arch.paging.* -import android.arch.persistence.room.* +import android.arch.paging.DataSource +import android.arch.persistence.room.ColumnInfo +import android.arch.persistence.room.Dao +import android.arch.persistence.room.Database +import android.arch.persistence.room.Delete +import android.arch.persistence.room.Entity +import android.arch.persistence.room.Insert +import android.arch.persistence.room.OnConflictStrategy +import android.arch.persistence.room.PrimaryKey +import android.arch.persistence.room.Query +import android.arch.persistence.room.RoomDatabase @Database(entities = arrayOf(User::class), version = 1) abstract class PagingDatabase : RoomDatabase() { @@ -23,7 +32,7 @@ data class User( @Dao interface UserDao { @get:Query("SELECT * FROM user") - val dataSource: TiledDataSource + val dataSource: DataSource.Factory @get:Query("SELECT * FROM user") val all: List diff --git a/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/PagingSampleActivity.kt b/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/PagingSampleActivity.kt index 527b67e924..ade73cb119 100644 --- a/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/PagingSampleActivity.kt +++ b/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/PagingSampleActivity.kt @@ -1,18 +1,23 @@ package com.airbnb.epoxy.pagingsample -import android.arch.paging.* -import android.content.* -import android.os.* -import android.support.v7.app.* -import android.support.v7.widget.* -import android.widget.* -import com.airbnb.epoxy.* -import com.airbnb.epoxy.paging.* -import android.arch.persistence.room.*; -import kotlinx.coroutines.experimental.* -import kotlinx.coroutines.experimental.android.* -import org.jetbrains.anko.coroutines.experimental.* -import java.util.concurrent.* +import android.arch.paging.PagedList +import android.arch.persistence.room.Room +import android.content.Context +import android.os.AsyncTask +import android.os.Bundle +import android.os.Handler +import android.os.Looper +import android.support.v7.app.AppCompatActivity +import android.support.v7.widget.LinearLayoutManager +import android.support.v7.widget.RecyclerView +import android.widget.TextView +import com.airbnb.epoxy.ModelView +import com.airbnb.epoxy.TextProp +import com.airbnb.epoxy.paging.PagingEpoxyController +import kotlinx.coroutines.experimental.android.UI +import kotlinx.coroutines.experimental.async +import org.jetbrains.anko.coroutines.experimental.bg +import java.util.concurrent.Executor class PagingSampleActivity : AppCompatActivity() { @@ -37,22 +42,21 @@ class PagingSampleActivity : AppCompatActivity() { db.userDao().insertAll(User(i)) } - return@bg PagedList.Builder().run { - setDataSource(db.userDao().dataSource) + return@bg PagedList.Builder( + db.userDao().dataSource.create(), + PagedList.Config.Builder().run { + setEnablePlaceholders(false) + setPageSize(40) + setInitialLoadSizeHint(80) + setPrefetchDistance(50) + build() + }).run { setMainThreadExecutor(UiThreadExecutor) setBackgroundThreadExecutor(AsyncTask.THREAD_POOL_EXECUTOR) - setConfig(PagedList.Config.Builder().run { - setEnablePlaceholders(false) - setPageSize(40) - setInitialLoadSizeHint(80) - setPrefetchDistance(50) - build() - }) build() } } - pagingController.setList(pagedList.await()) } From ed62e31b92e586ec6b97df24b88ec60fed96c8a2 Mon Sep 17 00:00:00 2001 From: William Kranich Date: Wed, 13 Dec 2017 15:09:29 -0500 Subject: [PATCH 2/4] Reverse studio auto-import --- .../epoxy/pagingsample/DataBaseSetup.kt | 13 ++------ .../pagingsample/PagingSampleActivity.kt | 31 ++++++++----------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/DataBaseSetup.kt b/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/DataBaseSetup.kt index 2c1a54b1c6..4779f2a18d 100644 --- a/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/DataBaseSetup.kt +++ b/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/DataBaseSetup.kt @@ -1,16 +1,7 @@ package com.airbnb.epoxy.pagingsample -import android.arch.paging.DataSource -import android.arch.persistence.room.ColumnInfo -import android.arch.persistence.room.Dao -import android.arch.persistence.room.Database -import android.arch.persistence.room.Delete -import android.arch.persistence.room.Entity -import android.arch.persistence.room.Insert -import android.arch.persistence.room.OnConflictStrategy -import android.arch.persistence.room.PrimaryKey -import android.arch.persistence.room.Query -import android.arch.persistence.room.RoomDatabase +import android.arch.paging.* +import android.arch.persistence.room.* @Database(entities = arrayOf(User::class), version = 1) abstract class PagingDatabase : RoomDatabase() { diff --git a/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/PagingSampleActivity.kt b/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/PagingSampleActivity.kt index ade73cb119..f8c91b6461 100644 --- a/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/PagingSampleActivity.kt +++ b/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/PagingSampleActivity.kt @@ -1,23 +1,18 @@ package com.airbnb.epoxy.pagingsample -import android.arch.paging.PagedList -import android.arch.persistence.room.Room -import android.content.Context -import android.os.AsyncTask -import android.os.Bundle -import android.os.Handler -import android.os.Looper -import android.support.v7.app.AppCompatActivity -import android.support.v7.widget.LinearLayoutManager -import android.support.v7.widget.RecyclerView -import android.widget.TextView -import com.airbnb.epoxy.ModelView -import com.airbnb.epoxy.TextProp -import com.airbnb.epoxy.paging.PagingEpoxyController -import kotlinx.coroutines.experimental.android.UI -import kotlinx.coroutines.experimental.async -import org.jetbrains.anko.coroutines.experimental.bg -import java.util.concurrent.Executor +import android.arch.paging.* +import android.content.* +import android.os.* +import android.support.v7.app.* +import android.support.v7.widget.* +import android.widget.* +import com.airbnb.epoxy.* +import com.airbnb.epoxy.paging.* +import android.arch.persistence.room.*; +import kotlinx.coroutines.experimental.* +import kotlinx.coroutines.experimental.android.* +import org.jetbrains.anko.coroutines.experimental.* +import java.util.concurrent.* class PagingSampleActivity : AppCompatActivity() { From e89429c426709d4215d4e0302512a2e782633d9b Mon Sep 17 00:00:00 2001 From: William Kranich Date: Thu, 14 Dec 2017 13:47:48 -0500 Subject: [PATCH 3/4] Enable placeholders and check null --- .../epoxy/pagingsample/PagingSampleActivity.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/PagingSampleActivity.kt b/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/PagingSampleActivity.kt index f8c91b6461..ce9b52b8d1 100644 --- a/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/PagingSampleActivity.kt +++ b/epoxy-pagingsample/src/main/java/com/airbnb/epoxy/pagingsample/PagingSampleActivity.kt @@ -40,7 +40,7 @@ class PagingSampleActivity : AppCompatActivity() { return@bg PagedList.Builder( db.userDao().dataSource.create(), PagedList.Config.Builder().run { - setEnablePlaceholders(false) + setEnablePlaceholders(true) setPageSize(40) setInitialLoadSizeHint(80) setPrefetchDistance(50) @@ -63,13 +63,15 @@ class TestController : PagingEpoxyController() { setDebugLoggingEnabled(true) } - override fun buildModels(users: List) { + override fun buildModels(users: List) { println("build ${users.size}") users.forEach { - pagingView { - id(it.uid) - name("Id: ${it.uid}") + if (it != null) { + pagingView { + id(it.uid) + name("Id: ${it.uid}") + } } } } From b2bc119d099f6686e4fd975bc48593e2ea5f3f80 Mon Sep 17 00:00:00 2001 From: William Kranich Date: Thu, 25 Jan 2018 10:29:34 -0500 Subject: [PATCH 4/4] Update paging library version to alpha5 --- blessedDeps.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blessedDeps.gradle b/blessedDeps.gradle index 303c5ceedb..32c79ececd 100644 --- a/blessedDeps.gradle +++ b/blessedDeps.gradle @@ -18,7 +18,7 @@ rootProject.ext.MIN_SDK_VERSION_LITHO = 15 rootProject.ext.ANDROID_BUILD_TOOLS_VERSION = "26.0.2" rootProject.ext.ANDROID_SUPPORT_LIBS_VERSION = "26.1.0" rootProject.ext.ANDROID_DATA_BINDING = "1.3.1" -rootProject.ext.ANDROID_PAGING = "1.0.0-alpha4" +rootProject.ext.ANDROID_PAGING = "1.0.0-alpha5" rootProject.ext.BUTTERKNIFE_VERSION = "8.8.1" rootProject.ext.SQUARE_JAVAPOET_VERSION = "1.9.0" rootProject.ext.SQUARE_KOTLINPOET_VERSION = "0.5.0"