forked from h6ah4i/android-advancedrecyclerview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExpandableDraggableItemAdapter.java
118 lines (105 loc) · 5.54 KB
/
ExpandableDraggableItemAdapter.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
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
/*
* Copyright (C) 2015 Haruki Hasegawa
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.h6ah4i.android.widget.advrecyclerview.expandable;
import android.support.v7.widget.RecyclerView;
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
public interface ExpandableDraggableItemAdapter<GVH extends RecyclerView.ViewHolder, CVH extends RecyclerView.ViewHolder> {
/**
* Called when user is attempt to drag the group item.
*
* @param holder The group ViewHolder which is associated to item user is attempt to start dragging.
* @param groupPosition Group position.
* @param x Touched X position. Relative from the itemView's top-left.
* @param y Touched Y position. Relative from the itemView's top-left.
*
* @return Whether can start dragging.
*/
boolean onCheckGroupCanStartDrag(GVH holder, int groupPosition, int x, int y);
/**
* Called when user is attempt to drag the child item.
*
* @param holder The child ViewHolder which is associated to item user is attempt to start dragging.
* @param groupPosition Group position.
* @param childPosition Child position.
* @param x Touched X position. Relative from the itemView's top-left.
* @param y Touched Y position. Relative from the itemView's top-left.
*
* @return Whether can start dragging.
*/
boolean onCheckChildCanStartDrag(CVH holder, int groupPosition, int childPosition, int x, int y);
/**
* Called after the {@link #onCheckGroupCanStartDrag(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int)} method returned true.
*
* @param holder The ViewHolder which is associated to item user is attempt to start dragging.
* @param groupPosition Group position.
*
* @return null: no constraints (= new ItemDraggableRange(0, getGroupCount() - 1)),
* otherwise: the range specified item can be drag-sortable.
*/
ItemDraggableRange onGetGroupItemDraggableRange(GVH holder, int groupPosition);
/**
* Called after the {@link #onCheckChildCanStartDrag(android.support.v7.widget.RecyclerView.ViewHolder, int, int, int, int)} method returned true.
*
* @param holder The ViewHolder which is associated to item user is attempt to start dragging.
* @param groupPosition Group position.
* @param childPosition Child position.
*
* @return null: no constraints (= new ItemDraggableRange(0, getGroupCount() - 1)),
* otherwise: the range specified item can be drag-sortable.
*/
ItemDraggableRange onGetChildItemDraggableRange(CVH holder, int groupPosition, int childPosition);
/**
* Called when group item is moved. Should apply the move operation result to data set.
*
* @param fromGroupPosition Previous group position of the item.
* @param toGroupPosition New group position of the item.
*/
void onMoveGroupItem(int fromGroupPosition, int toGroupPosition);
/**
* Called when child item is moved. Should apply the move operation result to data set.
*
* @param fromGroupPosition Previous group position of the item.
* @param fromChildPosition Previous child position of the item.
* @param toGroupPosition New group position of the item.
* @param toChildPosition New child position of the item.
*/
void onMoveChildItem(int fromGroupPosition, int fromChildPosition, int toGroupPosition, int toChildPosition);
/**
* Called while dragging in order to check whether the dragging item can be dropped to the specified position.
*
* NOTE: This method will be called when the checkCanDrop option is enabled by {@link RecyclerViewDragDropManager#setCheckCanDropEnabled(boolean)}.
*
* @param draggingGroupPosition The position of the currently dragging group item.
* @param dropGroupPosition The position of a group item whether to check can be dropped or not.
*
* @return Whether can be dropped to the specified position.
*/
boolean onCheckGroupCanDrop(int draggingGroupPosition, int dropGroupPosition);
/**
* Called while dragging in order to check whether the dragging item can be dropped to the specified position.
*
* NOTE: This method will be called when the checkCanDrop option is enabled by {@link RecyclerViewDragDropManager#setCheckCanDropEnabled(boolean)}.
*
* @param draggingGroupPosition The group position of the currently dragging item.
* @param draggingChildPosition The child position of the currently dragging item.
* @param dropGroupPosition The group position to check whether the dragging item can be dropped or not.
* @param dropChildPosition The child position to check whether the dragging item can be dropped or not.
*
* @return Whether can be dropped to the specified position.
*/
boolean onCheckChildCanDrop(int draggingGroupPosition, int draggingChildPosition, int dropGroupPosition, int dropChildPosition);
}