- Notifications
You must be signed in to change notification settings - Fork8
Android library for the adapter view (RecyclerView, ViewPager, ViewPager2)
License
NotificationsYou must be signed in to change notification settings
naverz/Antonio
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Android library for the adapter view (RecyclerView, ViewPager, ViewPager2)
- Free from implementation of the adapter's boilerplate code!
- Free from implementation of the view holder with data-binding (Two-way binding OK)!
- ViewPager, ViewPager2, Paging2, Paging3 supported!
- Manage the recycler view state on your view model!
- There is no things to learn, if you already know about adapter views (RecyclerView, ViewPager, ViewPager2)!
dependencies {def antonioVersion='1.0.9-alpha' implementation"io.github.naverz:antonio:$antonioVersion"//For paging2 implementation"io.github.naverz:antonio-paging2:$antonioVersion"//For paging3 implementation"io.github.naverz:antonio-paging3:$antonioVersion"// You can implement additional dependencies as bellow, if you want to use AntonioAnnotation.def antonioAnnotationVersion='0.0.8-alpha' implementation"io.github.naverz:antonio-annotation:$antonioAnnotationVersion"//For java (You must select only one of kapt, ksp and annotationProcessor) annotationProcessor"io.github.naverz:antonio-compiler:$antonioAnnotationVersion"//For kotlin kapt (You must select only one of kapt, ksp and annotationProcessor) kapt"io.github.naverz:antonio-compiler:$antonioAnnotationVersion"//For kotlin ksp (You must select only one of kapt, ksp and annotationProcessor) ksp"io.github.naverz:antonio-compiler:$antonioAnnotationVersion"}
dependencies {def antonioVersion='1.0.9-alpha' implementation"io.github.naverz:antonio-databinding:$antonioVersion"//For paging2 implementation"io.github.naverz:antonio-databinding-paging2:$antonioVersion"//For paging3 implementation"io.github.naverz:antonio-databinding-paging3:$antonioVersion"}
- Implement
AntonioBindingModel
to bind model on yourview holder layout xml.
data classContentSmallModel(valid:String, @DrawableResvaliconRes:Int,valprice:Int,valonClick: (id:String)->Unit,valonLongClick: (id:String)->Boolean,valselectedIds:LiveData<Set<String>>) : AntonioBindingModel {// Layout id to be inflatedoverridefunlayoutId():Int=R.layout.view_holder_content_small// Variable id in XML to be bind on bind view holder// (e.g., onBindViewHolder in ViewHolder, onViewCreated in Fragment).overridefunbindingVariableId():Int=BR.model}
- Create your view holder layout xml with the AntonioBindingModel you implemented.
view_holder_content_small.xml
<?xml version="1.0" encoding="utf-8"?><layoutxmlns:android="http://schemas.android.com/apk/res/android" > <data> <variablename="model"type="io.github.naverz.antonio.sample.ContentSmallModel" /> </data> <LinearLayoutandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:gravity="center_horizontal"android:onClick="@{()->model.onClick.invoke(model.id)}"android:onLongClick="@{(view)->model.onLongClick.invoke(model.id)}"android:orientation="vertical"android:padding="5dp" ><!-- ...--> </LinearLayout></layout>
- Declare
AntonioAdapter
(orAntonioListAdapter
) and Set adapter with your data to RecyclerView.
privatefuninitAdapter(){// You also can specify the type of Antonio model for the adapter, if you don't need various view types.// e.g., AntonioAdapter<ContentSmallModel>() binding.recyclerView.adapter=AntonioAdapter<AntonioModel>().apply { currentList= viewModel.antonioModels }// Don't forget to set the layout manager to your recycler view :) binding.recyclerView.layoutManager=GridLayoutManager(context,4) viewModel.onDataSetChanged.observe(this) { binding.recyclerView.adapter?.notifyDataSetChanged() } }
LifecycleOwner, which is nearest from the view, will be automatically injected on All of XML inflated fromAutoBindingModel
in order to use LiveData for two-way binding.
- Additional tips for Data binding
- Usage without data binding
- Additional component for Antonio
- Plug-in
- AdapterView state (RecyclerView, ViewPager)
The sample module is available!
AntonioCopyright (c) 2021-present NAVER Z Corp.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.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.
About
Android library for the adapter view (RecyclerView, ViewPager, ViewPager2)
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published