3
3
import android .app .Activity ;
4
4
import android .os .Bundle ;
5
5
import android .support .v4 .app .Fragment ;
6
- import android .support .v4 .view .GravityCompat ;
7
6
import android .support .v4 .view .PagerAdapter ;
8
7
import android .support .v4 .view .ViewPager ;
9
- import android .support .v4 .widget .DrawerLayout ;
10
8
import android .util .Log ;
11
9
import android .util .TypedValue ;
12
10
import android .view .View ;
26
24
import net .coding .program .model .TaskCountModel ;
27
25
import net .coding .program .model .TaskLabelModel ;
28
26
import net .coding .program .model .TaskObject ;
27
+ import net .coding .program .model .TaskProjectCountModel ;
29
28
import net .coding .program .project .detail .TaskFilterFragment ;
30
29
import net .coding .program .project .detail .TaskListFragment ;
31
30
import net .coding .program .project .detail .TaskListFragment_ ;
@@ -81,6 +80,22 @@ void initTaskFragment() {
81
80
adapter = new PageTaskFragment (getChildFragmentManager ());
82
81
pager .setPageMargin (pageMargin );
83
82
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
+ });
84
99
85
100
tabs .setVisibility (View .INVISIBLE );
86
101
actionDivideLine .setVisibility (View .INVISIBLE );
@@ -93,10 +108,37 @@ void initTaskFragment() {
93
108
protected void initFilterViews () {
94
109
super .initFilterViews ();
95
110
setHasOptionsMenu (true );
96
- getNetwork (urlTaskCountAll , urlTaskCountAll );
97
- getNetwork (urlTaskLabel + getRole (), urlTaskLabel );
111
+ load (0 );
98
112
}
99
113
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
+
100
142
@ Override
101
143
public void onRefresh () {
102
144
}
@@ -153,18 +195,63 @@ public void parseJson(int code, JSONObject respanse, String tag, int pos, Object
153
195
} else if (tag .equals (urlTaskCountAll )) {
154
196
showLoading (false );
155
197
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 ;
157
210
} else {
158
211
showErrorMsg (code , respanse );
159
212
}
160
- } else if (tag .equals (urlTaskLabel )) {
213
+ } else if (tag .equals (urlTaskLabel ) || tag . equals ( urlProjectTaskLabels ) ) {
161
214
showLoading (false );
162
215
if (code == 0 ) {
163
216
taskLabelModels = JSONUtils .getList (respanse .getString ("data" ), TaskLabelModel .class );
164
217
Collections .sort (taskLabelModels , new PinyinComparator ());
165
218
} else {
166
219
showErrorMsg (code , respanse );
167
220
}
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
+ }
168
255
}
169
256
}
170
257
@@ -325,6 +412,7 @@ protected final void action_filter() {
325
412
protected void sureFilter () {
326
413
super .sureFilter ();
327
414
//筛选了状态,相应的筛选标签也变化
328
- getNetwork (urlTaskLabel + getRole (), urlTaskLabel );
415
+ //getNetwork(urlTaskLabel + getRole(), urlTaskLabel);
416
+ loadLabels ();
329
417
}
330
418
}
0 commit comments