All Projects → pwnjeswani → SuperAdapter

pwnjeswani / SuperAdapter

Licence: Apache-2.0 License
A Super simple library can be used for inserting elements in between RecyclerView's elements.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to SuperAdapter

recyclerview-kotlin
10+ Tutorials on RecyclerView in Kotlin
Stars: ✭ 41 (+127.78%)
Mutual labels:  recyclerview, recyclerview-adapter, recyclerviewadapter
PrimeAdapter
PrimeAdapter makes working with RecyclerView easier.
Stars: ✭ 54 (+200%)
Mutual labels:  recyclerview, recyclerview-adapter
AdapterCommands
Drop in solution to animate RecyclerView's dataset changes by using command pattern
Stars: ✭ 74 (+311.11%)
Mutual labels:  recyclerview, recyclerview-adapter
slush
This library will no longer be updated 😭
Stars: ✭ 26 (+44.44%)
Mutual labels:  recyclerview, recyclerview-adapter
DiverseRecyclerAdapter
A small and yet powerful library, which greatly simplifies building lists of different items
Stars: ✭ 16 (-11.11%)
Mutual labels:  recyclerview, recyclerview-adapter
Modular2Recycler
Modular²Recycler is a RecyclerView.Adapter that is modular squared.
Stars: ✭ 72 (+300%)
Mutual labels:  recyclerview, recyclerview-adapter
Recycling
A Library for make an easy and faster RecyclerView without adapter
Stars: ✭ 57 (+216.67%)
Mutual labels:  recyclerview, recyclerview-adapter
InfiniteScrollRecyclerView
Enables the RecyclerView to Auto scroll for indefinite time.
Stars: ✭ 49 (+172.22%)
Mutual labels:  recyclerview, recyclerview-adapter
App-Manager-Android
An app manager for Android written in Kotlin. View app related info, launch or uninstall apps.
Stars: ✭ 31 (+72.22%)
Mutual labels:  recyclerview, recyclerview-adapter
Statik
A simple static list information backed by RecyclerView for Android in Kotlin
Stars: ✭ 22 (+22.22%)
Mutual labels:  recyclerview, recyclerview-adapter
jubako
A small API to help display rich content in a RecyclerView such as a wall of carousels
Stars: ✭ 28 (+55.56%)
Mutual labels:  recyclerview, recyclerview-adapter
LxAdapter
RecyclerView Adapter Library
Stars: ✭ 50 (+177.78%)
Mutual labels:  recyclerview, recyclerview-adapter
MultiTypeAdapter
RecyclerView通用多类型适配器MultiTypeAdapter,以布局文件为单位更细粒度的条目复用。
Stars: ✭ 18 (+0%)
Mutual labels:  recyclerview, recyclerview-adapter
recyclerview-expandable
RecyclerView implementation of traex's ExpandableLayout
Stars: ✭ 70 (+288.89%)
Mutual labels:  recyclerview, recyclerview-adapter
BaseRecyclerViewAdapter
RecyclerView通用适配器
Stars: ✭ 14 (-22.22%)
Mutual labels:  recyclerview, recyclerview-adapter
recyclerview-adapters
Multiple item adapters for RecyclerView (inspired by Merge Adapter)
Stars: ✭ 24 (+33.33%)
Mutual labels:  recyclerview, recyclerview-adapter
Admobadapter
It wraps your Adapter to display Admob native ads and banners in a ListView/RecyclerView data set. It based on the Yahoo fetchr project https://github.com/yahoo/fetchr
Stars: ✭ 224 (+1144.44%)
Mutual labels:  recyclerview, recyclerview-adapter
Adapterdelegates
"Favor composition over inheritance" for RecyclerView Adapters
Stars: ✭ 2,735 (+15094.44%)
Mutual labels:  recyclerview, recyclerview-adapter
SortedListAdapter
The RecyclerView.Adapter that makes your life easy!
Stars: ✭ 48 (+166.67%)
Mutual labels:  recyclerview, recyclerview-adapter
RvClickListenerExample
Example showing the implementation of onItemClickListener & getAdapterPosition() in RecyclerView.
Stars: ✭ 22 (+22.22%)
Mutual labels:  recyclerview, recyclerview-adapter

SuperAdapter

License Android Arsenal

A Super simple library can be used for inserting elements in between RecyclerView's elements.

Gradle Dependency

Repository

Add this in your root build.gradle file (not your module build.gradle file):

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

Dependency

Add this to your module's build.gradle file:

dependencies {
	...
	implementation 'com.github.pwnjeswani:SuperAdaper:0.1'
	}
}

Usage

To use this library simply add dependency in your project and follow the steps --

STEP 1 ->
Create your adapter and extend SuperAdapter like this,(Refer sample module) 
We have created useradapter which is used 
for displaying users in RecyclerView.
class UserAdapter : SuperAdapter {
    constructor(context: Context){
        createOtherItemList()
    }
    ....
  }
STEP 2 ->
We want to have ad banners (or any other banner) on specfic positions in the useradapter,
for that we are adding dummyobjects (see class DummyObject) 
which takes itemViewType and position as parameters in the constructor 
override fun createOtherItemList() {
        var dummyObject = DummyObject(1, 1)
	var dummyObject2 = DummyObject(1, 3)
        super.otherViewPositions.add(dummyObject)
	super.otherViewPositions.add(dummyObject2)
    }
STEP 3 ->
After adding the dummy objects, we have to override getItemViewType function 
	override fun getItemViewType(position: Int): Int {
        val itemViewType = super.getItemViewType(position)
        return if (itemViewType != -1) {
		//it's dummy object hence returning the actual viewtype 
		//which was mentioned while creating other item list
            itemViewType
        } else {
		//it's item from your list (i.e, useritem) hence returning viewtype 0(User position)
            0
        }
    }
    
STEP 4 ->
Here is the createViewHolder and 
onBindViewHolder function's code for your reference. 
 override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        when (viewType) {
            0 -> {
                val view = LayoutInflater.from(parent.context).inflate(R.layout.user_item_view, parent, false)
                return UserViewHolder(view)

            }
            1 -> {
                val view = LayoutInflater.from(parent.context).inflate(R.layout.ad_item_view, parent, false)
                return AdViewHolder(view)
            }
        }
    }
    
    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        when (holder.itemViewType) {
            0 -> {
                val holderr = holder as UserViewHolder
                var user = super.baseList[position] as User
                holderr.tv_user_id.text = user.id.toString()
                holderr.tv_user_name.text = user.name
                holderr.tv_user_phone.text = user.phoneNo.toString()

            }
            1 -> {
	    //write your own logic here
            }
        }
    }
    
STEP 5 -> Using this adapter in your activity/fragment
var userAdapter = UserAdapter(this)
userAdapter.setUserList(usersList)
var llm = LinearLayoutManager(this,RecyclerView.VERTICAL,false)
rv_useres.layoutManager = llm
rv_useres.adapter = userAdapter

Inspiration

In our company, we had frequent requirement of inserting elements in various lists. Earlier we were doing all tasks in the adapter itself, but that was getting frustating & also error prone code which requires long hours to fix and this cycle was repeating every week. To solve this problem Mr.CTO Avneesh Kumar seeded the idea of creating SuperAdapter.

LinkedIn

Contribution

Please fork repository and contribute using pull requests.

Any contributions, large or small, major features, bug fixes, additional language translations, unit/integration tests are welcomed and appreciated but will be thoroughly reviewed and discussed.

License

Copyright 2019 pwnjeswani

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].