29
29
import android .os .Bundle ;
30
30
import android .text .Editable ;
31
31
import android .text .TextUtils ;
32
- import android .util .Log ;
33
32
import android .view .View ;
34
33
import android .view .View .OnClickListener ;
35
34
import android .widget .EditText ;
49
48
import com .github .mobile .accounts .AuthenticatedUserTask ;
50
49
import com .github .mobile .core .issue .IssueUtils ;
51
50
import com .github .mobile .ui .DialogFragmentActivity ;
52
- import com .github .mobile .ui .ProgressDialogTask ;
53
51
import com .github .mobile .ui .StyledText ;
54
52
import com .github .mobile .ui .TextWatcherAdapter ;
55
53
import com .github .mobile .util .AvatarLoader ;
@@ -105,8 +103,6 @@ public static Intent createIntent(final Issue issue,
105
103
return builder .toIntent ();
106
104
}
107
105
108
- private static final String TAG = "EditIssueActivity" ;
109
-
110
106
private EditText titleText ;
111
107
112
108
private EditText bodyText ;
@@ -199,45 +195,38 @@ public void afterTextChanged(Editable s) {
199
195
});
200
196
201
197
updateSaveMenu ();
202
- updateView ();
198
+ titleText .setText (issue .getTitle ());
199
+ bodyText .setText (issue .getBody ());
203
200
}
204
201
205
- private void checkCollaboratorStatus () {
206
- new AuthenticatedUserTask <Boolean >(this ) {
207
-
208
- @ Override
209
- public Boolean run (Account account ) throws Exception {
210
- return collaboratorService .isCollaborator (repository , AccountUtils .getLogin (EditIssueActivity .this ));
211
- }
212
-
213
- @ Override
214
- protected void onSuccess (Boolean isCollaborator ) throws Exception {
215
- super .onSuccess (isCollaborator );
216
-
217
- showMainContent ();
218
-
219
- if (isCollaborator )
220
- showCollaboratorOptions ();
221
- }
222
-
223
- @ Override
224
- protected void onException (Exception e ) throws RuntimeException {
225
- super .onException (e );
226
-
227
- Log .d (TAG , "Error loading collaborators for issue editing" , e );
228
- showMainContent ();
229
- }
202
+ @ Override
203
+ public void onDialogResult (int requestCode , int resultCode , Bundle arguments ) {
204
+ if (RESULT_OK != resultCode )
205
+ return ;
230
206
231
- @ Override
232
- public void execute () {
233
- super .execute ();
234
- }
207
+ switch (requestCode ) {
208
+ case ISSUE_MILESTONE_UPDATE :
209
+ issue .setMilestone (MilestoneDialogFragment .getSelected (arguments ));
210
+ updateMilestone ();
211
+ break ;
212
+ case ISSUE_ASSIGNEE_UPDATE :
213
+ User assignee = AssigneeDialogFragment .getSelected (arguments );
214
+ if (assignee != null )
215
+ issue .setAssignee (assignee );
216
+ else
217
+ issue .setAssignee (new User ().setLogin ("" ));
218
+ updateAssignee ();
219
+ break ;
220
+ case ISSUE_LABELS_UPDATE :
221
+ issue .setLabels (LabelsDialogFragment .getSelected (arguments ));
222
+ updateLabels ();
223
+ break ;
224
+ }
225
+ }
235
226
236
- private void showMainContent () {
237
- finder .find (id .sv_issue_content ).setVisibility (View .VISIBLE );
238
- finder .find (id .pb_loading ).setVisibility (View .GONE );
239
- }
240
- }.execute ();
227
+ private void showMainContent () {
228
+ finder .find (id .sv_issue_content ).setVisibility (View .VISIBLE );
229
+ finder .find (id .pb_loading ).setVisibility (View .GONE );
241
230
}
242
231
243
232
private void showCollaboratorOptions () {
@@ -254,8 +243,8 @@ private void showCollaboratorOptions() {
254
243
public void onClick (View v ) {
255
244
if (milestoneDialog == null )
256
245
milestoneDialog = new MilestoneDialog (
257
- EditIssueActivity .this , ISSUE_MILESTONE_UPDATE ,
258
- repository , milestoneService );
246
+ EditIssueActivity .this , ISSUE_MILESTONE_UPDATE ,
247
+ repository , milestoneService );
259
248
milestoneDialog .show (issue .getMilestone ());
260
249
}
261
250
});
@@ -266,8 +255,8 @@ public void onClick(View v) {
266
255
public void onClick (View v ) {
267
256
if (assigneeDialog == null )
268
257
assigneeDialog = new AssigneeDialog (EditIssueActivity .this ,
269
- ISSUE_ASSIGNEE_UPDATE , repository ,
270
- collaboratorService );
258
+ ISSUE_ASSIGNEE_UPDATE , repository ,
259
+ collaboratorService );
271
260
assigneeDialog .show (issue .getAssignee ());
272
261
}
273
262
});
@@ -278,35 +267,14 @@ public void onClick(View v) {
278
267
public void onClick (View v ) {
279
268
if (labelsDialog == null )
280
269
labelsDialog = new LabelsDialog (EditIssueActivity .this ,
281
- ISSUE_LABELS_UPDATE , repository , labelService );
270
+ ISSUE_LABELS_UPDATE , repository , labelService );
282
271
labelsDialog .show (issue .getLabels ());
283
272
}
284
273
});
285
- }
286
274
287
- @ Override
288
- public void onDialogResult (int requestCode , int resultCode , Bundle arguments ) {
289
- if (RESULT_OK != resultCode )
290
- return ;
291
-
292
- switch (requestCode ) {
293
- case ISSUE_MILESTONE_UPDATE :
294
- issue .setMilestone (MilestoneDialogFragment .getSelected (arguments ));
295
- updateMilestone ();
296
- break ;
297
- case ISSUE_ASSIGNEE_UPDATE :
298
- User assignee = AssigneeDialogFragment .getSelected (arguments );
299
- if (assignee != null )
300
- issue .setAssignee (assignee );
301
- else
302
- issue .setAssignee (new User ().setLogin ("" ));
303
- updateAssignee ();
304
- break ;
305
- case ISSUE_LABELS_UPDATE :
306
- issue .setLabels (LabelsDialogFragment .getSelected (arguments ));
307
- updateLabels ();
308
- break ;
309
- }
275
+ updateAssignee ();
276
+ updateLabels ();
277
+ updateMilestone ();
310
278
}
311
279
312
280
private void updateMilestone () {
@@ -349,15 +317,6 @@ private void updateLabels() {
349
317
labelsText .setText (string .none );
350
318
}
351
319
352
- private void updateView () {
353
- titleText .setText (issue .getTitle ());
354
- bodyText .setText (issue .getBody ());
355
-
356
- updateAssignee ();
357
- updateLabels ();
358
- updateMilestone ();
359
- }
360
-
361
320
@ Override
362
321
protected void onSaveInstanceState (Bundle outState ) {
363
322
super .onSaveInstanceState (outState );
@@ -422,4 +381,31 @@ protected void onSuccess(Issue created) throws Exception {
422
381
return super .onOptionsItemSelected (item );
423
382
}
424
383
}
384
+
385
+ private void checkCollaboratorStatus () {
386
+ new AuthenticatedUserTask <Boolean >(this ) {
387
+
388
+ @ Override
389
+ public Boolean run (Account account ) throws Exception {
390
+ return collaboratorService .isCollaborator (
391
+ repository , AccountUtils .getLogin (EditIssueActivity .this ));
392
+ }
393
+
394
+ @ Override
395
+ protected void onSuccess (Boolean isCollaborator ) throws Exception {
396
+ super .onSuccess (isCollaborator );
397
+
398
+ showMainContent ();
399
+ if (isCollaborator )
400
+ showCollaboratorOptions ();
401
+ }
402
+
403
+ @ Override
404
+ protected void onException (Exception e ) throws RuntimeException {
405
+ super .onException (e );
406
+
407
+ showMainContent ();
408
+ }
409
+ }.execute ();
410
+ }
425
411
}
0 commit comments