AbsPage.java
2.95 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
/*
* Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
*/
package com.wd.display.comp.layoutdata;
import java.util.ArrayList;
import java.util.List;
import androidx.fragment.app.Fragment;
import com.people.component.comp.parser.AbsSectionParser;
public abstract class AbsPage extends AbsLayout {
private AbsSectionParser sectionParser;
private ILayoutPresenter layoutPresenter;
/**
* 页面的楼层数据集合
*/
private List<AbsGroup> groups;
/**
* 组件所在的楼层在groups中的索引值(记录的楼层可支持翻页)
*/
private int currentGroupIndex = 0;
private AbsGroup specialGroup;
private Fragment mFragment;
public AbsSectionParser getSectionParser() {
return sectionParser;
}
public void setSectionParser(AbsSectionParser sectionParser) {
this.sectionParser = sectionParser;
}
public int getGroupIndex() {
return currentGroupIndex;
}
public void setGroupIndex(int groupIndex) {
this.currentGroupIndex = groupIndex;
}
@Override
public ILayoutPresenter getLayoutPresenter() {
return layoutPresenter;
}
public void setLayoutPresenter(ILayoutPresenter layoutPresenter) {
this.layoutPresenter = layoutPresenter;
}
/**
* removeLayoutPresenter
*/
public void removeLayoutPresenter() {
this.layoutPresenter = null;
}
/**
* getGroups
*
* @return AbsGroup
*/
public List<AbsGroup> getGroups() {
if (groups == null) {
groups = new ArrayList<AbsGroup>();
}
return groups;
}
public void setGroups(List<AbsGroup> groups) {
this.groups = groups;
}
/**
* removeGroup
*
* @param index
*/
public void removeGroup(int index) {
groups.remove(index);
getLayoutPresenter().onRefreshPageSuccess();
}
public Fragment getFragment() {
return mFragment;
}
public void setFragment(Fragment fragment) {
this.mFragment = fragment;
}
public AbsGroup getSpecialGroup() {
return specialGroup;
}
public void setSpecialGroup(AbsGroup specialGroup) {
this.specialGroup = specialGroup;
}
/**
* 检测当前使用的楼层对象数据是在groups中最后位置(通过索引值对比)
*
* @return true:表示在最后的位置
*/
public boolean checkGroupDataIsLastData() {
int groupSize = groups.size();
if (groupSize > 1) {
// 索引值从0开始计算
int temp = groupSize - 1;
if (currentGroupIndex == temp) {
return true;
} else {
return false;
}
} else {
return true;
}
}
/**
* 设置新的楼层参数
*/
public void setNewGroupParameter() {
currentGroupIndex = currentGroupIndex + 1;
}
}