Skip to content

一个基于mvp+databing开发的笑话app。简化RecyclerView的使用。

Notifications You must be signed in to change notification settings

xufengAndroid/DataBindingAdapter-joke

Repository files navigation

DataBindingAdapter-joke

Joke(笑话app)

项目采用mvp+databinding模式开发。

alt tag       alt tag

databindingadapter

使用databindingadapter库将简化在databinding模式开发RecyclerView。

Download

Download via Gradle:

compile 'com.xufeng.databindingadapter:databindingadapter:1.0.0'

or Maven:

<dependency>
  <groupId>com.xufeng.databindingadapter</groupId>
  <artifactId>databindingadapter</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

How does it work?

Create a class ViewHolder (JokeViewHolder for example). The method updateView will be call with the object, when an update of your view is require:

public class JokeViewHolder extends BindingViewHolder<JokeDto> {
  public JokeViewHolder(ViewDataBinding viewDataBinding) { super(viewDataBinding);}

  @Override
  protected void updateView(Context context, JokeDto object, int position) {
      getBinding().setVariable(BR.joke, object);
  }
}

Give this ViewHolder class to the constructor of the adapter (SimpleAdapter) of your RecyclerView, with the resource id of your item view and the list of objects:

BindingRecyclerViewAdapter<JokeDto> adapter = new BindingRecyclerViewAdapter<>(R.layout.joke_item, JokeViewHolder.class);
recyclerView.setAdapter(adapter);

And that's it!

License

Contributing

Please fork this repository and contribute back 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.

About

一个基于mvp+databing开发的笑话app。简化RecyclerView的使用。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages