BasicAdapter to use instead of separate java files for Android RecyclerView Adapters

Overview

Android-BasicAdapter

BasicAdapter to use instead of separate java files for Android RecyclerView Adapters, with a more comprehensible adapter structure and databinding.

API Release Android Arsenal

Download from the jitpack repo

Add it to your root project build.gradle file at the end of repositories

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Add the dependency

compile 'com.github.ajays97:Android-BasicAdapter:1.0'

Use Android-BasicAdapter

() { @Override public void onBind(int position, Post model, ItemBinding binding) { binding.text.setText(model.username); } })); // Using SmartBinder recyclerView.setAdapter(BasicAdapter.with(R.layout.item, posts, new BasicAdapter.SmartBinder () { @Override public void onBind(int position, Post model, ItemBinding binding) { binding.text.setText(model.username); } @Override public void onClick(View view, Post model, int position) { super.onClick(view, model, position); } @Override public void onCheckedChange(View view, Post model, int position) { super.onCheckedChange(view, model, position); } }).setClickableViews(R.id.text).setCheckableViews(R.id.checkbox));">
ArrayList<Post> posts = new ArrayList<>();        
posts.add(new Post("Ajay"));
posts.add(new Post("Srinivas"));

RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(BasicAdapter.with(R.layout.item, posts, new BasicAdapter.Binder<Post, ItemBinding>() {
    @Override
    public void onBind(int position, Post model, ItemBinding binding) {
        binding.text.setText(model.username);
    }
}));

// Using SmartBinder
recyclerView.setAdapter(BasicAdapter.with(R.layout.item, posts, new BasicAdapter.SmartBinder<Post, ItemBinding>() {
    @Override
    public void onBind(int position, Post model, ItemBinding binding) {
        binding.text.setText(model.username);
    }

    @Override
    public void onClick(View view, Post model, int position) {
        super.onClick(view, model, position);
    }

    @Override
    public void onCheckedChange(View view, Post model, int position) {
        super.onCheckedChange(view, model, position);
    }
}).setClickableViews(R.id.text).setCheckableViews(R.id.checkbox));

License Information

Copyright 2018 Ajay Srinivas

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.
You might also like...
Create a new adapter for a RecyclerView or ViewPager is now much easier.

Efficient Adapter for Android Create a new adapter for a RecyclerView or ViewPager is now much easier. Overview Create a list of elements into a Recyc

Rx based RecyclerView Adapter
Rx based RecyclerView Adapter

RxRecyclerAdapter Rx based generic RecyclerView Adapter Library. How to use it? Example! Enable Databinding by adding these lines to your build.gradle

This Repository simplifies working with RecyclerView Adapter

AutoAdapter This Repository simplifies working with RecyclerView Adapter Gradle: Add it in your root build.gradle at the end of repositories: allproj

Generic RecyclerView adapter

Generic RecyclerView Adapter. Lightweight library which simplifies creating RecyclerView adapters and illuminates writing boilerplate code. Creating a

The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...

FastAdapter The FastAdapter is here to simplify creating adapters for RecyclerViews. Don't worry about the adapter anymore. Just write the logic for h

Vector map library and writer - running on Android and Desktop.
Vector map library and writer - running on Android and Desktop.

Mapsforge See the integration guide and changelog. And read through how to contribute guidelines. If you have any questions or problems, don't hesitat

Android - A ListView adapter with support for multiple choice modal selection
Android - A ListView adapter with support for multiple choice modal selection

MultiChoiceAdapter MultiChoiceAdapter is an implementation of ListAdapter which adds support for modal multiple choice selection as in the native Gmai

Simplify Adapter creation for your Android ListViews.

FunDapter takes the pain and hassle out of creating a new Adapter class for each ListView you have in your Android app. It is a new approach to custom

This library provides GridAdapters(ListGridAdapter & CursorGridAdapter) which enable you to bind your data in grid card fashion within android.widget.ListView, Also provides many other features related to GridListView.
This library provides GridAdapters(ListGridAdapter & CursorGridAdapter) which enable you to bind your data in grid card fashion within android.widget.ListView, Also provides many other features related to GridListView.

GridListViewAdapters This libarary enables you to implement GridView like card layout within ListView with added capabilites like Paginations, Additio

Comments
  • What is

    What is "ItemBinding" for?

    I don't see any example where is defined how to use "ItemBinding". Can You please explain how? I'm trying to recreate Your code for "Kotlin"

    opened by ExtinctAmoeba 0
Releases(1.0)
Owner
Ajay Srinivas
Learning to live. Living to learn.
Ajay Srinivas
Adapter Kit is a set of useful adapters for Android.

Adapter Kit Adapter Kit is a set of useful adapters for Android. The kit currently includes, Instant Adapter Instant Cursor Adapter Simple Section Ada

Ragunath Jawahar 368 Nov 25, 2022
Generate data-view-binding adapters of android recycler view.

Items 这个库可以为 Android 的 RecyclerView 生成基于 Data-View-Binding 的 Adapter。 对比其他一些类似的开源库,它有以下的一些优势: 更好的拓展性。这个库不需要你继承特定的 Adapter 或 ViewHolder 类,你可以继承任何第三方提供的

nekocode 253 Nov 11, 2022
Just like instant coffee, saves 78% of your time on Android's Custom Adapters.

Notice Instant Adapter is now part of an even more awesome Adapter Kit project! Instant Adapter Just like instant coffee, saves 78%* of your time on A

Ragunath Jawahar 232 Nov 25, 2022
This library provides Easy Android ListView Adapters(EasyListAdapter & EasyCursorAdapter) which makes designing Multi-Row-Type ListView very simple & cleaner, It also provides many useful features for ListView.

EasyListViewAdapters Whenever you want to display custom items in listview, then only way to achieve this is to implement your own subclass of BaseAda

Biraj Patel 132 Nov 25, 2022
Open source routing engine for OpenStreetMap. Use it as Java library or server.

GraphHopper Routing Engine GraphHopper is a fast and memory efficient Java routing engine, released under Apache License 2.0. By default it uses OpenS

GraphHopper 4k Jan 7, 2023
Epoxy is an Android library for building complex screens in a RecyclerView

Epoxy Epoxy is an Android library for building complex screens in a RecyclerView. Models are automatically generated from custom views or databinding

Airbnb 8.1k Jan 4, 2023
Android library to auto-play/pause videos from url in recyclerview.

AutoplayVideos Show some ❤️ and star the repo to support the project This library is created with the purpose to implement recyclerview with videos ea

Krupen Ghetiya 989 Nov 17, 2022
:page_with_curl: [Android Library] Giving powers to RecyclerView

Android library that provides most common functions around recycler-view like Swipe to dismiss, Drag and Drop, Divider in the ui, events for when item

Nishant Srivastava 644 Nov 20, 2022
Android library for the adapter view (RecyclerView, ViewPager, ViewPager2)

Antonio Android library for the adapter view (RecyclerView, ViewPager, ViewPager2) Free from implementation of the adapter's boilerplate code ! Reuse

NAVER Z 106 Dec 23, 2022
An Adapter that allows a RecyclerView to be split into Sections with headers and/or footers. Each Section can have its state controlled individually.

⚠️ Archived: this repository is no longer going to be maintained. SectionedRecyclerViewAdapter An Adapter that allows a RecyclerView to be split into

Gustavo Pagani 1.7k Dec 21, 2022