Skip to content

Commit c21d989

Browse files
committed
项目 修改显示的数量!!!
1 parent 9555da6 commit c21d989

File tree

4 files changed

+131
-48
lines changed

4 files changed

+131
-48
lines changed

app/src/main/java/net/coding/program/model/TaskCountModel.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,5 @@ public class TaskCountModel {
1212
public long watchAllProcessing;//「我关注的」中「进行中的」任务数
1313
public long create;//「我创建的」任务数
1414
public long createProcessing;//「我创建的」中「进行中的」任务数
15-
1615
public int all;
17-
public int allProcessing;
18-
19-
//注: - 「我关注的」中「已完成的」数量 = watchAll - watchAllProcessing - 「
20-
public long getWatcherDoneCount() {
21-
return watchAll - watchAllProcessing;
22-
}
23-
24-
// 我创建的」中「已完成的」数量 = create - createProcessing
25-
public long getCreatorDoneCount() {
26-
return create - createProcessing;
27-
}
2816
}

app/src/main/java/net/coding/program/project/detail/ProjectTaskFragment.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ private void loadData(int index) {
153153

154154
loadAllLabels();
155155
} else {
156-
if (mMembersAll.size() <= index) {
157-
return;
158-
}
159156
TaskObject.Members members = mMembersAll.get(index);
160157

161158
//某个成员
@@ -167,7 +164,7 @@ private void loadData(int index) {
167164
private void loadAllLabels() {
168165
int cur = tabs.getCurrentPosition();
169166
if (cur != 0) {
170-
TaskObject.Members members = mMembersAll.get(cur + 1);
167+
TaskObject.Members members = mMembersAll.get(cur);
171168
getNetwork(String.format(urlSome_Label, mProjectObject.getId(), members.user_id), urlSome_Label);
172169
} else {
173170
if (statusIndex == 0) {
@@ -285,10 +282,16 @@ public void parseJson(int code, JSONObject respanse, String tag, int pos, Object
285282
showLoading(false);
286283
if (code == 0) {
287284
ProjectTaskUserCountModel item = JSONUtils.getData(respanse.getString("data"), ProjectTaskUserCountModel.class);
285+
286+
mTaskProjectCountModel.owner = item.memberDone + item.memberProcessing;
288287
mTaskProjectCountModel.ownerDone = item.memberDone;
289288
mTaskProjectCountModel.ownerProcessing = item.memberProcessing;
289+
290290
mTaskProjectCountModel.creatorDone = item.creatorDone;
291+
mTaskProjectCountModel.creator = item.creatorDone + item.creatorProcessing;
291292
mTaskProjectCountModel.creatorProcessing = item.creatorProcessing;
293+
294+
mTaskProjectCountModel.watcher = item.watcherDone + item.watcherProcessing;
292295
mTaskProjectCountModel.watcherDone = item.watcherDone;
293296
mTaskProjectCountModel.watcherProcessing = item.watcherProcessing;
294297
} else {

app/src/main/java/net/coding/program/project/detail/TaskFilterFragment.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import net.coding.program.common.network.LoadingFragment;
1414
import net.coding.program.event.EventFilterDetail;
1515
import net.coding.program.model.FilterModel;
16-
import net.coding.program.model.TaskCountModel;
1716
import net.coding.program.model.TaskLabelModel;
1817
import net.coding.program.model.TaskProjectCountModel;
1918

@@ -34,6 +33,11 @@ public class TaskFilterFragment extends LoadingFragment {
3433
//项目外
3534
protected final String urlTaskCountAll = Global.HOST_API + "/tasks/count";
3635
protected final String urlTaskLabel = Global.HOST_API + "/projects/tasks/labels?role=";
36+
protected final String urlTaskSomeCount_owner = Global.HOST_API + "/tasks/search?project_id=%s&owner=%s";
37+
protected final String urlTaskSomeCount_watcher = Global.HOST_API + "/tasks/search?project_id=%s&watcher=%s";
38+
protected final String urlTaskSomeCount_creator = Global.HOST_API + "/tasks/search?project_id=%s&creator=%s";
39+
protected final String urlTaskSomeOther = Global.HOST_API + "/project/%s/tasks/counts";
40+
3741
//项目外特定项目
3842
protected final String urlProjectTaskCount = Global.HOST_API + "/project/%s/tasks/counts";
3943
protected final String urlProjectTaskLabels = Global.HOST_API + "/project/%s/tasks/labels?role=";
@@ -61,7 +65,7 @@ public class TaskFilterFragment extends LoadingFragment {
6165
protected FilterModel mFilterModel;
6266
protected int statusIndex = 0;////筛选的index
6367

64-
protected TaskCountModel mTaskCountModel;
68+
//数量关联的唯一对象
6569
protected TaskProjectCountModel mTaskProjectCountModel;
6670

6771

@@ -101,20 +105,20 @@ private void iniTaskStatus() {
101105
"我关注的",
102106
"我创建的"
103107
};
104-
105-
if (mTaskCountModel != null) {
106-
filterTxtCount = new String[]{
107-
String.format(" (%d)", mTaskCountModel.processing + mTaskCountModel.done),
108-
String.format(" (%d)", mTaskCountModel.watchAll),
109-
String.format(" (%d)", mTaskCountModel.create)
110-
};
111-
}
108+
//
109+
// if (mTaskCountModel != null) {
110+
// filterTxtCount = new String[]{
111+
// String.format(" (%d)", mTaskCountModel.processing + mTaskCountModel.done),
112+
// String.format(" (%d)", mTaskCountModel.watchAll),
113+
// String.format(" (%d)", mTaskCountModel.create)
114+
// };
115+
// }
112116

113117
if (mTaskProjectCountModel != null) {
114118
filterTxtCount = new String[]{
115-
String.format(" (%d)", mTaskProjectCountModel.ownerProcessing + mTaskProjectCountModel.ownerDone),
116-
String.format(" (%d)", mTaskProjectCountModel.watcherProcessing + mTaskProjectCountModel.watcherDone),
117-
String.format(" (%d)", mTaskProjectCountModel.creatorProcessing + mTaskProjectCountModel.creatorDone)
119+
String.format(" (%d)", mTaskProjectCountModel.owner),
120+
String.format(" (%d)", mTaskProjectCountModel.watcher),
121+
String.format(" (%d)", mTaskProjectCountModel.creator)
118122
};
119123
}
120124

@@ -162,18 +166,18 @@ protected final void actionFilter() {
162166
mFilterModel.labelModels = taskLabelModels;
163167
}
164168

165-
if (mTaskCountModel != null) {
166-
if (statusIndex == 0) {
167-
mFilterModel.statusTaskDoing = mTaskCountModel.processing;
168-
mFilterModel.statusTaskDone = mTaskCountModel.done;
169-
} else if (statusIndex == 1) {
170-
mFilterModel.statusTaskDoing = mTaskCountModel.watchAllProcessing;
171-
mFilterModel.statusTaskDone = mTaskCountModel.getWatcherDoneCount();
172-
} else if (statusIndex == 2) {
173-
mFilterModel.statusTaskDoing = mTaskCountModel.createProcessing;
174-
mFilterModel.statusTaskDone = mTaskCountModel.getCreatorDoneCount();
175-
}
176-
}
169+
// if (mTaskCountModel != null) {
170+
// if (statusIndex == 0) {
171+
// mFilterModel.statusTaskDoing = mTaskCountModel.processing;
172+
// mFilterModel.statusTaskDone = mTaskCountModel.done;
173+
// } else if (statusIndex == 1) {
174+
// mFilterModel.statusTaskDoing = mTaskCountModel.watchAllProcessing;
175+
// mFilterModel.statusTaskDone = mTaskCountModel.getWatcherDoneCount();
176+
// } else if (statusIndex == 2) {
177+
// mFilterModel.statusTaskDoing = mTaskCountModel.createProcessing;
178+
// mFilterModel.statusTaskDone = mTaskCountModel.getCreatorDoneCount();
179+
// }
180+
// }
177181

178182
if (mTaskProjectCountModel != null) {
179183
if (statusIndex == 0) {

app/src/main/java/net/coding/program/task/TaskFragment.java

Lines changed: 95 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
import android.app.Activity;
44
import android.os.Bundle;
55
import android.support.v4.app.Fragment;
6-
import android.support.v4.view.GravityCompat;
76
import android.support.v4.view.PagerAdapter;
87
import android.support.v4.view.ViewPager;
9-
import android.support.v4.widget.DrawerLayout;
108
import android.util.Log;
119
import android.util.TypedValue;
1210
import android.view.View;
@@ -26,6 +24,7 @@
2624
import net.coding.program.model.TaskCountModel;
2725
import net.coding.program.model.TaskLabelModel;
2826
import net.coding.program.model.TaskObject;
27+
import net.coding.program.model.TaskProjectCountModel;
2928
import net.coding.program.project.detail.TaskFilterFragment;
3029
import net.coding.program.project.detail.TaskListFragment;
3130
import net.coding.program.project.detail.TaskListFragment_;
@@ -81,6 +80,22 @@ void initTaskFragment() {
8180
adapter = new PageTaskFragment(getChildFragmentManager());
8281
pager.setPageMargin(pageMargin);
8382
pager.setAdapter(adapter);
83+
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
84+
@Override
85+
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
86+
87+
}
88+
89+
@Override
90+
public void onPageSelected(int position) {
91+
load(position);
92+
}
93+
94+
@Override
95+
public void onPageScrollStateChanged(int state) {
96+
97+
}
98+
});
8499

85100
tabs.setVisibility(View.INVISIBLE);
86101
actionDivideLine.setVisibility(View.INVISIBLE);
@@ -93,10 +108,37 @@ void initTaskFragment() {
93108
protected void initFilterViews() {
94109
super.initFilterViews();
95110
setHasOptionsMenu(true);
96-
getNetwork(urlTaskCountAll, urlTaskCountAll);
97-
getNetwork(urlTaskLabel + getRole(), urlTaskLabel);
111+
load(0);
98112
}
99113

114+
private void load(int index) {
115+
mTaskProjectCountModel = new TaskProjectCountModel();
116+
117+
if (index == 0) {
118+
//全部项目
119+
getNetwork(urlTaskCountAll, urlTaskCountAll);
120+
} else {
121+
ProjectObject mProjectObject = mData.get(index);
122+
int userid = MyApp.sUserObject.id;
123+
//某个项目
124+
getNetwork(String.format(urlTaskSomeCount_owner, mProjectObject.getId(), userid), urlTaskSomeCount_owner);
125+
getNetwork(String.format(urlTaskSomeCount_watcher, mProjectObject.getId(), userid), urlTaskSomeCount_watcher);
126+
getNetwork(String.format(urlTaskSomeCount_creator, mProjectObject.getId(), userid), urlTaskSomeCount_creator);
127+
getNetwork(String.format(urlTaskSomeOther, mProjectObject.getId()), urlTaskSomeOther);
128+
}
129+
loadLabels();
130+
}
131+
132+
private void loadLabels() {
133+
if (tabs.getCurrentPosition() == 0) {
134+
getNetwork(urlTaskLabel + getRole(), urlTaskLabel);
135+
} else {
136+
ProjectObject mProjectObject = mData.get(tabs.getCurrentPosition());
137+
getNetwork(String.format(urlProjectTaskLabels, mProjectObject.getId()) + getRole(), urlProjectTaskLabels);
138+
}
139+
}
140+
141+
100142
@Override
101143
public void onRefresh() {
102144
}
@@ -153,18 +195,63 @@ public void parseJson(int code, JSONObject respanse, String tag, int pos, Object
153195
} else if (tag.equals(urlTaskCountAll)) {
154196
showLoading(false);
155197
if (code == 0) {
156-
mTaskCountModel = JSONUtils.getData(respanse.getString("data"), TaskCountModel.class);
198+
TaskCountModel mTaskCountModel = JSONUtils.getData(respanse.getString("data"), TaskCountModel.class);
199+
mTaskProjectCountModel.owner = mTaskCountModel.processing + mTaskCountModel.done;
200+
mTaskProjectCountModel.ownerDone = mTaskCountModel.done;
201+
mTaskProjectCountModel.ownerProcessing = mTaskCountModel.processing;
202+
203+
mTaskProjectCountModel.watcher = mTaskCountModel.watchAll;
204+
mTaskProjectCountModel.watcherDone = mTaskCountModel.watchAll - mTaskCountModel.watchAllProcessing;
205+
mTaskProjectCountModel.watcherProcessing = mTaskCountModel.watchAllProcessing;
206+
207+
mTaskProjectCountModel.creator = mTaskCountModel.create;
208+
mTaskProjectCountModel.creatorDone = mTaskCountModel.create - mTaskCountModel.createProcessing;
209+
mTaskProjectCountModel.creatorProcessing = mTaskCountModel.createProcessing;
157210
} else {
158211
showErrorMsg(code, respanse);
159212
}
160-
} else if (tag.equals(urlTaskLabel)) {
213+
} else if (tag.equals(urlTaskLabel) || tag.equals(urlProjectTaskLabels)) {
161214
showLoading(false);
162215
if (code == 0) {
163216
taskLabelModels = JSONUtils.getList(respanse.getString("data"), TaskLabelModel.class);
164217
Collections.sort(taskLabelModels, new PinyinComparator());
165218
} else {
166219
showErrorMsg(code, respanse);
167220
}
221+
} else if (tag.equals(urlTaskSomeCount_owner)) {
222+
showLoading(false);
223+
if (code == 0) {
224+
mTaskProjectCountModel.owner = JSONUtils.getJSONLong("totalRow", respanse.getString("data"));
225+
} else {
226+
showErrorMsg(code, respanse);
227+
}
228+
} else if (tag.equals(urlTaskSomeCount_watcher)) {
229+
showLoading(false);
230+
if (code == 0) {
231+
mTaskProjectCountModel.watcher = JSONUtils.getJSONLong("totalRow", respanse.getString("data"));
232+
} else {
233+
showErrorMsg(code, respanse);
234+
}
235+
} else if (tag.equals(urlTaskSomeCount_creator)) {
236+
showLoading(false);
237+
if (code == 0) {
238+
mTaskProjectCountModel.creator = JSONUtils.getJSONLong("totalRow", respanse.getString("data"));
239+
} else {
240+
showErrorMsg(code, respanse);
241+
}
242+
} else if (tag.equals(urlTaskSomeOther)) {
243+
showLoading(false);
244+
if (code == 0) {
245+
TaskProjectCountModel item = JSONUtils.getData(respanse.getString("data"), TaskProjectCountModel.class);
246+
mTaskProjectCountModel.ownerDone = item.ownerDone;
247+
mTaskProjectCountModel.ownerProcessing = item.ownerProcessing;
248+
mTaskProjectCountModel.creatorDone = item.creatorDone;
249+
mTaskProjectCountModel.creatorProcessing = item.creatorProcessing;
250+
mTaskProjectCountModel.watcherDone = item.watcherDone;
251+
mTaskProjectCountModel.watcherProcessing = item.watcherProcessing;
252+
} else {
253+
showErrorMsg(code, respanse);
254+
}
168255
}
169256
}
170257

@@ -325,6 +412,7 @@ protected final void action_filter() {
325412
protected void sureFilter() {
326413
super.sureFilter();
327414
//筛选了状态,相应的筛选标签也变化
328-
getNetwork(urlTaskLabel + getRole(), urlTaskLabel);
415+
//getNetwork(urlTaskLabel + getRole(), urlTaskLabel);
416+
loadLabels();
329417
}
330418
}

0 commit comments

Comments
 (0)