Skip to content

Commit f5db7f2

Browse files
committed
Move some methods to keep consistency through the class, clean imports
1 parent 941a391 commit f5db7f2

File tree

2 files changed

+63
-81
lines changed

2 files changed

+63
-81
lines changed

app/res/layout/issue_edit.xml

-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@
5353
style="@style/FormalSingleLineEditText"
5454
android:layout_width="match_parent" />
5555

56-
<!-- We initially hide many of these because we don't know if the
57-
the user is a collaborator, so we show them later as necessary
58-
-->
59-
6056
<TextView
6157
android:id="@+id/tv_labels_label"
6258
style="@style/HeaderTitleText"

app/src/main/java/com/github/mobile/ui/issue/EditIssueActivity.java

+63-77
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import android.os.Bundle;
3030
import android.text.Editable;
3131
import android.text.TextUtils;
32-
import android.util.Log;
3332
import android.view.View;
3433
import android.view.View.OnClickListener;
3534
import android.widget.EditText;
@@ -49,7 +48,6 @@
4948
import com.github.mobile.accounts.AuthenticatedUserTask;
5049
import com.github.mobile.core.issue.IssueUtils;
5150
import com.github.mobile.ui.DialogFragmentActivity;
52-
import com.github.mobile.ui.ProgressDialogTask;
5351
import com.github.mobile.ui.StyledText;
5452
import com.github.mobile.ui.TextWatcherAdapter;
5553
import com.github.mobile.util.AvatarLoader;
@@ -105,8 +103,6 @@ public static Intent createIntent(final Issue issue,
105103
return builder.toIntent();
106104
}
107105

108-
private static final String TAG = "EditIssueActivity";
109-
110106
private EditText titleText;
111107

112108
private EditText bodyText;
@@ -199,45 +195,38 @@ public void afterTextChanged(Editable s) {
199195
});
200196

201197
updateSaveMenu();
202-
updateView();
198+
titleText.setText(issue.getTitle());
199+
bodyText.setText(issue.getBody());
203200
}
204201

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;
230206

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+
}
235226

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);
241230
}
242231

243232
private void showCollaboratorOptions() {
@@ -254,8 +243,8 @@ private void showCollaboratorOptions() {
254243
public void onClick(View v) {
255244
if (milestoneDialog == null)
256245
milestoneDialog = new MilestoneDialog(
257-
EditIssueActivity.this, ISSUE_MILESTONE_UPDATE,
258-
repository, milestoneService);
246+
EditIssueActivity.this, ISSUE_MILESTONE_UPDATE,
247+
repository, milestoneService);
259248
milestoneDialog.show(issue.getMilestone());
260249
}
261250
});
@@ -266,8 +255,8 @@ public void onClick(View v) {
266255
public void onClick(View v) {
267256
if (assigneeDialog == null)
268257
assigneeDialog = new AssigneeDialog(EditIssueActivity.this,
269-
ISSUE_ASSIGNEE_UPDATE, repository,
270-
collaboratorService);
258+
ISSUE_ASSIGNEE_UPDATE, repository,
259+
collaboratorService);
271260
assigneeDialog.show(issue.getAssignee());
272261
}
273262
});
@@ -278,35 +267,14 @@ public void onClick(View v) {
278267
public void onClick(View v) {
279268
if (labelsDialog == null)
280269
labelsDialog = new LabelsDialog(EditIssueActivity.this,
281-
ISSUE_LABELS_UPDATE, repository, labelService);
270+
ISSUE_LABELS_UPDATE, repository, labelService);
282271
labelsDialog.show(issue.getLabels());
283272
}
284273
});
285-
}
286274

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();
310278
}
311279

312280
private void updateMilestone() {
@@ -349,15 +317,6 @@ private void updateLabels() {
349317
labelsText.setText(string.none);
350318
}
351319

352-
private void updateView() {
353-
titleText.setText(issue.getTitle());
354-
bodyText.setText(issue.getBody());
355-
356-
updateAssignee();
357-
updateLabels();
358-
updateMilestone();
359-
}
360-
361320
@Override
362321
protected void onSaveInstanceState(Bundle outState) {
363322
super.onSaveInstanceState(outState);
@@ -422,4 +381,31 @@ protected void onSuccess(Issue created) throws Exception {
422381
return super.onOptionsItemSelected(item);
423382
}
424383
}
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+
}
425411
}

0 commit comments

Comments
 (0)