Add simple null checks to StorageWizard*, also listen to...
the disk destroyed event. Bug 21336042 Change-Id: I9f53501a6122a4a9046774e3c4c08b5d6d6f8552
This commit is contained in:
@@ -20,8 +20,10 @@ import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.storage.DiskInfo;
|
||||
import android.os.storage.StorageEventListener;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.os.storage.VolumeInfo;
|
||||
import android.os.storage.VolumeRecord;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
@@ -63,6 +65,10 @@ public abstract class StorageWizardBase extends Activity implements NavigationBa
|
||||
}
|
||||
|
||||
setTheme(R.style.SuwThemeMaterial_Light);
|
||||
|
||||
if (mDisk != null) {
|
||||
mStorage.registerListener(mStorageListener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,6 +88,12 @@ public abstract class StorageWizardBase extends Activity implements NavigationBa
|
||||
getBackButton().setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mStorage.unregisterListener(mStorageListener);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
protected NavigationBar getNavigationBar() {
|
||||
return (NavigationBar) findViewById(R.id.suw_layout_navigation_bar);
|
||||
}
|
||||
@@ -142,4 +154,14 @@ public abstract class StorageWizardBase extends Activity implements NavigationBa
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private final StorageEventListener mStorageListener = new StorageEventListener() {
|
||||
@Override
|
||||
public void onDiskDestroyed(DiskInfo disk) {
|
||||
// We know mDisk != null.
|
||||
if (mDisk.id.equals(disk.id)) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user