-
Notifications
You must be signed in to change notification settings - Fork 22
/
BaseExpandableObservable.java
91 lines (73 loc) · 2.66 KB
/
BaseExpandableObservable.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package com.zaihuishou.databinding.expandablerecycleradapter.observable;
import android.databinding.BaseObservable;
import android.databinding.ObservableArrayList;
import android.databinding.ObservableBoolean;
import com.zaihuishou.databinding.expandablerecycleradapter.viewholder.BindingViewHolder;
import java.util.List;
/**
* 创建者: zhiqiang(谭志强)
* 创建时间 16-8-3.
* 作者邮箱 tanzhiqiang@todayoffice.cn
* 描述:
*/
public abstract class BaseExpandableObservable extends BaseObservable {
/**
* item contain child list
*/
public ObservableArrayList<Object> mChildList;
/**
* item is expanded
*/
public ObservableBoolean isExpand;
protected ItemListExpandCollapseListener mItemListExpandCollapseListener;
public BaseExpandableObservable() {
mChildList = new ObservableArrayList<>();
isExpand = new ObservableBoolean(false);
}
public ObservableArrayList<Object> getChildList() {
return mChildList;
}
public void setChildList(List<Object> childList) {
mChildList.addAll(childList);
}
public boolean getIsExpand() {
return isExpand.get();
}
public void setIsExpand(boolean expand) {
this.isExpand.set(expand);
}
public ItemListExpandCollapseListener getItemListExpandCollapseListener() {
return mItemListExpandCollapseListener;
}
public void setItemListExpandCollapseListener(ItemListExpandCollapseListener itemListExpandCollapseListener) {
mItemListExpandCollapseListener = itemListExpandCollapseListener;
}
/**
* implementations to be notified of expand/collapse state change events.
*/
public interface ItemListExpandCollapseListener {
/**
* Called when a list item is expanded.
*
* @param baseExpandableObservable The item in the list being expanded
*/
void onItemListExpanded(BaseExpandableObservable baseExpandableObservable);
/**
* Called when a list item is collapsed.
*
* @param baseExpandableObservable The item in the list being collapsed
*/
void onItemListCollapsed(BaseExpandableObservable baseExpandableObservable);
}
/**
* Callback triggered when expansion state is changed, but not during
* initialization.
* <p>
* Useful for implementing animations on expansion.
*
* @param expanded true if view is expanded before expansion is toggled,
* false if not
* @param index the operate item position
*/
public abstract void onExpansionToggled(BindingViewHolder bindingViewHolder, int index, boolean expanded);
}