Skip to content

Commit 93e36b2

Browse files
committed
Accept Pull Request #794 : (ashuo:merged -> coding:merge410)
Pull Request: 项目内外筛选 修正数量 Created By: @阿朔 Accepted By: @陈超 URL: https://coding.net/u/coding/p/Coding-Android/git/pull/794
2 parents 43070aa + c21d989 commit 93e36b2

File tree

11 files changed

+340
-67
lines changed

11 files changed

+340
-67
lines changed

app/src/main/java/net/coding/program/common/DrawerLayoutHelper.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class DrawerLayoutHelper {
3434
private FilterModel mFilterModel;
3535
private int font2;
3636
private int green;
37+
private boolean showLabelCount;
3738

3839
public DrawerLayoutHelper() {
3940

@@ -43,9 +44,17 @@ public static DrawerLayoutHelper getInstance() {
4344
return new DrawerLayoutHelper();
4445
}
4546

46-
public void initData(Context context, DrawerLayout drawerLayout, FilterModel filterModel, FilterListener filterListener) {
47+
/**
48+
* @param context
49+
* @param projectInner 是不是显示标签数量
50+
* @param drawerLayout
51+
* @param filterModel
52+
* @param filterListener
53+
*/
54+
public void initData(Context context, boolean projectInner, DrawerLayout drawerLayout, FilterModel filterModel, FilterListener filterListener) {
4755
this.mContext = context;
4856
this.mFilterModel = filterModel;
57+
this.showLabelCount = !projectInner;
4958
font2 = mContext.getResources().getColor(R.color.font_2);
5059
green = mContext.getResources().getColor(R.color.green);
5160

@@ -119,7 +128,7 @@ private void iniLabels(FilterListener filterListener, EditText etSearch) {
119128
}
120129

121130
TextView labelItem = (TextView) layoutInflater.inflate(R.layout.dialog_task_filter_label_item, null);
122-
String str = String.format("%s (%d/%d)", item.name, item.processing, item.all);
131+
String str = showLabelCount ? String.format("%s (%d/%d)", item.name, item.processing, item.all) : item.name;
123132
labelItem.setText(str);
124133
setLeftDrawable(labelItem, item.color, item.name.equals(mFilterModel.label));
125134
labelItem.setOnClickListener(v -> {

app/src/main/java/net/coding/program/message/JSONUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,7 @@ public static <T> List<T> getList(String key, String jsonString, Class<T> cls) {
3030
public static String getJSONString(String key, String jsonStringString) {
3131
return JSONObject.parseObject(jsonStringString).getString(key);
3232
}
33+
public static long getJSONLong(String key, String jsonStringString) {
34+
return JSONObject.parseObject(jsonStringString).getLong(key);
35+
}
3336
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package net.coding.program.model;
2+
3+
/**
4+
* Created by anfs on 22/12/2016.
5+
*/
6+
public class ProjectTaskCountModel {
7+
public long watch;
8+
public long processing;
9+
public long create;
10+
public long done;
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package net.coding.program.model;
2+
3+
/**
4+
* Created by anfs on 22/12/2016.
5+
*/
6+
public class ProjectTaskUserCountModel {
7+
public long memberDone;
8+
public long memberProcessing;
9+
10+
public long creatorDone;
11+
public long creatorProcessing;
12+
13+
public long watcherDone;
14+
public long watcherProcessing;
15+
}

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/model/TaskLabelModel.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
*/
77
public class TaskLabelModel {
88
public String color;
9-
public String project_id;
9+
public long project_id;
1010
public String name;
1111
public int all;
1212
public int count;
1313
public int processing;
14+
15+
public int owner_id;
16+
public int task_count;
17+
public int merge_request_count;
1418
}

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@
55
* 项目内 「我的任务、我关注的、我创建的」中「进行中的、已完成的」的数量
66
*/
77
public class TaskProjectCountModel {
8-
public int ownerDone;
9-
public int ownerProcessing;
10-
public int creatorDone;
11-
public int creatorProcessing;
12-
public int watcherDone;
13-
public int watcherProcessing;
8+
9+
public long owner;
10+
public long ownerDone;
11+
public long ownerProcessing;
12+
13+
public long creator;
14+
public long creatorDone;
15+
public long creatorProcessing;
16+
17+
public long watcher;
18+
public long watcherDone;
19+
public long watcherProcessing;
1420
}

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

Lines changed: 136 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@
2424
import net.coding.program.message.JSONUtils;
2525
import net.coding.program.model.AccountInfo;
2626
import net.coding.program.model.ProjectObject;
27+
import net.coding.program.model.ProjectTaskCountModel;
28+
import net.coding.program.model.ProjectTaskUserCountModel;
2729
import net.coding.program.model.TaskLabelModel;
2830
import net.coding.program.model.TaskObject;
2931
import net.coding.program.model.TaskProjectCountModel;
32+
import net.coding.program.model.UserObject;
3033
import net.coding.program.task.TaskListParentUpdate;
3134
import net.coding.program.task.TaskListUpdate;
3235
import net.coding.program.task.add.TaskAddActivity;
@@ -77,6 +80,7 @@ public class ProjectTaskFragment extends TaskFilterFragment implements TaskListP
7780
MemberTaskCount mMemberTask = new MemberTaskCount();
7881
private MyPagerAdapter adapter;
7982
private DrawerLayout drawer;
83+
private UserObject account;
8084

8185
@AfterViews
8286
protected final void initProjectTaskFragment() {
@@ -87,11 +91,29 @@ protected final void initProjectTaskFragment() {
8791
tabs.setLayoutInflater(mInflater);
8892
tabs.setVisibility(View.INVISIBLE);
8993

94+
account = AccountInfo.loadAccount(getActivity());
95+
9096
HOST_TASK_MEMBER = String.format(HOST_TASK_MEMBER, mProjectObject.getId());
9197
refresh();
9298

9399
adapter = new MyPagerAdapter(getChildFragmentManager());
94100
pager.setAdapter(adapter);
101+
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
102+
@Override
103+
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
104+
105+
}
106+
107+
@Override
108+
public void onPageSelected(int position) {
109+
loadData(position);
110+
}
111+
112+
@Override
113+
public void onPageScrollStateChanged(int state) {
114+
115+
}
116+
});
95117

96118
// 必须添加,否则回收恢复的时候,TaskListFragment 的 actionmenu 会显示几个出来
97119
setHasOptionsMenu(true);
@@ -106,10 +128,51 @@ protected void initFilterViews() {
106128
toolBarTitle.setOnClickListener(v -> {
107129
meActionFilter();
108130
});
109-
toolBarTitle.setText("我的任务");
131+
toolBarTitle.setText("全部任务");
132+
}
133+
134+
135+
loadData(0);
136+
}
137+
138+
@Override
139+
protected boolean isProjectInner() {
140+
return true;
141+
}
142+
143+
private void loadData(int index) {
144+
145+
mTaskProjectCountModel = new TaskProjectCountModel();
146+
147+
if (index == 0) {
148+
//全部成员
149+
//「全部任务」数量 - 进行中,已完成的 「我创建的」数量 = create
150+
getNetwork(String.format(urlProjectTaskCount, mProjectObject.getId()), urlProjectTaskCount);
151+
getNetwork(String.format(urlALL_Count, mProjectObject.getId()), urlALL_Count);
152+
getNetwork(String.format(urlALL_WATCH_Count, mProjectObject.getId(), account.id), urlALL_WATCH_Count);
153+
154+
loadAllLabels();
155+
} else {
156+
TaskObject.Members members = mMembersAll.get(index);
157+
158+
//某个成员
159+
getNetwork(String.format(urlSome_Count, mProjectObject.getId(), members.user_id), urlSome_Count);
160+
getNetwork(String.format(urlSome_Label, mProjectObject.getId(), members.user_id), urlSome_Label);
161+
}
162+
}
163+
164+
private void loadAllLabels() {
165+
int cur = tabs.getCurrentPosition();
166+
if (cur != 0) {
167+
TaskObject.Members members = mMembersAll.get(cur);
168+
getNetwork(String.format(urlSome_Label, mProjectObject.getId(), members.user_id), urlSome_Label);
169+
} else {
170+
if (statusIndex == 0) {
171+
getNetwork(String.format(urlALL_Label, mProjectObject.owner_user_name, mProjectObject.name), urlALL_Label);
172+
} else {
173+
getNetwork(String.format(urlProjectTaskLabels, mProjectObject.getId()) + getRole(), urlProjectTaskLabels);
174+
}
110175
}
111-
getNetwork(String.format(urlProjectTaskCount, mProjectObject.getId()), urlProjectTaskCount);
112-
getNetwork(String.format(urlProjectTaskLabels, mProjectObject.getId()) + getRole(), urlProjectTaskLabels);
113176
}
114177

115178
private void refresh() {
@@ -173,7 +236,29 @@ public void parseJson(int code, JSONObject respanse, String tag, int pos, Object
173236
} else if (tag.equals(urlProjectTaskCount)) {
174237
showLoading(false);
175238
if (code == 0) {
176-
mTaskProjectCountModel = JSONUtils.getData(respanse.getString("data"), TaskProjectCountModel.class);
239+
TaskProjectCountModel projectTaskCountModel = JSONUtils.getData(respanse.getString("data"), TaskProjectCountModel.class);
240+
mTaskProjectCountModel.creatorDone = projectTaskCountModel.creatorDone;
241+
mTaskProjectCountModel.creatorProcessing = projectTaskCountModel.creatorProcessing;
242+
mTaskProjectCountModel.watcherDone = projectTaskCountModel.watcherDone;
243+
mTaskProjectCountModel.watcherProcessing = projectTaskCountModel.watcherProcessing;
244+
} else {
245+
showErrorMsg(code, respanse);
246+
}
247+
} else if (tag.equals(urlALL_Count)) {
248+
showLoading(false);
249+
if (code == 0) {
250+
ProjectTaskCountModel projectTaskCountModel = JSONUtils.getData(respanse.getString("data"), ProjectTaskCountModel.class);
251+
mTaskProjectCountModel.owner = projectTaskCountModel.done + projectTaskCountModel.processing;
252+
mTaskProjectCountModel.ownerDone = projectTaskCountModel.done;
253+
mTaskProjectCountModel.ownerProcessing = projectTaskCountModel.processing;
254+
mTaskProjectCountModel.creator = projectTaskCountModel.create;
255+
} else {
256+
showErrorMsg(code, respanse);
257+
}
258+
} else if (tag.equals(urlALL_WATCH_Count)) {
259+
showLoading(false);
260+
if (code == 0) {
261+
mTaskProjectCountModel.watcher = JSONUtils.getJSONLong("totalRow", respanse.getString("data"));
177262
} else {
178263
showErrorMsg(code, respanse);
179264
}
@@ -185,6 +270,41 @@ public void parseJson(int code, JSONObject respanse, String tag, int pos, Object
185270
} else {
186271
showErrorMsg(code, respanse);
187272
}
273+
} else if (tag.equals(urlALL_Label)) {
274+
showLoading(false);
275+
if (code == 0) {
276+
taskLabelModels = JSONUtils.getList(respanse.getString("data"), TaskLabelModel.class);
277+
Collections.sort(taskLabelModels, new PinyinComparator());
278+
} else {
279+
showErrorMsg(code, respanse);
280+
}
281+
} else if (tag.equals(urlSome_Count)) {
282+
showLoading(false);
283+
if (code == 0) {
284+
ProjectTaskUserCountModel item = JSONUtils.getData(respanse.getString("data"), ProjectTaskUserCountModel.class);
285+
286+
mTaskProjectCountModel.owner = item.memberDone + item.memberProcessing;
287+
mTaskProjectCountModel.ownerDone = item.memberDone;
288+
mTaskProjectCountModel.ownerProcessing = item.memberProcessing;
289+
290+
mTaskProjectCountModel.creatorDone = item.creatorDone;
291+
mTaskProjectCountModel.creator = item.creatorDone + item.creatorProcessing;
292+
mTaskProjectCountModel.creatorProcessing = item.creatorProcessing;
293+
294+
mTaskProjectCountModel.watcher = item.watcherDone + item.watcherProcessing;
295+
mTaskProjectCountModel.watcherDone = item.watcherDone;
296+
mTaskProjectCountModel.watcherProcessing = item.watcherProcessing;
297+
} else {
298+
showErrorMsg(code, respanse);
299+
}
300+
} else if (tag.equals(urlSome_Label)) {
301+
showLoading(false);
302+
if (code == 0) {
303+
taskLabelModels = JSONUtils.getList(respanse.getString("data"), TaskLabelModel.class);
304+
Collections.sort(taskLabelModels, new PinyinComparator());
305+
} else {
306+
showErrorMsg(code, respanse);
307+
}
188308
}
189309

190310
}
@@ -311,9 +431,17 @@ public Fragment getItem(int position) {
311431
bundle.putSerializable("mMembersArray", mUsersInfo);
312432
bundle.putSerializable("mMemberPos", position);
313433
bundle.putBoolean("mShowAdd", true);
314-
// bundle.putString("mMeAction", "");
315-
// bundle.putString("mStatus", "");
316-
// bundle.putString("mLabel", "");
434+
435+
bundle.putString("mMeAction", mMeActions[statusIndex]);
436+
if (mFilterModel != null) {
437+
bundle.putString("mStatus", mFilterModel.status + "");
438+
bundle.putString("mLabel", mFilterModel.label);
439+
bundle.putString("mKeyword", mFilterModel.keyword);
440+
} else {
441+
bundle.putString("mStatus", "");
442+
bundle.putString("mLabel", "");
443+
bundle.putString("mKeyword", "");
444+
}
317445
fragment.setParent(ProjectTaskFragment.this);
318446

319447
fragment.setArguments(bundle);
@@ -346,6 +474,6 @@ protected final void action_filter() {
346474
@Override
347475
protected void sureFilter() {
348476
super.sureFilter();
349-
getNetwork(String.format(urlProjectTaskLabels, mProjectObject.getId()) + getRole(), urlProjectTaskLabels);
477+
loadAllLabels();
350478
}
351479
}

0 commit comments

Comments
 (0)