Skip to content

Commit

Permalink
CATROID-240 - concurrency / task blocking issue with UploadStatusPoll…
Browse files Browse the repository at this point in the history
…ingTask
  • Loading branch information
84n4n4 committed Apr 22, 2019
1 parent 34ce3c7 commit 1b011f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,16 @@ private void showProgressDialogAndUploadProject() {
final int notificationId = StatusBarNotificationManager.getInstance()
.createUploadNotification(this, name);

UploadStatusPollingTask uploadStatusPollingTask = new UploadStatusPollingTask();

uploadProgressDialog = new AlertDialog.Builder(this)
.setTitle(getString(R.string.upload_project_dialog_title))
.setView(R.layout.dialog_upload_project_progress)
.setPositiveButton(R.string.progress_upload_dialog_show_program, null)
.setNegativeButton(R.string.done, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
uploadStatusPollingTask.cancel(false);
finish();
}
})
Expand All @@ -306,8 +309,7 @@ public void onClick(DialogInterface dialog, int which) {

startService(intent);

new UploadStatusPollingTask()
.execute();
uploadStatusPollingTask.execute();

int numberOfUploadedProjects = sharedPreferences.getInt(NUMBER_OF_UPLOADED_PROJECTS, 0) + 1;
sharedPreferences.edit()
Expand Down Expand Up @@ -418,6 +420,9 @@ private class UploadStatusPollingTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... voids) {
while (StatusBarNotificationManager.getInstance().getProgressPercent() != 100) {
if (isCancelled()) {
break;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ public void renameItem(ProjectData item, String name) {

@Override
public void onLoadFinished(boolean success) {
if (getActivity() == null) {
return;
}
if (success) {
Intent intent = new Intent(getActivity(), ProjectActivity.class);
intent.putExtra(ProjectActivity.EXTRA_FRAGMENT_POSITION, ProjectActivity.FRAGMENT_SCENES);
Expand Down

0 comments on commit 1b011f7

Please sign in to comment.