Skip to content

Commit 847fda6

Browse files
authored
Merge pull request #410 from Microsoft/fix/hide_progress_dialog_background
Fix hiding progress dialog on download/install failure
2 parents 09d72ed + 5b39f71 commit 847fda6

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

sdk/mobile-center-distribute/src/main/java/com/microsoft/azure/mobile/distribute/Distribute.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1306,8 +1306,17 @@ private void showDownloadProgress() {
13061306
*/
13071307
private synchronized void hideProgressDialog() {
13081308
if (mProgressDialog != null) {
1309-
mProgressDialog.hide();
1309+
final ProgressDialog progressDialog = mProgressDialog;
13101310
mProgressDialog = null;
1311+
1312+
/* This can be called from background check download task. */
1313+
HandlerUtils.runOnUiThread(new Runnable() {
1314+
1315+
@Override
1316+
public void run() {
1317+
progressDialog.hide();
1318+
}
1319+
});
13111320
HandlerUtils.getMainHandler().removeCallbacksAndMessages(HANDLER_TOKEN_CHECK_PROGRESS);
13121321
}
13131322
}

sdk/mobile-center-distribute/src/test/java/com/microsoft/azure/mobile/distribute/DistributeMandatoryDownloadTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,17 @@ public Void answer(InvocationOnMock invocation) throws Throwable {
291291
}).when(mContext).startActivity(installIntent);
292292
doAnswer(new Answer<Void>() {
293293

294+
boolean firstCall = true;
295+
294296
@Override
295297
public Void answer(InvocationOnMock invocation) throws Throwable {
296-
beforeStartingActivityLock.release();
297-
disabledLock.acquireUninterruptibly();
298+
299+
/* First call is update progress dialog, second is hide. */
300+
if (firstCall) {
301+
firstCall = false;
302+
beforeStartingActivityLock.release();
303+
disabledLock.acquireUninterruptibly();
304+
}
298305
(((Runnable) invocation.getArguments()[0])).run();
299306
return null;
300307
}

0 commit comments

Comments
 (0)