Skip to content

Releases: gotev/recycler-adapter

4.1.1

14 Oct 17:15
Compare
Choose a tag to compare

Improvements

  • fix AdapterItem firstTime behavior with DiffUtils. Thanks to @skyfaccincania

4.1.0

30 Sep 18:55
Compare
Choose a tag to compare

New features

  • When the rendering canvas is empty, you can specify onEmptyCanvas renderable items. This is useful for example if you have complex UIs which may result in no items to be shown and you want an easy way of detecting that scenario to display an empty state or something else without tons of ifs. Big thanks to @mike5v 🎉

Updates

  • Gradle 7.0.2

4.0.0

05 Jun 10:51
Compare
Choose a tag to compare

Breaking changes

  • Removed all the deprecated features in 3.0.0, 3.1.2, 3.2.0
  • syncWithItems is now using Android DiffUtil and accepts a List instead of ArrayList. This also tangibly improves performance.

Fixes

  • Diffing bug in PagingAdapter

Upgrades

  • Kotlin from 1.4.10 to 1.4.32
  • Lifecycle to 2.3.1
  • RecyclerView to 1.2.1
  • Stopped using deprecated Kotlin Android Extensions
  • Stopped using jcenter

3.2.0

17 Apr 10:55
Compare
Choose a tag to compare
  • updated Recycler View to 1.2.0
  • implemented publishing support for Maven Central and dropped Bintray
  • deprecated all the older declarative extensions, which can be replaced by the newer RenderableItems

3.1.2

30 Mar 23:12
Compare
Choose a tag to compare

New features and improvements

  • RenderableItems are now iterable and can accept also lists of null items, adding only the non-null ones
  • Fixed an internal function which can now return null. This could have caused setEmptyItem malfunctioning.

Deprecations

setEmptyItem. Prefer re-rendering the list when needed instead of relying on setEmptyItem. Check AsyncLoadingActivity in the example app.

Why deprecating this feature?

Because it does not allow to handle different situations in which your list may be empty. Imagine this scenario: you go to a screen and then make an API call which returns you a list of stuff.

  • When you land on the page and before you make the API call, your list is empty
  • After you execute the API call successfully, your list may be empty
  • Some error happens during your API call and your list is empty, but you have to notify the user about the error

So, you actually have 3 different empty states which means different things. By using setEmptyItem you cannot cover those 3 different scenarios. Removing that feature and using new render features, you can. Check AsyncLoadingActivity example.

Demo App

  • Added fetcher and AsyncLoadingActivity to demonstrate new extended rendering capabilities
  • Refactorings and improvements

3.1.1

23 Mar 18:22
Compare
Choose a tag to compare

New features and improvements

  • RenderableItems now also accepts nullable values

3.1.0

22 Mar 22:55
Compare
Choose a tag to compare

New features and improvements

  • withAdapterItem is now an inline extension

  • added onClick extension in RecyclerAdapterViewHolder (a throttling click listener to prevent double clicks). You can use it on your views: yourView.onClick { }

  • added onClickWith, which combines onClick and withAdapterItem:
    This:

    itemView.setOnClickListener {
        withAdapterItem<TextWithToggleItem> {
            // do something
        }
    }

    can be rewritten as:

    itemView.onClickWith<TextWithToggleItem> {
        // do something
    }
  • added RenderableItems DSL. It allows a functional-declarative approach without using arrayOf, listOf, spread operator or toTypedArray
    Example:

    render {
        +Items.leaveBehind("swipe to left to leave behind", "option")
    
        (0..random.nextInt(200) + 50).map {
            if (it % 2 == 0)
                +Items.Card.titleSubtitle("Item $it", "subtitle $it")
            else
                +Items.Card.labelWithToggle("Toggle $it")
        }
    }

    Example 2:

    private fun singleSelectionGroup(): RenderableItems = renderableItems {
        val selectedItem = groupAselected.firstOrNull()
    
        (1..3).map { number ->
            +Items.switch(
                label = "Option $number",
                onClick = { item ->
                    val selected = listOf(item)
                    onGroupChangedSelection("Group A", selected)
                    groupAselected = selected
                    render(selectionGroups())
                }
            ).apply {
                selected = equals(selectedItem)
            }
        }
    }
    
    private fun selectionGroups() = renderableItems {
        +Items.label(getString(R.string.single_selection))
        +singleSelectionGroup()
    
        +Items.label(getString(R.string.multiple_selection))
        +multipleSelectionGroup()
    
        +Items.button(
            text = getString(R.string.show_selections),
            onClick = {
                val selectedA = groupAselected.asString()
                val selectedB = groupBselected.asString()
    
                AlertDialog.Builder(this@GroupsSelectionActivity)
                    .setTitle("Selected items")
                    .setMessage(
                        "${getString(R.string.single_selection)}:\n$selectedA\n\n" +
                            "${getString(R.string.multiple_selection)}:\n$selectedB"
                    )
                    .setPositiveButton("Ok", null)
                    .show()
            }
        )
    }

3.0.0

20 Mar 10:09
Compare
Choose a tag to compare

All the AdapterItems written for RecyclerAdapter 2.10.x are 100% compatible with 3.0.0 without any change.

Breaking changes

  • removed RecyclerAdapter.createRecycledViewPool It's better to use plain RecyclerView.RecycledViewPool() and pass it around to all the shared Recycler Views
  • removed internal support for selection groups. They can be achieved without that support, which was cumbersome. Updated examples in the demo app.
  • moved lockScrollingWhileInserting as an external extension
  • moved enableDragDrop as an external extension
  • removed getItemPosition. It's now achieved with recyclerAdapter.adapterItems.indexOf(item)
  • removed getItemAtPosition. It's now achieved with recyclerAdapter.adapterItems.getOrNull(item)
  • removed sort. It's now achieved with recyclerAdapter.modifyItemsAndRender { it.sorted() } and recyclerAdapter.modifyItemsAndRender { it.sortedDescending() }. Check the readme for more details.
  • removed removeAllItemsWithClass, getLastItemWithClass, removeLastItemWithClass methods and RemoveListener. It's now achieved with modifyItemsAndRender extension. Check the demo app for replacement details and examples.

Deprecations

  • AdapterItem's getLayoutId. Use getView(parent: ViewGroup) = parent.inflating(id) instead
  • AdapterItem View Holder's getAdapterItem(). Use withAdapterItem<SomeItem> { } instead

New features and improvements

  • You can get a copy of the internal list with recyclerAdapter.adapterItems. Modifying that list won't affect the internal one.
  • added RecyclerAdapter.modifyItemsAndRender extension which gives freedom to manipulate the internal list and render it back. It's the replacement for sort, removeAllItemsWithClass, getLastItemWithClass, removeLastItemWithClass methods
  • RecyclerView.withSharedViewPool and RecyclerView.setupWithPrefetchingLinearLayoutAndSharedViewPool extensions now accepts a RecyclerView.RecycledViewPool as parameter. If not specified, it will continue to use the global shared pool as in 2.x
  • You can swap two items in the RecyclerAdapter
  • Improved internal handling of the empty item
  • added getView(parent: ViewGroup) which allows to both inflate XML views by using parent.inflating(id) or to create them completely programmatically
  • added Int.dp(context) to favor programmatic views and be able to write 24.dp(context)
  • added withAdapterItem<SomeItem> { } to replace error prone and cumbersome (getAdapterItem() as? SomeItem)?.apply { }
  • enhanced release script, which now build and adds the demo app in the release
  • dropped support for Android API < 21

Updates

  • Kotlin 1.4.10

2.8.1

18 Jul 20:42
Compare
Choose a tag to compare

Fixed bintray deployment problems after switching to Gradle 5

2.8.0

15 Jul 20:26
Compare
Choose a tag to compare
  • Updated Gradle Plugin to 3.4.1
  • Updated Gradle to 5.4.1
  • Using new Sky-UK Gradle maven plugin and dropped dcendents maven plugin
  • Implemented "prepareForReuse" in view holders
  • Added declarative extensions