Generic Recycler Adapter

Generic adapters for Android based on https://github.com/MaximeJallu/generic-adapter-kotlin

Лицензия

Лицензия

The Code Project Open License (CPOL) 1.02
Категории

Категории

Kotlin Языки программирования
Группа

Группа

com.github.maximejallu
Идентификатор

Идентификатор

adapters-kotlin
Последняя версия

Последняя версия

18.08.01
Дата

Дата

Тип

Тип

aar
Описание

Описание

Generic Recycler Adapter
Generic adapters for Android based on https://github.com/MaximeJallu/generic-adapter-kotlin
Ссылка на сайт

Ссылка на сайт

https://github.com/MaximeJallu/generic-adapter-kotlin
Система контроля версий

Система контроля версий

https://github.com/MaximeJallu/generic-adapter-kotlin

Скачать adapters-kotlin

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.maximejallu/adapters-kotlin/ -->
<dependency>
    <groupId>com.github.maximejallu</groupId>
    <artifactId>adapters-kotlin</artifactId>
    <version>18.08.01</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.maximejallu/adapters-kotlin/
implementation 'com.github.maximejallu:adapters-kotlin:18.08.01'
// https://jarcasting.com/artifacts/com.github.maximejallu/adapters-kotlin/
implementation ("com.github.maximejallu:adapters-kotlin:18.08.01")
'com.github.maximejallu:adapters-kotlin:aar:18.08.01'
<dependency org="com.github.maximejallu" name="adapters-kotlin" rev="18.08.01">
  <artifact name="adapters-kotlin" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.maximejallu', module='adapters-kotlin', version='18.08.01')
)
libraryDependencies += "com.github.maximejallu" % "adapters-kotlin" % "18.08.01"
[com.github.maximejallu/adapters-kotlin "18.08.01"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
org.jetbrains.kotlin : kotlin-stdlib-jdk7 jar 1.2.60
com.android.support » appcompat-v7 jar 27.1.1
com.android.support » recyclerview-v7 jar 27.1.1

Модули Проекта

Данный проект не имеет модулей.

Status

alt text API

Generic-Adapter-Kotlin:

This tool allows you to no longer worry about adapters. Now you will only create your ViewHolder. Communication management between your Views and your ViewHolders is possible. Creating sections is now very easily. Enjoy.

Download Maven Central

buildtool used is 27 use {exclude group: 'com.android.support'} only if you have problems

dependencies {
    ...
    implementation ('com.github.maximejallu:adapters-kotlin:18.08.01')
    ...
}

Decorators for : ButterKnife - Picasso - Glide ...

class SampleApplication: Application {

    override 
    fun onCreate() {
        super.onCreate()

        RecyclerAdapter.Companion.Helper()
                    .attachInitBindingView(decorator = object : InitBindingViewHolder {
                        override fun initBinding(target: Any, view: View) {
                            if (view.javaClass.simpleName.contains(".java")) {
                                //TODO e.g. butter-knife binding...
                            }
                        }
                    })
    }
}

1- Create yours RecyclerViewHolder (Easy sample method)

class ViewOne(parent: ViewGroup) : RecyclerViewHolder<Int>(
            parent, R.layout.support_simple_spinner_dropdown_item
        ) {

        init {
            itemView.setOnClickListener {
                (getCommunication() as ViewOneListener).onClick(item)
            }
        }
       
        override fun onBind() {
            itemView.myTextViewId.text = "text: $item"
        }

        interface ViewOneListener: RecyclerViewListener{
            fun onClick(item: Int)
        }  
    }

2 - Create and init Adapter

fun sample(){
val adapter = RecyclerAdapter<Int>(
            items = ArrayList(),
            defaultViewHolder = ViewOne::class, /*for getItemViewType == 0*/
            listener = object :ViewOne.ViewOneListener{
                            override fun onClick(item: Int) {
                                TODO("not implemented")
                            }
            
                        }
        )
    /*attache others viewHolder*/    
    adapter.registerViewHolder(TYPE_2, ViewTwo::class, listener = null)      
} 

3 - Declare strategy view type is necessary (Multi cell method)

fun multicellSample(){
        /*sample for multi Cell [3 viewholder resgistered for this sample]*/
        adapter.setItemViewTypeStrategy(strategy = object : ViewTypeStrategy<Int> {
            override fun getItemViewType(position: Int, item: Int): Int {
                return when{
                    position == 0 -> TYPE_1
                    item > 5 -> TYPE_2
                    else -> TYPE_3
                }
            }
        })
}

Версии библиотеки

Версия
18.08.01
18.07.02
18.07.01