Fix window leak problems in settings.
There were window leak in the settings application. These leak happens when an AlertDialog displays, rotate the phone, then it would cause window leak. Change-Id: I914897bf657933efea72eeea66076dc288098420
This commit is contained in:
committed by
Johan Redestig
parent
05c2b96f42
commit
20108e2ed6
@@ -71,6 +71,8 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
||||
|
||||
private final LocalBluetoothManager mLocalManager;
|
||||
|
||||
private AlertDialog mDialog = null;
|
||||
|
||||
private List<Callback> mCallbacks = new ArrayList<Callback>();
|
||||
|
||||
/**
|
||||
@@ -375,12 +377,29 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
|
||||
}
|
||||
};
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(getName())
|
||||
.setMessage(message)
|
||||
.setPositiveButton(android.R.string.ok, disconnectListener)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
if (mDialog == null) {
|
||||
mDialog = new AlertDialog.Builder(context)
|
||||
.setPositiveButton(android.R.string.ok, disconnectListener)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
} else {
|
||||
if (mDialog.isShowing()) {
|
||||
mDialog.dismiss();
|
||||
}
|
||||
}
|
||||
mDialog.setTitle(getName());
|
||||
mDialog.setMessage(message);
|
||||
mDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
if (mDialog != null) {
|
||||
mDialog.dismiss();
|
||||
mDialog = null;
|
||||
}
|
||||
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
public void connect() {
|
||||
|
Reference in New Issue
Block a user