Skip to content

Commit 348bf2c

Browse files
committed
Reuse assignee, milestone, and labels dialogs
This allows the dialogs to immediately display when opened again after the first successful load. Previously the elements would be loaded each time the dialog was opened.
1 parent 7286c75 commit 348bf2c

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ public static Intent createIntent(final Issue issue,
143143

144144
private MenuItem saveItem;
145145

146+
private MilestoneDialog milestoneDialog;
147+
148+
private AssigneeDialog assigneeDialog;
149+
150+
private LabelsDialog labelsDialog;
151+
146152
@Override
147153
protected void onCreate(Bundle savedInstanceState) {
148154
super.onCreate(savedInstanceState);
@@ -175,28 +181,34 @@ protected void onCreate(Bundle savedInstanceState) {
175181

176182
@Override
177183
public void onClick(View v) {
178-
new MilestoneDialog(EditIssueActivity.this,
179-
ISSUE_MILESTONE_UPDATE, repository, milestoneService)
180-
.show(issue.getMilestone());
184+
if (milestoneDialog == null)
185+
milestoneDialog = new MilestoneDialog(
186+
EditIssueActivity.this, ISSUE_MILESTONE_UPDATE,
187+
repository, milestoneService);
188+
milestoneDialog.show(issue.getMilestone());
181189
}
182190
});
183191

184192
findViewById(id.ll_assignee).setOnClickListener(new OnClickListener() {
185193

186194
@Override
187195
public void onClick(View v) {
188-
new AssigneeDialog(EditIssueActivity.this,
189-
ISSUE_ASSIGNEE_UPDATE, repository, collaboratorService)
190-
.show(issue.getAssignee());
196+
if (assigneeDialog == null)
197+
assigneeDialog = new AssigneeDialog(EditIssueActivity.this,
198+
ISSUE_ASSIGNEE_UPDATE, repository,
199+
collaboratorService);
200+
assigneeDialog.show(issue.getAssignee());
191201
}
192202
});
193203

194204
findViewById(id.ll_labels).setOnClickListener(new OnClickListener() {
195205

196206
@Override
197207
public void onClick(View v) {
198-
new LabelsDialog(EditIssueActivity.this, ISSUE_LABELS_UPDATE,
199-
repository, labelService).show(issue.getLabels());
208+
if (labelsDialog == null)
209+
labelsDialog = new LabelsDialog(EditIssueActivity.this,
210+
ISSUE_LABELS_UPDATE, repository, labelService);
211+
labelsDialog.show(issue.getLabels());
200212
}
201213
});
202214

0 commit comments

Comments
 (0)