Skip to content

Commit

Permalink
Beta 5 fixes and release (#1016)
Browse files Browse the repository at this point in the history
* Fix timings crash and bump versions

* Change databinding annotations to type target

* beta 5 update and changelog
  • Loading branch information
elihart authored Jul 10, 2020
1 parent 435c2fb commit 141894c
Show file tree
Hide file tree
Showing 51 changed files with 394 additions and 280 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# 4.0.0-beta5 (July 9, 2020)
Fixes:
- An occasional processor crash when the option to log timings is enabled
- Incremental annotation processing of databinding models would fail to generate models (#1014)

Breaking!
- The annotation that support databinding, `EpoxyDataBindingLayouts` and `EpoxyDataBindingPattern`,
must now be placed on a class or interface instead of in a `package-info.java` file. The interface
or class must be in Java, Kotlin is not supported. This is necessary to support incremental processing.

Example usage:
```java
package com.example.app;

import com.airbnb.epoxy.EpoxyDataBindingLayouts;
import com.airbnb.epoxy.EpoxyDataBindingPattern;

@EpoxyDataBindingPattern(rClass = R.class, layoutPrefix = "my_view_prefix")
@EpoxyDataBindingLayouts({R.layout.my_model_layout})
interface EpoxyDataBindingConfig {}
```

# 4.0.0-beta4 (June 1, 2020)
Fixes:
- Synchronize ListUpdateCallback and PagedListModelCache functions (#987)
Expand Down
4 changes: 2 additions & 2 deletions blessedDeps.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ rootProject.ext.ROBOLECTRIC_VERSION = "4.3"
rootProject.ext.LOTTIE_VERSION = "2.8.0"
rootProject.ext.SO_LOADER_VERSION = "0.2.0"

rootProject.ext.AUTO_VALUE_VERSION = "1.6.2"
rootProject.ext.AUTO_VALUE_VERSION = "1.7.4"
rootProject.ext.ANDROID_RUNTIME_VERSION = "4.1.1.4"

rootProject.ext.PARIS_VERSION = "1.2.1"
rootProject.ext.PARIS_VERSION = "1.5.0"

rootProject.ext.INCAP_VERSION = "0.2"
rootProject.ext.KOTLIN_METADATA_VERSION = "1.4.0"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildscript {
}

plugins {
id 'com.github.ben-manes.versions' version '0.20.0'
id 'com.github.ben-manes.versions' version '0.28.0'
}

allprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ class WrappedEpoxyModelClickListener<T : EpoxyModel<*>, V> : OnClickListener, On
}

if (if (originalClickListener != null) {
originalClickListener != other.originalClickListener
} else {
originalClickListener != other.originalClickListener
} else {
other.originalClickListener != null
}
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ class StickyHeaderLinearLayoutManager @JvmOverloads constructor(
// - Isn't followed by another sticky header;
if (headerPos != -1 &&
(headerPos != anchorPos || isViewOnBoundary(anchorView)) &&
nextHeaderPos != headerPos + 1) {
nextHeaderPos != headerPos + 1
) {
// 1. Ensure existing sticky header, if any, is of correct type.
if (stickyHeader != null && getItemViewType(stickyHeader!!) != adapter?.getItemViewType(headerPos)) {
// A sticky header was shown before but is not of the correct type. Scrap it.
Expand Down
48 changes: 29 additions & 19 deletions epoxy-adapter/src/test/java/com/airbnb/epoxy/EpoxyModelGroupTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,35 @@ class EpoxyModelGroupTest(val useViewStubs: Boolean) {
public override fun buildView(parent: ViewGroup): View {
return LinearLayout(parent.context).apply {

addView(ViewStub(parent.context).apply {
inflatedId = 0
})

addView(LinearLayout(parent.context).apply {
addView(ViewStub(parent.context).apply {
inflatedId = 1
})

addView(Space(parent.context))

addView(ViewStub(parent.context).apply {
inflatedId = 2
})
})

addView(ViewStub(parent.context).apply {
inflatedId = 3
})
addView(
ViewStub(parent.context).apply {
inflatedId = 0
}
)

addView(
LinearLayout(parent.context).apply {
addView(
ViewStub(parent.context).apply {
inflatedId = 1
}
)

addView(Space(parent.context))

addView(
ViewStub(parent.context).apply {
inflatedId = 2
}
)
}
)

addView(
ViewStub(parent.context).apply {
inflatedId = 3
}
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,13 @@ class EpoxyVisibilityTrackerNestedTest {
// Build a test sample of sampleSize items
val helpers = mutableListOf<List<AssertHelper>>().apply {
for (i in 0 until verticalSampleSize) {
add(mutableListOf<AssertHelper>().apply {
for (j in 0 until horizontalSampleSize) {
add(AssertHelper(ids++))
add(
mutableListOf<AssertHelper>().apply {
for (j in 0 until horizontalSampleSize) {
add(AssertHelper(ids++))
}
}
})
)
}
}
log(helpers.ids())
Expand All @@ -226,35 +228,37 @@ class EpoxyVisibilityTrackerNestedTest {
@Before
fun setup() {
Robolectric.setupActivity(Activity::class.java).apply {
setContentView(EpoxyRecyclerView(this).apply {
epoxyVisibilityTracker.attach(this)
recyclerView = this
// Plug an epoxy controller
epoxyController = object : TypedEpoxyController<List<List<AssertHelper>>>() {
override fun buildModels(data: List<List<AssertHelper>>?) {
data?.forEachIndexed { index, helpers ->
val models = mutableListOf<EpoxyModel<*>>()
helpers.forEach { helper ->
models.add(
TrackerTestModel(
itemPosition = index,
itemHeight = itemHeight,
itemWidth = itemWidth,
helper = helper
).id("$index-${helper.id}")
setContentView(
EpoxyRecyclerView(this).apply {
epoxyVisibilityTracker.attach(this)
recyclerView = this
// Plug an epoxy controller
epoxyController = object : TypedEpoxyController<List<List<AssertHelper>>>() {
override fun buildModels(data: List<List<AssertHelper>>?) {
data?.forEachIndexed { index, helpers ->
val models = mutableListOf<EpoxyModel<*>>()
helpers.forEach { helper ->
models.add(
TrackerTestModel(
itemPosition = index,
itemHeight = itemHeight,
itemWidth = itemWidth,
helper = helper
).id("$index-${helper.id}")
)
}
add(
CarouselModel_()
.id(index)
.paddingDp(0)
.models(models)
)
}
add(
CarouselModel_()
.id(index)
.paddingDp(0)
.models(models)
)
}
}
recyclerView.adapter = epoxyController.adapter
}
recyclerView.adapter = epoxyController.adapter
})
)
viewportHeight = recyclerView.measuredHeight
activity = this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,26 +881,28 @@ class EpoxyVisibilityTrackerTest {
@Before
fun setup() {
Robolectric.setupActivity(Activity::class.java).apply {
setContentView(EpoxyRecyclerView(this).apply {
epoxyVisibilityTracker.setPartialImpressionThresholdPercentage(50)
epoxyVisibilityTracker.attach(this)
recyclerView = this
// Plug an epoxy controller
epoxyController = object : TypedEpoxyController<List<AssertHelper>>() {
override fun buildModels(data: List<AssertHelper>?) {
data?.forEachIndexed { index, helper ->
add(
TrackerTestModel(
itemPosition = index,
itemHeight = itemHeight,
helper = helper
).id(helper.id)
)
setContentView(
EpoxyRecyclerView(this).apply {
epoxyVisibilityTracker.setPartialImpressionThresholdPercentage(50)
epoxyVisibilityTracker.attach(this)
recyclerView = this
// Plug an epoxy controller
epoxyController = object : TypedEpoxyController<List<AssertHelper>>() {
override fun buildModels(data: List<AssertHelper>?) {
data?.forEachIndexed { index, helper ->
add(
TrackerTestModel(
itemPosition = index,
itemHeight = itemHeight,
helper = helper
).id(helper.id)
)
}
}
}
recyclerView.adapter = epoxyController.adapter
}
recyclerView.adapter = epoxyController.adapter
})
)
viewportHeight = recyclerView.measuredHeight
activity = this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Alternatively you can use {@link EpoxyDataBindingPattern} to avoid explicitly declaring each
* layout.
*/
@Target(ElementType.PACKAGE)
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface EpoxyDataBindingLayouts {
/** A list of databinding layout resources that should have EpoxyModel's generated for them. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* The layouts must not specify a custom databinding class name or package via the
* class="com.example.CustomClassName" override in the layout xml.
*/
@Target(ElementType.PACKAGE)
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface EpoxyDataBindingPattern {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@EpoxyDataBindingPattern(rClass = R.class, layoutPrefix = "view_holder")
@EpoxyDataBindingLayouts({R.layout.model_with_data_binding})
package com.airbnb.epoxy.integrationtest;

import com.airbnb.epoxy.EpoxyDataBindingLayouts;
import com.airbnb.epoxy.EpoxyDataBindingPattern;

@EpoxyDataBindingPattern(rClass = R.class, layoutPrefix = "view_holder")
@EpoxyDataBindingLayouts({R.layout.model_with_data_binding})
interface EpoxyDataBindingConfig {}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import com.airbnb.epoxy.ModelView.Size
import com.airbnb.epoxy.TextProp

@ModelView(autoLayout = Size.WRAP_WIDTH_MATCH_HEIGHT)
class ViewWithInterface(context: Context) : View(context), InterfaceForView, InterfaceForView2,
ClassWithNestedInterface.NestedInterface, InterfaceWithNoPropMethods {
class ViewWithInterface(context: Context) :
View(context),
InterfaceForView,
InterfaceForView2,
ClassWithNestedInterface.NestedInterface,
InterfaceWithNoPropMethods {

override fun getSomething() = 5

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import android.view.View
import androidx.paging.PagedList
import com.airbnb.epoxy.EpoxyController
import com.airbnb.epoxy.EpoxyModel
import java.util.concurrent.Executor
import java.util.concurrent.TimeUnit
import org.hamcrest.CoreMatchers
import org.hamcrest.CoreMatchers.`is`
import org.hamcrest.MatcherAssert.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import java.util.concurrent.Executor
import java.util.concurrent.TimeUnit

@RunWith(AndroidJUnit4::class)
class PagedListModelCacheTest {
Expand Down Expand Up @@ -317,7 +317,8 @@ class PagedListModelCacheTest {
private fun createPagedList(items: List<Item>): Pair<PagedList<Item>, ListDataSource<Item>> {
val dataSource = ListDataSource(items)
val pagedList = PagedList.Builder<Int, Item>(
dataSource, PagedList.Config.Builder()
dataSource,
PagedList.Config.Builder()
.setEnablePlaceholders(true)
.setInitialLoadSizeHint(PAGE_SIZE * 2)
.setPageSize(PAGE_SIZE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,12 @@ internal class PagedListModelCache<T>(
val mainThreadExecutorField =
AsyncPagedListDiffer::class.java.getDeclaredField("mMainThreadExecutor")
mainThreadExecutorField.isAccessible = true
mainThreadExecutorField.set(this, Executor {
modelBuildingHandler.post(it)
})
mainThreadExecutorField.set(
this,
Executor {
modelBuildingHandler.post(it)
}
)
} catch (t: Throwable) {
val msg = "Failed to hijack update handler in AsyncPagedListDiffer." +
"You can only build models on the main thread"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ class PagingSampleActivity : AppCompatActivity() {
recyclerView.adapter = pagingController.adapter

val viewModel = ViewModelProviders.of(this).get(ActivityViewModel::class.java)
viewModel.pagedList.observe(this, Observer {
pagingController.submitList(it)
})
viewModel.pagedList.observe(
this,
Observer {
pagingController.submitList(it)
}
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ abstract class KotlinHolder : EpoxyHolder() {
}

protected fun <V : View> bind(id: Int): ReadOnlyProperty<KotlinHolder, V> =
Lazy { holder: KotlinHolder, prop ->
holder.view.findViewById(id) as V?
?: throw IllegalStateException("View ID $id for '${prop.name}' not found.")
}
Lazy { holder: KotlinHolder, prop ->
holder.view.findViewById(id) as V?
?: throw IllegalStateException("View ID $id for '${prop.name}' not found.")
}

/**
* Taken from Kotterknife.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,13 @@ abstract class AttributeInfo : Comparable<AttributeInfo> {
open fun generatedGetterName(isOverload: Boolean): String = fieldName

override fun toString(): String {
return ("Attribute {" +
"model='" + rootClass + '\''.toString() +
", name='" + fieldName + '\''.toString() +
", type=" + typeName +
'}'.toString())
return (
"Attribute {" +
"model='" + rootClass + '\''.toString() +
", name='" + fieldName + '\''.toString() +
", type=" + typeName +
'}'.toString()
)
}

override fun equals(other: Any?): Boolean {
Expand Down
Loading

0 comments on commit 141894c

Please sign in to comment.