Skip to content

Commit

Permalink
修复子item的响应长按事件,改善部分代码
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilBT committed Feb 16, 2017
1 parent 80faa16 commit 5fe54bb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ allprojects {
**Step 2.** Add the dependency
``` gradle
dependencies {
compile 'com.github.EvilBT:SherlockAdapter:v1.0.3'
compile 'com.github.EvilBT:SherlockAdapter:v1.0.4'
}
```

Expand Down
4 changes: 2 additions & 2 deletions adapter/src/main/java/xyz/zpayh/adapter/BaseAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public abstract class BaseAdapter<T> extends RecyclerView.Adapter<BaseViewHolder
* 设置新数据,会清除掉原有数据,并有可能重置加载更多状态
* @param data 数据集合
*/
public void setData(@Nullable List<T> data){
public void setData(@Nullable List<? extends T> data){
mData.clear();
if (data != null){
mData.addAll(data);
Expand Down Expand Up @@ -123,7 +123,7 @@ public void addData(T data){
* 添加新数据,并有可能重置加载更多状态
* @param data 数据集合
*/
public void addData(List<T> data){
public void addData(List<? extends T> data){
if (data == null){
return;
}
Expand Down
4 changes: 2 additions & 2 deletions adapter/src/main/java/xyz/zpayh/adapter/BaseViewHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ public BaseViewHolder setLongClickable(@IdRes int id, boolean longClickable){
View view = find(id);
if (view != null){
if (longClickable){
view.setOnClickListener(mOnClickListener);
view.setOnLongClickListener(mOnLongClickListener);
}else{
view.setOnClickListener(null);
view.setOnLongClickListener(null);
}
}
return this;
Expand Down
12 changes: 6 additions & 6 deletions adapter/src/main/java/xyz/zpayh/adapter/ExpandableAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public abstract class ExpandableAdapter extends RecyclerView.Adapter<BaseViewHol
* 设置新数据,会清除掉原有数据,并有可能重置加载更多状态
* @param data 数据集合
*/
public void setData(@Nullable List<IMultiItem> data){
public void setData(@Nullable List<? extends IMultiItem> data){
mData.clear();
if (data != null){
mData.addAll(data);
Expand Down Expand Up @@ -130,7 +130,7 @@ public void addData(IMultiItem data){
* 添加新数据,并有可能重置加载更多状态
* @param data 数据集合
*/
public void addData(List<IMultiItem> data){
public void addData(List<? extends IMultiItem> data){
if (data == null){
return;
}
Expand All @@ -157,7 +157,7 @@ public void removeData(IMultiItem data){
}
}

private int findData(List<IMultiItem> list, IMultiItem data) {
private int findData(List<? extends IMultiItem> list, IMultiItem data) {

int showSubSize = 0;
for (int i = 0; i < list.size(); i++) {
Expand Down Expand Up @@ -203,7 +203,7 @@ public void removeData(int adapterPosition){

}

private int removeData(List<IMultiItem> list, int index){
private int removeData(List<? extends IMultiItem> list, int index){
for (IMultiItem item : list) {
if (index == 0){
int removeSize = 1;
Expand Down Expand Up @@ -470,7 +470,7 @@ private int getDataSize() {
return getShowSize(mData);
}

private int getShowSize(List<IMultiItem> data) {
private int getShowSize(List<? extends IMultiItem> data) {
if (data == null || data.isEmpty()){
return 0;
}
Expand All @@ -484,7 +484,7 @@ private int getShowSize(List<IMultiItem> data) {
return size;
}

private IMultiItem getData(List<IMultiItem> list, int index){
private IMultiItem getData(List<? extends IMultiItem> list, int index){

for (IMultiItem item : list) {
if (index == 0){
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/xyz/zpayh/myadapter/data/Text.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public int getLayoutRes() {

@Override
public void convert(BaseViewHolder holder) {

holder.setText(R.id.text,mText);
}

@Override
Expand Down

0 comments on commit 5fe54bb

Please sign in to comment.