[android] Improved download thread canceling logic

This commit is contained in:
Alex Zolotarev 2012-05-25 14:19:18 +03:00 committed by Alex Zolotarev
parent 92938ceeeb
commit 9dfdc9ead7

View file

@ -151,6 +151,7 @@ class DownloadChunkTask extends AsyncTask<Void, byte [], Boolean>
// Notify the client about error
m_httpErrorCode = INVALID_URL;
cancel(false);
return false;
}
catch (IOException ex)
{
@ -158,13 +159,19 @@ class DownloadChunkTask extends AsyncTask<Void, byte [], Boolean>
// Notify the client about error
m_httpErrorCode = IO_ERROR;
cancel(false);
return false;
}
finally
{
if (urlConnection != null)
urlConnection.disconnect();
else
{
cancel(false);
return false;
}
}
// Download has finished
return true;
}
}