Fix Bluetooth Settings activity memory leak.

There were two leaks in Bluetooth Settings: one when rotating the
    phone and other when scanning for bluetooth devices.
This commit is contained in:
thigobr
2010-07-21 13:10:04 -03:00
parent 46c0a5b129
commit d4cebee1e4
2 changed files with 11 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ import java.util.Map;
public class ProgressCategory extends PreferenceCategory {
private boolean mProgress = false;
private View oldView = null;
public ProgressCategory(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -41,6 +42,13 @@ public class ProgressCategory extends PreferenceCategory {
int visibility = mProgress ? View.VISIBLE : View.INVISIBLE;
textView.setVisibility(visibility);
progressBar.setVisibility(visibility);
if (oldView != null) {
oldView.findViewById(R.id.scanning_progress).setVisibility(View.GONE);
oldView.findViewById(R.id.scanning_text).setVisibility(View.GONE);
oldView.setVisibility(View.GONE);
}
oldView = view;
}
/**

View File

@@ -188,7 +188,8 @@ public class BluetoothSettings extends PreferenceActivity
super.onPause();
mLocalManager.setForegroundActivity(null);
mDevicePreferenceMap.clear();
mDeviceList.removeAll();
unregisterReceiver(mReceiver);
mLocalManager.unregisterCallback(this);