Skip to content

Commit

Permalink
Merge pull request #447 from elfman/master
Browse files Browse the repository at this point in the history
Change the name of  DataBindingAdapter in demo in case of confusion
  • Loading branch information
CymChad authored Oct 26, 2016
2 parents ebef86c + 7abd1cb commit 7aadc1d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.chad.baserecyclerviewadapterhelper;

import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.baserecyclerviewadapterhelper.adapter.DataBindingAdapter;
import com.chad.baserecyclerviewadapterhelper.adapter.DataBindingUseAdapter;
import com.chad.baserecyclerviewadapterhelper.entity.Movie;

import java.util.ArrayList;
Expand All @@ -16,15 +15,15 @@
public class DataBindingUseActivity extends Activity {

RecyclerView mRecyclerView;
DataBindingAdapter mAdapter;
DataBindingUseAdapter mAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_data_binding_use);

mRecyclerView = (RecyclerView)findViewById(R.id.rv);
mAdapter = new DataBindingAdapter(R.layout.item_movie, genData());
mAdapter = new DataBindingUseAdapter(R.layout.item_movie, genData());
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setAdapter(mAdapter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.baserecyclerviewadapterhelper.adapter.DataBindingAdapter;
import com.chad.baserecyclerviewadapterhelper.adapter.HomeAdapter;
import com.chad.baserecyclerviewadapterhelper.entity.HomeItem;
import com.chad.library.adapter.base.BaseQuickAdapter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.chad.baserecyclerviewadapterhelper.R;
import com.chad.baserecyclerviewadapterhelper.entity.Movie;
import com.chad.baserecyclerviewadapterhelper.entity.MoviePresenter;
import com.chad.baserecyclerviewadapterhelper.entity.Person;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

Expand All @@ -19,40 +18,43 @@
* Created by luoxiongwen on 16/10/24.
*/

public class DataBindingAdapter extends BaseQuickAdapter<Movie, DataBindingAdapter.PersonViewHolder> {
public class DataBindingUseAdapter extends BaseQuickAdapter<Movie, DataBindingUseAdapter.MovieViewHolder> {

private MoviePresenter mPresenter;

public DataBindingAdapter(int layoutResId, List<Movie> data) {
public DataBindingUseAdapter(int layoutResId, List<Movie> data) {
super(layoutResId, data);

mPresenter = new MoviePresenter();
}

@Override
protected void convert(PersonViewHolder helper, Movie item) {
protected void convert(MovieViewHolder helper, Movie item) {
ViewDataBinding binding = helper.getBinding();
binding.setVariable(BR.movie, item);
binding.setVariable(BR.presenter, mPresenter);
binding.executePendingBindings();
}

@Override
protected PersonViewHolder createBaseViewHolder(View view) {
return new PersonViewHolder(view);
protected MovieViewHolder createBaseViewHolder(View view) {
return new MovieViewHolder(view);
}

@Override
protected View getItemView(int layoutResId, ViewGroup parent) {
ViewDataBinding binding = DataBindingUtil.inflate(mLayoutInflater, layoutResId, parent, false);
if (binding == null) {
return super.getItemView(layoutResId, parent);
}
View view = binding.getRoot();
view.setTag(R.id.BaseQuickAdapter_databinding_support, binding);
return view;
}

public class PersonViewHolder extends BaseViewHolder {
public class MovieViewHolder extends BaseViewHolder {

public PersonViewHolder(View view) {
public MovieViewHolder(View view) {
super(view);
}

Expand Down

0 comments on commit 7aadc1d

Please sign in to comment.