Revert "fixed weird problem with AsyncTask canceling."

This reverts commit 4be85a1f760ef0c2fd6f1d0ac62bd79360dbc03a.
This commit is contained in:
Alex Zolotarev 2012-05-24 17:14:18 +03:00 committed by Alex Zolotarev
parent 93504315eb
commit ee022787db
2 changed files with 7 additions and 16 deletions

View file

@ -48,8 +48,8 @@ public:
~HttpThread()
{
JNIEnv * env = jni::GetEnv();
jmethodID methodId = jni::GetJavaMethodID(env, m_self, "safeCancel", "()V");
ASSERT(methodId, ("Can't find java method 'safeCancel' in com/mapswithme/maps/downloader/DownloadChunkTask"));
jmethodID methodId = jni::GetJavaMethodID(env, m_self, "cancel", "(Z)Z");
ASSERT(methodId, ("Can't find java method 'cancel' in com/mapswithme/maps/downloader/DownloadChunkTask"));
env->CallBooleanMethod(m_self, methodId, false);
env->DeleteGlobalRef(m_self);

View file

@ -51,8 +51,7 @@ class DownloadChunkTask extends AsyncTask<Void, byte [], Void>
@Override
protected void onPostExecute(Void resCode)
{
if (!mIsCancelled)
onFinish(m_httpCallbackID, 200, m_beg, m_end);
onFinish(m_httpCallbackID, 200, m_beg, m_end);
}
@Override
@ -66,7 +65,7 @@ class DownloadChunkTask extends AsyncTask<Void, byte [], Void>
@Override
protected void onProgressUpdate(byte []... data)
{
if (!mIsCancelled)
if (!isCancelled())
{
// Use progress event to save downloaded bytes
onWrite(m_httpCallbackID, m_beg + m_downloadedBytes, data[0], data[0].length);
@ -89,7 +88,7 @@ class DownloadChunkTask extends AsyncTask<Void, byte [], Void>
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
if (mIsCancelled)
if (isCancelled())
{
urlConnection.disconnect();
return null;
@ -121,7 +120,7 @@ class DownloadChunkTask extends AsyncTask<Void, byte [], Void>
os.flush();
}
if (mIsCancelled)
if (isCancelled())
{
urlConnection.disconnect();
return null;
@ -143,7 +142,7 @@ class DownloadChunkTask extends AsyncTask<Void, byte [], Void>
long readBytes;
while ((readBytes = is.read(tempBuf)) != -1)
{
if (mIsCancelled)
if (isCancelled())
{
urlConnection.disconnect();
return null;
@ -171,12 +170,4 @@ class DownloadChunkTask extends AsyncTask<Void, byte [], Void>
return null;
}
private boolean mIsCancelled = false;
void safeCancel()
{
mIsCancelled = true;
cancel(false);
}
}