Skip to content

Commit

Permalink
recyclerview set adapter in Walle
Browse files Browse the repository at this point in the history
  • Loading branch information
donniesky committed Jun 15, 2017
1 parent 6b1e94e commit 5d796b0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/me/donnie/adapter/BaseAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @description
*/

public abstract class BaseAdapter<T> extends MultiItemAdapter<T, ViewHolder> {
public abstract class BaseAdapter<T> extends MultiItemAdapter<T> {

public BaseAdapter(final int layoutResId, List<T> datas) {
super(datas);
Expand Down
10 changes: 5 additions & 5 deletions library/src/main/java/me/donnie/adapter/MultiItemAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @description
*/

public abstract class MultiItemAdapter<T, K extends ViewHolder> extends RecyclerView.Adapter<K> {
public abstract class MultiItemAdapter<T> extends RecyclerView.Adapter<ViewHolder> {

private static final String TAG = MultiItemAdapter.class.getSimpleName();

Expand Down Expand Up @@ -160,17 +160,17 @@ public int getItemViewType(int position) {
}

@Override
public K onCreateViewHolder(ViewGroup parent, int viewType) {
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
mContext = parent.getContext();
this.mInflater = LayoutInflater.from(mContext);
ItemViewDelegate itemViewDelegate = mItemViewDelegateManager.getItemViewDelegate(viewType);
K holder = (K) K.createBaseViewHolder(mContext, parent, itemViewDelegate.getItemViewLayoutId());
ViewHolder holder = ViewHolder.createBaseViewHolder(mContext, parent, itemViewDelegate.getItemViewLayoutId());
bindViewClickListener(holder);
return holder;
}

@Override
public void onBindViewHolder(K holder, int position) {
public void onBindViewHolder(ViewHolder holder, int position) {
convert(holder, mDatas.get(position));
}

Expand Down Expand Up @@ -201,7 +201,7 @@ protected void startAnim(Animator animator, int position) {
animator.setInterpolator(mInterpolator);
}

public void convert(K holder, T t) {
public void convert(ViewHolder holder, T t) {
mItemViewDelegateManager.convert(holder, t, holder.getAdapterPosition());
}

Expand Down
4 changes: 4 additions & 0 deletions library/src/main/java/me/donnie/adapter/Walle.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ public WrapperAdapter getWrapperAdapter() {
return wrapperAdapter;
}

public void addTo(RecyclerView recyclerView) {
recyclerView.setAdapter(wrapperAdapter);
}

private class WrapperAdapter extends RecyclerView.Adapter<ViewHolder> {

private static final int VIEW_TYPE_EMPTY = 1;
Expand Down

0 comments on commit 5d796b0

Please sign in to comment.