All Projects → nitrico → Lastadapter

nitrico / Lastadapter

Licence: apache-2.0
Don't write a RecyclerView adapter again. Not even a ViewHolder!

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Lastadapter

Brv
Android上最强大的RecyclerView库
Stars: ✭ 345 (-55.6%)
Mutual labels:  databinding, recyclerview, recyclerview-adapter
Fastadapter
The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
Stars: ✭ 3,512 (+351.99%)
Mutual labels:  recyclerview, recyclerview-adapter
Zoomrecylerlayout
🎢 Zoom Recycler Layout Manager For Android Kotlin
Stars: ✭ 618 (-20.46%)
Mutual labels:  recyclerview, recyclerview-adapter
Codeview Android
Display code with syntax highlighting ✨ in native way.
Stars: ✭ 748 (-3.73%)
Mutual labels:  recyclerview, recyclerview-adapter
Recyclerviewevent
RecyclerView onItemClick、onItemLongClick、drag、swipe、divider、reuse disorder RecyclerView 梳理:点击&长按事件、分割线、拖曳排序、滑动删除、优雅解决 EditText 和 CheckBox 复用错乱问题
Stars: ✭ 265 (-65.89%)
Mutual labels:  recyclerview, recyclerview-adapter
Chipslayoutmanager
ANDROID. ChipsLayoutManager (SpanLayoutManager, FlowLayoutManager). A custom layout manager for RecyclerView which mimicric TextView span behaviour, flow layouts behaviour with support of amazing recyclerView features
Stars: ✭ 3,138 (+303.86%)
Mutual labels:  recyclerview, recyclerview-adapter
Easyxrecyclerview
主要提供了简单易用强大的RecyclerView库,包括自定义刷新加载效果、极简通用的万能适配器Adapter、万能分割线、多种分组效果、常见状态页面、item动画效果、添加多个header和footer、侧滑、拖拽、Sticky(黏性)效果、多item布局等,各模块之间灵活、解耦、通用、又能相互组合使用。
Stars: ✭ 607 (-21.88%)
Mutual labels:  recyclerview, recyclerview-adapter
AccordionRecycler
Android RecyclerView Adapter with nested items & expand/contract functionality
Stars: ✭ 17 (-97.81%)
Mutual labels:  recyclerview, recyclerview-adapter
Klaster
Declare RecyclerView adapters in a functional way, without boilerplate and subclassing. No compromises on flexibility. If it's possible to do something by subclassing, it's possible to do it with this library.
Stars: ✭ 373 (-51.99%)
Mutual labels:  recyclerview, recyclerview-adapter
Multiitem
一个优雅的实现多类型的RecyclerView类库 支持DataBinding Form表单录入 跨多个RecyclerView拖动
Stars: ✭ 381 (-50.97%)
Mutual labels:  databinding, recyclerview
Brvah kotlin
This is kotlin BRVAH Demo
Stars: ✭ 402 (-48.26%)
Mutual labels:  recyclerview, recyclerview-adapter
Tableview
TableView is a powerful Android library for displaying complex data structures and rendering tabular data composed of rows, columns and cells.
Stars: ✭ 2,928 (+276.83%)
Mutual labels:  recyclerview, recyclerview-adapter
SimplifiedRecyclerview
An android library to help you get rid of boiler plate code when setting up Recyclerview
Stars: ✭ 19 (-97.55%)
Mutual labels:  recyclerview, recyclerview-adapter
Kiel
Kotlin way of building RecyclerView Adapter 🧩. You do not have to write RecyclerView Adapters again and again and suffer from handling of different view types. Kiel will help you.
Stars: ✭ 297 (-61.78%)
Mutual labels:  recyclerview, recyclerview-adapter
RecyclerELE
Android Library for easy addition of Empty, Loading and Error views in a RecyclerView
Stars: ✭ 27 (-96.53%)
Mutual labels:  recyclerview, recyclerview-adapter
Recycler Fast Scroll
Provides fast scroll and section idexer for recycler view
Stars: ✭ 445 (-42.73%)
Mutual labels:  recyclerview, recyclerview-adapter
kandy
Sweet Android libraries written in Kotlin
Stars: ✭ 19 (-97.55%)
Mutual labels:  recyclerview, recyclerview-adapter
BindingListAdapter
Say goodbye to repeated, redundant custom Adapters , Make the developer's focus on the data, beacuse data-driven UI (告别反复、冗余的自定义Adapter,让开发者的重点落在数据上,做到数据驱动UI)
Stars: ✭ 111 (-85.71%)
Mutual labels:  recyclerview-adapter, databinding
Multichoicerecyclerview
Multi choice selection applied on recycler view make life easier
Stars: ✭ 361 (-53.54%)
Mutual labels:  recyclerview, recyclerview-adapter
Recyclerviewtemplate
One Template which solves all frequently used RecyclerViews Code Snippets
Stars: ✭ 404 (-48.01%)
Mutual labels:  recyclerview, recyclerview-adapter

Download Android Arsenal License Gitter

LastAdapter

Don't write a RecyclerView adapter again. Not even a ViewHolder!

  • Based on Android Data Binding
  • Written in Kotlin
  • No need to write the adapter
  • No need to write the viewholders
  • No need to modify your model classes
  • No need to notify the adapter when data set changes
  • Supports multiple item view types
  • Optional Callbacks/Listeners
  • Very fast — no reflection
  • Super easy API
  • Tiny size: ~30 KB
  • Minimum Android SDK: 9

Setup

Gradle

// apply plugin: 'kotlin-kapt' // this line only for Kotlin projects

android {
    ...
    dataBinding.enabled true 
}

dependencies {
    compile 'com.github.nitrico.lastadapter:lastadapter:2.3.0'
    // kapt 'com.android.databinding:compiler:GRADLE_PLUGIN_VERSION' // this line only for Kotlin projects
}

Usage

Create your item layouts with <layout> as root:

<layout xmlns:android="http://schemas.android.com/apk/res/android">

    <data>
        <variable name="item" type="com.github.nitrico.lastadapterproject.item.Header"/>
    </data>
    
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@{item.text}"/>
        
</layout>

It is important for all the item types to have the same variable name, in this case "item". This name is passed to the adapter builder as BR.variableName, in this case BR.item:

// Java
new LastAdapter(listOfItems, BR.item)
           .map(Header.class, R.layout.item_header)
           .map(Point.class, R.layout.item_point)
           .into(recyclerView);
// Kotlin
LastAdapter(listOfItems, BR.item)
           .map<Header>(R.layout.item_header)
           .map<Point>(R.layout.item_point)
           .into(recyclerView)

The list of items can be an ObservableList if you want to get the adapter automatically updated when its content changes, or a simple List if you don't need to use this feature.

LayoutHandler

The LayoutHandler interface allows you to use different layouts based on more complex criteria. Its one single method receives the item and the position and returns the layout resource id.

// Java sample
new LastAdapter(listOfItems, BR.item)
           .handler(handler)
           .into(recyclerView);

private LayoutHandler handler = new LayoutHandler() {
    @Override public int getItemLayout(@NotNull Object item, int position) {
        if (item instanceof Header) {
            return (position == 0) ? R.layout.item_header_first : R.layout.item_header;
        } else {
            return R.layout.item_point;
        }
    }
};
// Kotlin sample
LastAdapter(listOfItems, BR.item).layout { item, position ->
    when (item) {
        is Header -> if (position == 0) R.layout.item_header_first else R.layout.item_header
        else -> R.layout.item_point 
    }
}.into(recyclerView)

For further information, please take a look at my article at Medium.

Custom fonts

You might also want to try FontBinder to easily use custom fonts in your XML layouts.

Acknowledgments

Thanks to Yigit Boyar and George Mount for this talk.

Author

Miguel Ángel Moreno

I'm open to new job positions - Contact me!

AngelList Email Facebook Google+ Linked.in Twitter

License

Copyright 2016 Miguel Ángel Moreno

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].