AndroidUniversalAdapter

Additional

Language
Java
Version
N/A
Created
Oct 27, 2016
Updated
Nov 6, 2018 (Retired)
Owner
Arthur Korchagin (lliepmah)
Contributor
Arthur Korchagin (lliepmah)
1
Activity
Badge
Generate
Download
Source code

Android Universal Adapter

Integration

  1. Implement your view holder, by extending DefaultViewHolder<SomeModelClass>
  2. Annotate it by @HolderBuilder(R.layout.some_layout) annotation
  3. Library generates view holder builder
  4. You can use it with your custom adapter, or with UniversalAdapter

Example

View holder builder implementation:

@HolderBuilder(R.layout.li_label)
class LabelHolder extends DefaultViewHolder<String> {

    private final String mValue;

    @BindView(R.id.li_label_tv_text)
    TextView mTvText;

    @HolderConstructor
    LabelHolder(View view, String value) {
        super(view);
        ButterKnife.bind(this, view);
        mValue = value;
    }

    public LabelHolder(View itemView) {
        super(itemView);
        mValue = "";
    }

    @Override
    public void bind(String text) {
        mTvText.setText(mValue + text);
    }
}

Usage holder builder:

  UniversalAdapter adapter = new UniversalAdapter(new ScreenHolderBuilder(this),
                new LabelHolderBuilder("example "));

  adapter.add(getString(R.string.menu));
  adapter.addAll(getScreens());
  
  mRecyclerView.setAdapter(adapter);
  

Gradle

    def universalAdapterVersion = 'x.x.x'
    ...
    dependencies {
      provided "com.github.lliepmah:annotations:$universalAdapterVersion"
      compile "com.github.lliepmah:library:$universalAdapterVersion"
      annotationProcessor "com.github.lliepmah:compiler:$universalAdapterVersion"
    ...
    }

Kotlin

    def universalAdapterVersion = 'x.x.x'
    ...
    dependencies {
      provided "com.github.lliepmah:annotations:$universalAdapterVersion"
      compile "com.github.lliepmah:library:$universalAdapterVersion"
      kapt "com.github.lliepmah:compiler:$universalAdapterVersion"
    ...
    }

ProGuard

No special ProGuard rules required.

License

Copyright 2016 Arthur Korchagin

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.