Skip to content

UFreedom/LubanAdapter

Repository files navigation

Luban Adapter

Make it more easy to work with RecyclerView.

📎 Lastest version

module LubanAdapter-api LubanAdapter-compiler
version Download Download

👉 Features

  • Support LubanApdaterHelper to bind layout,model and ViewHolder
  • Support @BindType or @BindTypes annotations to bind layout,model and ViewHolder

🖥 Usage

Step 1

Add dependencies in build.gradle.

    dependencies {
        compile 'com.ufreedom.kit:lubanadapter-api:1.2.0'
        annotationProcessor 'com.ufreedom.kit:lubanadapter-compiler:1.2.0.1'
    }
Step 2

Create your model

    public class Animals {
    }

And then create your ViewHolder

    public class AnimalsHolder extends LubanViewHolder<Animals> {

    public ImageHolder(View itemView) {
        super(itemView);
        //Hear to find views
    }

    @Override
    public void onBindViewHolder(Animals animalsModel, int position) {
        //Hear to bind view with you model data
    }
}
Step 3

Use LubanAdapter to bind your layout,model,and ViewHolder. Thear have two easy way to do this:

  • Use LubanAdapterHelper
    LubanAdapter<Animals> lubanAdapter = LubanAdapterHelper.create(context)
                .register(Animals.class, R.layout.view_item_animals,AnimalsHolder.class)
                .apply();
    lubanAdapter.setAdataList(AnimalsList);

    recyclerView.setAdapter(lubanAdapter);
  • Use @BindType or @BindTypes annotations

Use anotations is much more easy

@BindType(layout = R.layout.view_item_animals, model = Animals.class, holder = AnimalsHolder.class)
public class AnimalsAdapter extends LubanAdapter<Animals> {
    public DemoAdapter(Context context) {
        super(context);
    }
}
recyclerView.setAdapter(new AnimalsAdapter(content));

License

Copyright 2019 UFreedom

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.

About

Make it more easy to work with RecyclerView.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages