fixed 'leaky' dialog box error

svn:r24717
This commit is contained in:
Nathan Freitas 2011-05-03 06:41:34 +00:00
parent ae7738338d
commit bc48d8f1cc
2 changed files with 19 additions and 13 deletions

View File

@ -248,6 +248,12 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
if (progressDialog != null)
{
progressDialog.dismiss();
progressDialog = null;
}
} }
@ -472,21 +478,18 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
} }
} }
private AlertDialog aDialog = null;
private void showAlert(String title, String msg, boolean button) private void showAlert(String title, String msg, boolean button)
{ {
if (aDialog != null) AlertDialog aDialog = null;
aDialog.dismiss();
if (button) if (button)
{ {
aDialog = new AlertDialog.Builder(this) aDialog = new AlertDialog.Builder(this)
.setIcon(R.drawable.icon) .setIcon(R.drawable.icon)
.setTitle(title) .setTitle(title)
.setMessage(msg) .setMessage(msg)
.setPositiveButton(android.R.string.ok, null) .setPositiveButton(android.R.string.ok, null)
.show(); .show();
} }
else else
{ {
@ -496,6 +499,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
.setMessage(msg) .setMessage(msg)
.show(); .show();
} }
} }
/* /*
* Set the state of the running/not running graphic and label * Set the state of the running/not running graphic and label
@ -515,6 +519,7 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
{ {
imgStatus.setImageResource(R.drawable.toron); imgStatus.setImageResource(R.drawable.toron);
if (progressDialog != null) if (progressDialog != null)
{ {
progressDialog.dismiss(); progressDialog.dismiss();
@ -544,8 +549,10 @@ public class Orbot extends Activity implements OnLongClickListener, TorConstants
showAlert(getString(R.string.status_activated),getString(R.string.connect_first_time),true); showAlert(getString(R.string.status_activated),getString(R.string.connect_first_time),true);
} }
if (mItemOnOff != null) if (mItemOnOff != null)
mItemOnOff.setTitle(R.string.menu_stop); mItemOnOff.setTitle(R.string.menu_stop);
} }
else if (torStatus == STATUS_CONNECTING) else if (torStatus == STATUS_CONNECTING)

View File

@ -600,14 +600,13 @@ public class TorService extends Service implements TorServiceConstants, Runnable
else else
{ {
TorTransProxy.purgeIptables(this); TorTransProxy.purgeIptables(this);
showAlert("Status", "Transparent proxying DISABLED"); showAlert("Status", "Transparent proxying: DISABLED");
} }
} }
else else
{ {
TorTransProxy.purgeIptables(this); TorTransProxy.purgeIptables(this);
showAlert("Status", "Transparent proxying DISABLED"); showAlert("Status", "Transparent proxying: DISABLED");
} }