Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ChadCym committed Jun 22, 2016
2 parents 2af2d1d + 6f68696 commit 7e8c954
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 36 deletions.
12 changes: 9 additions & 3 deletions README-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
- **设置空布局(比Listview的setEmptyView还要好用!)**
- **添加拖拽item**

![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/demo.gif)
#如何使用它?
先在 build.gradle 的 repositories 添加:
```
Expand All @@ -41,7 +40,7 @@
```

#如何使用它来创建Adapter?
![demo](http://upload-images.jianshu.io/upload_images/972352-54bd17d3680a4cf9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/item_view.png)
```
public class QuickAdapter extends BaseQuickAdapter<Status> {
public QuickAdapter() {
Expand All @@ -60,6 +59,7 @@ public class QuickAdapter extends BaseQuickAdapter<Status> {
}
```
#如何添加item点击、长按事件
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/chlid_click.gif)
```
mQuickAdapter.setOnRecyclerViewItemClickListener();
mQuickAdapter.setOnRecyclerViewItemLongClickListener();
Expand Down Expand Up @@ -92,7 +92,7 @@ mQuickAdapter.setOnRecyclerViewItemChildClickListener(new BaseQuickAdapter.OnRec
});
```
#如何使用它添加动画?

![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/animation.gif)
```
// 一行代码搞定(默认为渐显效果)
quickAdapter.openLoadAnimation();
Expand All @@ -116,11 +116,13 @@ quickAdapter.openLoadAnimation(new BaseAnimation() {
});
```
#使用它添加头部添加尾部
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/header_footer.gif)
```
mQuickAdapter.addHeaderView(getView());
mQuickAdapter.addFooterView(getView());
```
#使用它加载更多
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/load_more.gif)
```
mQuickAdapter.openLoadMore(PAGE_SIZE, true);
mQuickAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
Expand All @@ -146,6 +148,7 @@ mQuickAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener
mQuickAdapter.setLoadingView(customView);
```
#使用分组
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/section_headers.gif)
```
public class SectionAdapter extends BaseSectionQuickAdapter<MySection> {
public SectionAdapter(int layoutResId, int sectionHeadResId, List data) {
Expand All @@ -168,6 +171,7 @@ public class SectionAdapter extends BaseSectionQuickAdapter<MySection> {
}
```
#如何添加多种类型item?
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/multiple_item.gif)
```
public class MultipleItemQuickAdapter extends BaseMultiItemQuickAdapter<MultipleItem> {
Expand All @@ -192,10 +196,12 @@ public class MultipleItemQuickAdapter extends BaseMultiItemQuickAdapter<Multiple
}
```
#使用setEmptyView
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/empty_view.gif)
```
mQuickAdapter.setEmptyView(getView());
```
#使用DragItem
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/drag_item.gif)
```java
OnItemDragListener listener = new OnItemDragListener() {
@Override
Expand Down
71 changes: 38 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ Please feel free to use this.(Love can be a **Star**)
[![Get it on Google Play](https://developer.android.com/images/brand/en_generic_rgb_wo_60.png)](https://play.google.com/store/apps/details?id=com.chad.baserecyclerviewadapterhelper)
#Features([download apk](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/raw/master/demo_res/demo.apk)
- **Reduce lot of code.easily create RecyclerAdapter**
- **add item click and add item long click**
- **add item click and add item long click and item chlid click**
- **easily add RecyclerAdapter animations**
- **add HeadView and add FooterView**
- **add The drop-down refresh, load more**
- **set custom loading view**
- **easily create section headers**
- **custom item view type**
- **add setEmptyView methods**
- **add item chlid click**
- **add drag item**

![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/demo.gif)
# Get it
Add it in your root build.gradle at the end of repositories:
```groovy
Expand All @@ -38,7 +36,7 @@ dependencies {
```

#Use it create RecyclerAdapter

![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/item_view.png)
```java
public class QuickAdapter extends BaseQuickAdapter<Status> {
public QuickAdapter() {
Expand All @@ -56,7 +54,8 @@ public class QuickAdapter extends BaseQuickAdapter<Status> {
}
}
```
#Use it item click
#Use it item click and item chlid click
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/chlid_click.gif)
```java
mQuickAdapter.setOnRecyclerViewItemClickListener(new BaseQuickAdapter.OnRecyclerViewItemClickListener() {
@Override
Expand All @@ -65,8 +64,36 @@ mQuickAdapter.setOnRecyclerViewItemClickListener(new BaseQuickAdapter.OnRecycler
}
});
```
#Use it item chlid click
Adapter
```java
protected void convert(BaseViewHolder helper, Status item) {
helper.setOnClickListener(R.id.tweetAvatar, new OnItemChildClickListener())
.setOnClickListener(R.id.tweetName, new OnItemChildClickListener());
}
```
Activity
```java
mQuickAdapter.setOnRecyclerViewItemChildClickListener(new BaseQuickAdapter.OnRecyclerViewItemChildClickListener() {
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
String content = null;
Status status = (Status) adapter.getItem(position);
switch (view.getId()) {
case R.id.tweetAvatar:
content = "img:" + status.getUserAvatar();
break;
case R.id.tweetName:
content = "name:" + status.getUserName();
break;
}
Toast.makeText(AnimationUseActivity.this, content, Toast.LENGTH_LONG).show();
}
});
```

#Use it add adaptar Animation
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/animation.gif)
```java
// Turn animation
quickAdapter.openLoadAnimation();
Expand All @@ -90,6 +117,7 @@ quickAdapter.openLoadAnimation(new BaseAnimation() {
});
```
#Use it custom item view type
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/multiple_item.gif)
```java
public class MultipleItemQuickAdapter extends BaseMultiItemQuickAdapter<MultipleItem> {

Expand All @@ -114,11 +142,13 @@ public class MultipleItemQuickAdapter extends BaseMultiItemQuickAdapter<Multiple
}
```
#Use it add header and footer
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/header_footer.gif)
```java
mQuickAdapter.addHeaderView(getView());
mQuickAdapter.addFooterView(getView());
```
#Use it load more
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/load_more.gif)
setOnLoadMoreListener
```java
mQuickAdapter.openLoadMore(PAGE_SIZE, true);
Expand All @@ -145,6 +175,7 @@ public void onLoadMoreRequested() {
mQuickAdapter.setLoadingView(customView);
```
#Use it create section headers
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/section_headers.gif)
```java
public class SectionAdapter extends BaseSectionQuickAdapter<MySection> {
public SectionAdapter(int layoutResId, int sectionHeadResId, List data) {
Expand All @@ -167,38 +198,12 @@ public class SectionAdapter extends BaseSectionQuickAdapter<MySection> {
}
```
#Use it setEmptyView
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/empty_view.gif)
```java
mQuickAdapter.setEmptyView(getView());
```
#Use it item chlid click
Adapter
```java
protected void convert(BaseViewHolder helper, Status item) {
helper.setOnClickListener(R.id.tweetAvatar, new OnItemChildClickListener())
.setOnClickListener(R.id.tweetName, new OnItemChildClickListener());
}
```
Activity
```java
mQuickAdapter.setOnRecyclerViewItemChildClickListener(new BaseQuickAdapter.OnRecyclerViewItemChildClickListener() {
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
String content = null;
Status status = (Status) adapter.getItem(position);
switch (view.getId()) {
case R.id.tweetAvatar:
content = "img:" + status.getUserAvatar();
break;
case R.id.tweetName:
content = "name:" + status.getUserName();
break;
}
Toast.makeText(AnimationUseActivity.this, content, Toast.LENGTH_LONG).show();
}
});
```

#Use it drag item
![demo](https://github.com/CymChad/BaseRecyclerViewAdapterHelper/blob/master/demo_res/drag_item.gif)
```java
OnItemDragListener listener = new OnItemDragListener() {
@Override
Expand Down

0 comments on commit 7e8c954

Please sign in to comment.