android时光轴(RecycleView 多种type实现),包含child的滑动效果SwipeDragLayout,2.0版本sample项目使用了Databinding 来操作数据
- SwipeDragLayout使用ViewDragHelper来进行滑动操作,代码少,易理解,核心代码不过150行
- 使用了保留一个静态类的方法解决复用问题,并在
onDetachedFromWindow方法中进行关闭操作 - 轻松实现IOS QQ消息列表的回弹效果(有多轻松:见SwipeDragLayout 第100行)
- sample使用了DataBinding和RecyclerView 进行了多类型的绑定,对于了解和使用DataBinding大有益处,添加多种Type更是十分简单,再也不用extends RecyclerView.Adapter了
###自定义属性
//滑动监听
public interface SwipeListener {
/**
* 拖动中,可根据offset 进行其他动画
* @param layout
* @param offset 偏移量
*/
void onUpdate(SwipeDragLayout layout, float offset);
/**
* 展开完成
* @param layout
*/
void onOpened(SwipeDragLayout layout);
/**
* 关闭完成
* @param layout
*/
void onClosed(SwipeDragLayout layout);
/**
* 点击内容layout {@link #onFinishInflate()}
* @param layout
*/
void onClick(SwipeDragLayout layout);
}
