-
Notifications
You must be signed in to change notification settings - Fork 239
Expand file tree
/
Copy pathAdaptiveTableAdapter.java
More file actions
209 lines (181 loc) · 7.49 KB
/
AdaptiveTableAdapter.java
File metadata and controls
209 lines (181 loc) · 7.49 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package com.cleveroad.adaptivetablelayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.ViewGroup;
/**
* Base AdaptiveTableAdapter Interface for AdaptiveTableLayout's adapter.
*
* @param <VH> Implementation of ViewHolder {@link ViewHolder}
*/
public interface AdaptiveTableAdapter<VH extends ViewHolder> extends AdaptiveTableDataSetObserver {
/**
* @return Item click listener
*/
@Nullable
OnItemClickListener getOnItemClickListener();
/**
* Set new item click listener
*
* @param onItemClickListener new item click listener
*/
void setOnItemClickListener(@Nullable OnItemClickListener onItemClickListener);
/**
* @return Item long click listener
*/
@Nullable
OnItemLongClickListener getOnItemLongClickListener();
/**
* Set new item long click listener
*
* @param onItemLongClickListener new item long click listener
*/
void setOnItemLongClickListener(@Nullable OnItemLongClickListener onItemLongClickListener);
/**
* Register an observer that is called when changes happen to the data used
* by this adapter.
*
* @param observer the object that gets notified when the data set changes.
*/
void registerDataSetObserver(@NonNull AdaptiveTableDataSetObserver observer);
/**
* Unregister an observer that has previously been registered with this
* adapter via {@link #registerDataSetObserver}.
*
* @param observer the object to unregister.
*/
void unregisterDataSetObserver(@NonNull AdaptiveTableDataSetObserver observer);
/**
* How many rows are in the data table represented by this Adapter.
*
* @return count of rows with header
*/
int getRowCount();
/**
* How many columns are in the data table represented by this Adapter.
*
* @return count of columns with header
*/
int getColumnCount();
/**
* Called when {@link AdaptiveTableLayout} needs a new ITEM {@link ViewHolder}
*
* @param parent The ViewGroup into which the new View will be added after it is bound to
* an adapter position.
* @return A new ViewHolder that holds a View of the given view type.
* @see #onBindViewHolder(ViewHolder, int, int)
*/
@NonNull
VH onCreateItemViewHolder(@NonNull ViewGroup parent);
/**
* Called when {@link AdaptiveTableLayout} needs a new COLUMN HEADER ITEM {@link ViewHolder}
*
* @param parent The ViewGroup into which the new View will be added after it is bound to
* an adapter position.
* @return A new ViewHolder that holds a View of the given view type.
* @see #onBindHeaderColumnViewHolder(ViewHolder, int)
*/
@NonNull
VH onCreateColumnHeaderViewHolder(@NonNull ViewGroup parent);
/**
* Called when {@link AdaptiveTableLayout} needs a new ROW HEADER ITEM {@link ViewHolder}
*
* @param parent The ViewGroup into which the new View will be added after it is bound to
* an adapter position.
* @return A new ViewHolder that holds a View of the given view type.
* @see #onBindHeaderRowViewHolder(ViewHolder, int)
*/
@NonNull
VH onCreateRowHeaderViewHolder(@NonNull ViewGroup parent);
/**
* Called when {@link AdaptiveTableLayout} needs a new LEFT TOP HEADER ITEM {@link ViewHolder}
*
* @param parent The ViewGroup into which the new View will be added after it is bound to
* an adapter position.
* @return A new ViewHolder that holds a View of the given view type.
* @see #onBindLeftTopHeaderViewHolder(ViewHolder)
*/
@NonNull
VH onCreateLeftTopHeaderViewHolder(@NonNull ViewGroup parent);
/**
* Called by {@link AdaptiveTableLayout} to display the data at the specified position. This method should
* update the contents of the {@link ViewHolder#getItemView()} to reflect the item at the given
* position.
*
* @param viewHolder The ITEM {@link ViewHolder} which should be updated to represent the contents of the
* item at the given position in the data set.
* @param row The row index of the item within the adapter's data set.
* @param column The column index of the item within the adapter's data set.
*/
void onBindViewHolder(@NonNull VH viewHolder, int row, int column);
/**
* Called by {@link AdaptiveTableLayout} to display the data at the specified position. This method should
* update the contents of the {@link ViewHolder#getItemView()} to reflect the item at the given
* position.
*
* @param viewHolder The COLUMN HEADER ITEM {@link ViewHolder} which should be updated to represent the contents of the
* item at the given position in the data set.
* @param column The column index of the item within the adapter's data set.
*/
void onBindHeaderColumnViewHolder(@NonNull VH viewHolder, int column);
/**
* Called by {@link AdaptiveTableLayout} to display the data at the specified position. This method should
* update the contents of the {@link ViewHolder#getItemView()} to reflect the item at the given
* position.
*
* @param viewHolder The ROW HEADER ITEM {@link ViewHolder} which should be updated to represent the contents of the
* item at the given position in the data set.
* @param row The row index of the item within the adapter's data set.
*/
void onBindHeaderRowViewHolder(@NonNull VH viewHolder, int row);
/**
* Called by {@link AdaptiveTableLayout} to display the data at the specified position. This method should
* update the contents of the {@link ViewHolder#getItemView()} to reflect the item at the given
* position.
*
* @param viewHolder The TOP LEFT HEADER ITEM{@link ViewHolder} which should be updated to represent the contents of the
* item at the given position in the data set.
*/
void onBindLeftTopHeaderViewHolder(@NonNull VH viewHolder);
/**
* Return the width of the column.
*
* @param column the column index.
* @return The width of the column, in pixels.
*/
int getColumnWidth(int column);
/**
* Return the header column height.
*
* @return The header height of the columns, in pixels.
*/
int getHeaderColumnHeight();
/**
* Return the height of the row.
*
* @param row the row index.
* @return The height of the row, in pixels.
*/
int getRowHeight(int row);
/**
* Return the header row width.
*
* @return The header width of the rows, in pixels.
*/
int getHeaderRowWidth();
/**
* Called when a view created by this adapter has been recycled.
* <p>
* <p>A view is recycled when a {@link AdaptiveTableLayout} decides that it no longer
* needs to be attached. This can be because it has
* fallen out of visibility or a set of cached views represented by views still
* attached to the parent RecyclerView. If an item view has large or expensive data
* bound to it such as large bitmaps, this may be a good place to release those
* resources.</p>
* <p>
* {@link AdaptiveTableLayout} calls this method right before clearing ViewHolder's internal data and
* sending it to Recycler.
*
* @param viewHolder The {@link ViewHolder} for the view being recycled
*/
void onViewHolderRecycled(@NonNull VH viewHolder);
}