groupChildren = new ArrayList<>();
176 | groupChildren.add(new GroupChild("update gc1"));
177 | groupChildren.add(new GroupChild("gc1"));
178 | mAdapter.setGroupChild(0, groupChildren);
179 | mAdapter.setBottom(new Footer("botoom back"));
180 |
181 | }
182 | }, 10000);
183 |
184 | mHandler.postDelayed(new Runnable() {
185 | @Override
186 | public void run() {
187 | mAdapter.clearFooter();
188 | mAdapter.setBottom(new Footer("botoom 111 back"));
189 | }
190 | }, 15000);
191 | }
192 |
193 | private void test() {
194 | L.GL.d(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss sss").format(System.currentTimeMillis()));
195 | for (int i = 0; i < 5; i++) {
196 | mAdapter.addHeader(new Header("header " + i));
197 | }
198 | for (int i = 0; i < 5; i++) {
199 | mAdapter.addChild(new Child("child " + i));
200 | }
201 |
202 | for (int i = 0; i < 100; i++) {
203 | int groupPos = mAdapter.addGroup(new Group("group " + i));
204 | for (int j = 0; j < 100; j++) {
205 | mAdapter.addGroupChild(groupPos, new GroupChild("groupchild " + i + "," + j));
206 | }
207 | }
208 |
209 | for (int i = 0; i < 5; i++) {
210 | mAdapter.addFooter(new Footer("footer " + i));
211 | }
212 |
213 | mAdapter.addHeader(0, new Header("random header 0"));
214 | mAdapter.addHeader(2, new Header("random header 2"));
215 | mAdapter.addHeader(mAdapter.getHeaderCount(), new Header("random header last"));
216 |
217 | mAdapter.addChild(0, new Child("random child 0"));
218 | mAdapter.addChild(2, new Child("random child 2"));
219 | mAdapter.addChild(mAdapter.getChildCount(), new Child("random child last"));
220 |
221 | int gp;
222 | gp = mAdapter.addGroup(0, new Group("random group 0"));
223 | for (int i = 0; i < 2; i++) {
224 | mAdapter.addGroupChild(gp, new GroupChild("random group 0, " + i));
225 | }
226 | gp = mAdapter.addGroup(3, new Group("random group 3"));
227 | for (int i = 0; i < 10; i++) {
228 | mAdapter.addGroupChild(gp, new GroupChild("random group 3, " + i));
229 | }
230 | gp = mAdapter.addGroup(mAdapter.getGroupCount(), new Group("random group last"));
231 | for (int i = 0; i < 5; i++) {
232 | mAdapter.addGroupChild(gp, new GroupChild("random group last, " + i));
233 | }
234 |
235 | mAdapter.addFooter(0, new Footer("random footer 0"));
236 | mAdapter.addFooter(1, new Footer("random footer 1"));
237 | mAdapter.addFooter(new Footer("random footer last"));
238 | L.GL.d(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss sss").format(System.currentTimeMillis()));
239 |
240 | mHandler.postDelayed(new Runnable() {
241 | @Override
242 | public void run() {
243 | mAdapter.clearChild(5);
244 | }
245 | }, 300);
246 | mHandler.postDelayed(new Runnable() {
247 | @Override
248 | public void run() {
249 | mAdapter.removeFooter(5, mAdapter.getFooterCount() - 6);
250 | }
251 | }, 320);
252 | mHandler.postDelayed(new Runnable() {
253 | @Override
254 | public void run() {
255 | mAdapter.clearHeader(5);
256 | }
257 | }, 310);
258 | /*mHandler.postDelayed(new Runnable() {
259 | @Override
260 | public void run() {
261 | mAdapter.removeAllGroup();
262 | mAdapter.clearHeader();
263 | mAdapter.clearChild();
264 | mAdapter.clearFooter();
265 | }
266 | }, 2500);*/
267 | mHandler.postDelayed(new Runnable() {
268 | @Override
269 | public void run() {
270 | mAdapter.clearHeader(5);
271 | mAdapter.clearChild(5);
272 | mAdapter.removeAllGroup();
273 | mAdapter.clearFooter(5);
274 | mAdapter.addHeader(new Header1("header1 test"));
275 | L.GL.d("last header position by viewType:%d",
276 | mAdapter.getLastHeaderPositionByViewType(Adapter.Type.HEADER1));
277 | }
278 | }, 15500);
279 | }
280 |
281 | /*private class InnerItemTouchHelper extends ItemTouchHelper {
282 |
283 | *//**
284 | * Creates an ItemTouchHelper that will work with the given Callback.
285 | *
286 | * You can attach ItemTouchHelper to a RecyclerView via
287 | * {@link #attachToRecyclerView(RecyclerView)}. Upon attaching, it will add an item decoration,
288 | * an onItemTouchListener and a Child attach / detach listener to the RecyclerView.
289 | *
290 | * @param callback The Callback which controls the behavior of this touch helper.
291 | *//*
292 | public InnerItemTouchHelper(Callback callback) {
293 | super(callback);
294 | }
295 | }
296 |
297 | private class InnerItemTouchCallback extends ItemTouchHelper.Callback {
298 |
299 | @Override
300 | public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
301 | int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
302 | int swipeFlags = 0;
303 | int flags = makeMovementFlags(dragFlags, swipeFlags);
304 | return flags;
305 | }
306 |
307 | @Override
308 | public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder
309 | target) {
310 | mAdapter.swapItem(viewHolder.getAdapterPosition(), target.getAdapterPosition());
311 | return true;
312 | }
313 |
314 | @Override
315 | public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
316 |
317 | }
318 | }*/
319 | }
320 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/qbw/expandableadapter/entity/BaseEntity.java:
--------------------------------------------------------------------------------
1 | package com.example.qbw.expandableadapter.entity;
2 |
3 | /**
4 | * @author QBW
5 | * @createtime 2016/04/05 10:02
6 | */
7 |
8 |
9 | public class BaseEntity {
10 | public String text;
11 |
12 | public BaseEntity(String text) {
13 | this.text = text;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/qbw/expandableadapter/entity/Child.java:
--------------------------------------------------------------------------------
1 | package com.example.qbw.expandableadapter.entity;
2 |
3 | /**
4 | * @author QBW
5 | * @createtime 2016/04/05 11:25
6 | */
7 |
8 |
9 | public class Child extends BaseEntity {
10 | public Child(String text) {
11 | super(text);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/qbw/expandableadapter/entity/Footer.java:
--------------------------------------------------------------------------------
1 | package com.example.qbw.expandableadapter.entity;
2 |
3 | /**
4 | * @author QBW
5 | * @createtime 2016/04/05 11:25
6 | */
7 |
8 |
9 | public class Footer extends BaseEntity {
10 | public Footer(String text) {
11 | super(text);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/qbw/expandableadapter/entity/Group.java:
--------------------------------------------------------------------------------
1 | package com.example.qbw.expandableadapter.entity;
2 |
3 | /**
4 | * @author QBW
5 | * @createtime 2016/04/05 11:26
6 | */
7 |
8 |
9 | public class Group extends BaseEntity {
10 | public Group(String text) {
11 | super(text);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/qbw/expandableadapter/entity/Group1.java:
--------------------------------------------------------------------------------
1 | package com.example.qbw.expandableadapter.entity;
2 |
3 | /**
4 | * Created by apple on 16/9/8.
5 | */
6 | public class Group1 extends BaseEntity {
7 |
8 | public Group1(String text) {
9 | super(text);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/qbw/expandableadapter/entity/GroupChild.java:
--------------------------------------------------------------------------------
1 | package com.example.qbw.expandableadapter.entity;
2 |
3 | /**
4 | * @author QBW
5 | * @createtime 2016/04/05 11:26
6 | */
7 |
8 |
9 | public class GroupChild extends BaseEntity {
10 | public GroupChild(String text) {
11 | super(text);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/qbw/expandableadapter/entity/Header.java:
--------------------------------------------------------------------------------
1 | package com.example.qbw.expandableadapter.entity;
2 |
3 | /**
4 | * @author QBW
5 | * @createtime 2016/04/05 11:25
6 | */
7 |
8 |
9 | public class Header extends BaseEntity {
10 | public Header(String text) {
11 | super(text);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/qbw/expandableadapter/entity/Header1.java:
--------------------------------------------------------------------------------
1 | package com.example.qbw.expandableadapter.entity;
2 |
3 | /**
4 | * Author:qbw on 2018/12/7 12:24
5 | */
6 | public class Header1 extends BaseEntity {
7 | public Header1(String text) {
8 | super(text);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/qbw/expandableadapter/holder/FooterViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.example.qbw.expandableadapter.holder;
2 |
3 | import android.content.Context;
4 | import android.view.ViewGroup;
5 | import android.widget.TextView;
6 |
7 | import com.example.qbw.expandableadapter.R;
8 | import com.example.qbw.expandableadapter.entity.Footer;
9 | import com.example.qbw.expandableadapter.BaseViewHolder;
10 |
11 | /**
12 | * @author QBW
13 | * @createtime 2016/04/05 11:29
14 | */
15 |
16 |
17 | public class FooterViewHolder extends BaseViewHolder