|
@@ -4,11 +4,14 @@ import android.support.annotation.RestrictTo;
|
4
|
4
|
import android.view.View;
|
5
|
5
|
import android.view.ViewGroup;
|
6
|
6
|
|
|
7
|
+import java.util.ArrayList;
|
|
8
|
+import java.util.List;
|
|
9
|
+
|
7
|
10
|
public class YellowBoxDelegate {
|
8
|
11
|
private ViewGroup parent;
|
9
|
|
- private View yellowBox;
|
10
|
12
|
private YellowBoxHelper yellowBoxHelper;
|
11
|
13
|
private boolean isDestroyed;
|
|
14
|
+ private ArrayList<View> yellowBoxViews = new ArrayList<>();
|
12
|
15
|
|
13
|
16
|
public YellowBoxDelegate() {
|
14
|
17
|
this.yellowBoxHelper = new YellowBoxHelper();
|
|
@@ -18,33 +21,39 @@ public class YellowBoxDelegate {
|
18
|
21
|
this.yellowBoxHelper = yellowBoxHelper;
|
19
|
22
|
}
|
20
|
23
|
|
21
|
|
- @RestrictTo(RestrictTo.Scope.TESTS)
|
22
|
|
- public ViewGroup getParent() {
|
23
|
|
- return parent;
|
24
|
|
- }
|
25
|
|
-
|
26
|
|
- @RestrictTo(RestrictTo.Scope.TESTS)
|
27
|
|
- public View getYellowBox() {
|
28
|
|
- return yellowBox;
|
29
|
|
- }
|
30
|
|
-
|
31
|
24
|
public void onChildViewAdded(View parent, View child) {
|
32
|
25
|
if (yellowBoxHelper.isYellowBox(parent, child)) {
|
33
|
|
- onYellowBoxAdded(parent, child);
|
|
26
|
+ onYellowBoxAdded(parent);
|
34
|
27
|
}
|
35
|
28
|
}
|
36
|
29
|
|
37
|
|
- protected void onYellowBoxAdded(View parent, View yellowBox) {
|
|
30
|
+ void onYellowBoxAdded(View parent) {
|
38
|
31
|
if (isDestroyed) return;
|
39
|
|
- this.yellowBox = yellowBox;
|
40
|
32
|
this.parent = (ViewGroup) parent;
|
41
|
|
- this.parent.removeView(yellowBox);
|
|
33
|
+
|
|
34
|
+ for (int i = 1; i < this.parent.getChildCount(); i++) {
|
|
35
|
+ yellowBoxViews.add(this.parent.getChildAt(i));
|
|
36
|
+ this.parent.removeView(this.parent.getChildAt(i));
|
|
37
|
+ this.parent.addView(new View(parent.getContext()), i);
|
|
38
|
+ }
|
42
|
39
|
}
|
43
|
40
|
|
44
|
41
|
public void destroy() {
|
45
|
42
|
isDestroyed = true;
|
46
|
|
- if (yellowBox != null) {
|
47
|
|
- parent.addView(yellowBox);
|
|
43
|
+ if (!yellowBoxViews.isEmpty()) {
|
|
44
|
+ for (View view : yellowBoxViews) {
|
|
45
|
+ parent.addView(view);
|
|
46
|
+ }
|
48
|
47
|
}
|
49
|
48
|
}
|
|
49
|
+
|
|
50
|
+ @RestrictTo(RestrictTo.Scope.TESTS)
|
|
51
|
+ public ViewGroup getParent() {
|
|
52
|
+ return parent;
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+ @RestrictTo(RestrictTo.Scope.TESTS)
|
|
56
|
+ public List<View> getYellowBoxes() {
|
|
57
|
+ return yellowBoxViews;
|
|
58
|
+ }
|
50
|
59
|
}
|