-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
重写展开Adapter,添加更多的辅助方法,以及更新IMultiItem接口,添加IMultiItem与IExpandable的实现抽象类
- Loading branch information
Showing
19 changed files
with
1,168 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
adapter/src/main/java/xyz/zpayh/adapter/DefaultExpandable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package xyz.zpayh.adapter; | ||
|
||
import android.support.annotation.LayoutRes; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* 文 件 名: DefaultExpandable | ||
* 创 建 人: 陈志鹏 | ||
* 创建日期: 2017/01/21 14:38 | ||
* 邮 箱: ch_zh_p@qq.com | ||
* 修改时间: | ||
* 修改备注: | ||
* 一个默认的实现{@link IExpandable}大部分方法的抽象类,一般继承实现此抽象类即可。 | ||
*/ | ||
|
||
public abstract class DefaultExpandable<T> implements IExpandable { | ||
|
||
protected final List<IMultiItem> mSubData; | ||
|
||
private int mSpanSize; | ||
|
||
private boolean mExpandable; | ||
|
||
@LayoutRes | ||
private final int mLayoutRes; | ||
|
||
protected T mData; | ||
|
||
public DefaultExpandable(@LayoutRes int layoutRes) { | ||
this(layoutRes, null); | ||
} | ||
|
||
public DefaultExpandable(@LayoutRes int layoutRes, T data){ | ||
this(layoutRes, data, 1); | ||
} | ||
|
||
public DefaultExpandable(@LayoutRes int layoutRes,T data, int spanSize){ | ||
mLayoutRes = layoutRes; | ||
mData = data; | ||
mSpanSize = spanSize; | ||
mSubData = new ArrayList<>(); | ||
mExpandable = false; | ||
} | ||
|
||
public T getData() { | ||
return mData; | ||
} | ||
|
||
public void setData(T mData) { | ||
this.mData = mData; | ||
} | ||
|
||
public void setSubData(List<IMultiItem> subData){ | ||
mSubData.clear(); | ||
if (subData != null){ | ||
mSubData.addAll(subData); | ||
} | ||
} | ||
|
||
public void addSubData(List<IMultiItem> subData){ | ||
if (subData != null){ | ||
mSubData.addAll(subData); | ||
} | ||
} | ||
|
||
public void addSubData(IMultiItem subData){ | ||
if (subData != null){ | ||
mSubData.add(subData); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isExpandable() { | ||
return mExpandable; | ||
} | ||
|
||
@Override | ||
public void setExpandable(boolean expandable) { | ||
mExpandable = expandable; | ||
} | ||
|
||
@Override | ||
public List<IMultiItem> getSubItems() { | ||
return mSubData; | ||
} | ||
|
||
@Override | ||
public int getLayoutRes() { | ||
return mLayoutRes; | ||
} | ||
|
||
@Override | ||
public int getSpanSize() { | ||
return mSpanSize; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
adapter/src/main/java/xyz/zpayh/adapter/DefaultMultiItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package xyz.zpayh.adapter; | ||
|
||
import android.support.annotation.LayoutRes; | ||
|
||
/** | ||
* 文 件 名: DefaultMultiItem | ||
* 创 建 人: 陈志鹏 | ||
* 创建日期: 2017/01/21 14:38 | ||
* 邮 箱: ch_zh_p@qq.com | ||
* 修改时间: | ||
* 修改备注: | ||
* 一个默认的实现{@link IMultiItem}大部分方法的抽象类,一般继承实现此抽象类即可。 | ||
*/ | ||
|
||
|
||
public abstract class DefaultMultiItem<T> implements IMultiItem { | ||
|
||
@LayoutRes | ||
private final int mLayoutRes; | ||
|
||
private int mSpanSize; | ||
|
||
protected T mData; | ||
|
||
public DefaultMultiItem(@LayoutRes int layoutRes) { | ||
this(layoutRes,null); | ||
} | ||
|
||
public DefaultMultiItem(@LayoutRes int layoutRes,T data) { | ||
this(layoutRes, data, 1); | ||
} | ||
|
||
public DefaultMultiItem(@LayoutRes int layoutRes,T data, int spanSize) { | ||
this.mLayoutRes = layoutRes; | ||
this.mData = data; | ||
this.mSpanSize = spanSize; | ||
} | ||
|
||
public T getData() { | ||
return mData; | ||
} | ||
|
||
public void setData(T mData) { | ||
this.mData = mData; | ||
} | ||
|
||
@Override | ||
public int getLayoutRes() { | ||
return mLayoutRes; | ||
} | ||
|
||
@Override | ||
public int getSpanSize() { | ||
return mSpanSize; | ||
} | ||
} |
Oops, something went wrong.