android-ibc-forum

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit f2a57cfd19a590123b03480f7d6cb23ecca17e4e
parent 2501a806538abb01a38253d0dc20d1e7197edefa
Author: Jan Dankert <devnull@localhost>
Date:   Mon,  6 Feb 2012 21:48:31 +0100

ReentrantLock um die Synchronität der Serveranfragen zu erzwingen.

Diffstat:
src/de/mtbnews/android/util/ServerAsyncTask.java | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/de/mtbnews/android/util/ServerAsyncTask.java b/src/de/mtbnews/android/util/ServerAsyncTask.java @@ -38,6 +38,7 @@ public abstract class ServerAsyncTask extends AsyncTask<Void, Void, Void> private Context context; private AlertDialog alertDialog; private Exception error; + private ReentrantLock lock; /** * @param context @@ -57,6 +58,9 @@ public abstract class ServerAsyncTask extends AsyncTask<Void, Void, Void> @Override final protected void onPreExecute() { + lock = new ReentrantLock(); + lock.lock(); + progressDialog.setCancelable(true); progressDialog .setOnCancelListener(new DialogInterface.OnCancelListener() @@ -80,6 +84,7 @@ public abstract class ServerAsyncTask extends AsyncTask<Void, Void, Void> final protected void onPostExecute(Void result) { progressDialog.dismiss(); + lock.unlock(); if (error != null) { @@ -100,6 +105,9 @@ public abstract class ServerAsyncTask extends AsyncTask<Void, Void, Void> */ protected void doOnError(Exception error) { + progressDialog.dismiss(); + lock.unlock(); + final Builder builder = new AlertDialog.Builder(this.context); alertDialog = builder.setCancelable(true).create(); final int causeRId = ExceptionUtils.getResourceStringId(error);