Skip to content
This repository has been archived by the owner on Dec 24, 2022. It is now read-only.

Commit

Permalink
0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
afollestad committed May 16, 2019
1 parent 2b38240 commit 2731eb0
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Add this to your module's `build.gradle` file:
```gradle
dependencies {
implementation 'com.afollestad:recyclical:0.7.2'
implementation 'com.afollestad:recyclical:0.8.0'
}
```

Expand Down
13 changes: 5 additions & 8 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
0.7.2
0.8.0

1. `DataSource`'s add method can now take multiple items as vararg parameters.
2. Added an `addAll` method to `DataSource` for appending collections as well.

### 0.7.1
1. Kotlin 1.3.0
2. A new `recyclical-swipe` module! Add it your app to gain access to an extension to the core library which enables swipe actions, like swipe to delete.
3. `DataSource` now accepts a generic type, to make it easier if your list only contains one type of item. (sorry if this breaks your app temporarily, you just need to use `DataSource<Any>` if you don't care about any specific type).
1. Fix a crash caused by stored indices getting out of date as items are removed from the list.
2. `withItem` can take a custom class name string to support generated model classes, see #11.
3. Added generic `withSwipeActionOn<>` method to the swipe plugin to target specific item types, see #12.
4. Internal cleanup and dependency upgrades.
32 changes: 22 additions & 10 deletions core/src/test/java/com/afollestad/recyclical/ItemDefinitionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.afollestad.recyclical

import android.content.Context
import android.view.View
import android.widget.FrameLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
Expand Down Expand Up @@ -53,6 +54,20 @@ class ItemDefinitionTest {
private val globalClickListener = TestClickListener<Any>()
private val globalLongClickListener = TestClickListener<Any>()

private val viewHolderCreator: (View) -> (TestViewHolder) = { view ->
val newViewHolder = mock<TestViewHolder> {
on { title } doReturn TextView(ApplicationProvider.getApplicationContext())
on { adapterPosition } doReturn TEST_ITEM_INDEX
}
newViewHolder.apply {
val itemViewField = ViewHolder::class.java.getDeclaredField("itemView")
.apply {
isAccessible = true
}
itemViewField.set(this, view)
}
}

private lateinit var titleView: TextView
private lateinit var rootView: FrameLayout

Expand All @@ -61,9 +76,9 @@ class ItemDefinitionTest {
withClickListener(globalClickListener.capture())
withLongClickListener(globalLongClickListener.capture())
}
private val definition = RealItemDefinition(
private val definition = RealItemDefinition<TestItem>(
setup = setup,
itemClass = TestItem::class.java
itemClassName = TestItem::class.java.name
)

@Before fun create() {
Expand Down Expand Up @@ -107,8 +122,8 @@ class ItemDefinitionTest {

wasBinderCalled.assertTrue()

rootView.getTag(R.id.rec_view_item_adapter_position)
.assertEqualTo(TEST_ITEM_INDEX)
rootView.getTag(R.id.rec_view_item_view_holder)
.assertIsA<ViewHolder>()
rootView.getTag(R.id.rec_view_item_selectable_data_source)
.assertNull()
}
Expand All @@ -117,9 +132,8 @@ class ItemDefinitionTest {
val listener = TestClickListener<TestItem>()
definition.onClick(listener.capture())

val creator = ::TestViewHolder
val binder: ViewHolder.(Int, TestItem) -> Unit = { _, _ -> }
definition.onBind(creator, binder)
definition.onBind(viewHolderCreator, binder)
val viewHolder = definition.createViewHolder(rootView)
definition.bindViewHolder(viewHolder, testItem, TEST_ITEM_INDEX)

Expand All @@ -132,9 +146,8 @@ class ItemDefinitionTest {
val listener = TestClickListener<TestItem>()
definition.onLongClick(listener.capture())

val creator = ::TestViewHolder
val binder: ViewHolder.(Int, TestItem) -> Unit = { _, _ -> }
definition.onBind(creator, binder)
definition.onBind(viewHolderCreator, binder)
val viewHolder = definition.createViewHolder(rootView)
definition.bindViewHolder(viewHolder, testItem, TEST_ITEM_INDEX)

Expand All @@ -147,9 +160,8 @@ class ItemDefinitionTest {
val listener = TestChildClickListener<TestItem, TextView>()
definition.onChildViewClick(TestViewHolder::title, listener.capture())

val creator = ::TestViewHolder
val binder: ViewHolder.(Int, TestItem) -> Unit = { _, _ -> }
definition.onBind(creator, binder)
definition.onBind(viewHolderCreator, binder)

val viewHolder = definition.createViewHolder(rootView) as TestViewHolder
definition.bindViewHolder(viewHolder, testItem, TEST_ITEM_INDEX)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mock-maker-inline
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ ext.versions = [
minSdk : 19,
compileSdk : 28,
buildTools : '28.0.3',
publishVersion : '0.7.2',
publishVersionCode : 15,
publishVersion : '0.8.0',
publishVersionCode : 16,

gradlePlugin : '3.4.0',
kotlin : '1.3.31',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class SwipePluginTest {

getPluginData<SwipePluginData>(PLUGIN_NAME)!!.run {
actions.assertSize(2)
actions.assertContainsKey(LEFT)
actions.assertContainsKey(RIGHT)
actions.assertContainsKey(ActionKey(LEFT, null))
actions.assertContainsKey(ActionKey(RIGHT, null))
}
}

Expand All @@ -73,7 +73,7 @@ class SwipePluginTest {

getPluginData<SwipePluginData>(PLUGIN_NAME)!!.run {
actions.assertSize(1)
actions.assertContainsKey(LEFT)
actions.assertContainsKey(ActionKey(LEFT, null))
getSwipeDirections().assertEqualTo(ItemTouchHelper.LEFT)
}
}
Expand All @@ -89,7 +89,7 @@ class SwipePluginTest {

getPluginData<SwipePluginData>(PLUGIN_NAME)!!.run {
actions.assertSize(1)
actions.assertContainsKey(RIGHT)
actions.assertContainsKey(ActionKey(RIGHT, null))
getSwipeDirections().assertEqualTo(ItemTouchHelper.RIGHT)
}
}
Expand All @@ -105,8 +105,8 @@ class SwipePluginTest {

getPluginData<SwipePluginData>(PLUGIN_NAME)!!.run {
actions.assertSize(2)
actions.assertContainsKey(LEFT)
actions.assertContainsKey(RIGHT)
actions.assertContainsKey(ActionKey(LEFT, null))
actions.assertContainsKey(ActionKey(RIGHT, null))
getSwipeDirections()
.assertEqualTo(ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT)
}
Expand Down

0 comments on commit 2731eb0

Please sign in to comment.