Fixed bugs in the noStorage error handler

This commit is contained in:
daniel oeh 2012-07-09 22:14:36 +02:00
parent d1c73645c4
commit 63c76b80f8
2 changed files with 22 additions and 6 deletions

View File

@ -88,6 +88,7 @@
<action android:name="de.podfetcher.feedupdatereceiver.refreshFeeds"/>
</intent-filter>
</receiver>
<activity android:name=".activity.StorageErrorActivity"></activity>
</application>
</manifest>

View File

@ -10,6 +10,7 @@ import android.util.Log;
import com.actionbarsherlock.app.SherlockActivity;
import de.podfetcher.R;
import de.podfetcher.util.StorageUtils;
public class StorageErrorActivity extends SherlockActivity {
private static final String TAG = "StorageErrorActivity";
@ -23,13 +24,27 @@ public class StorageErrorActivity extends SherlockActivity {
@Override
protected void onPause() {
super.onPause();
try {
unregisterReceiver(mediaUpdate);
} catch (IllegalArgumentException e) {
}
}
@Override
protected void onResume() {
super.onResume();
registerReceiver(mediaUpdate, new IntentFilter(Intent.ACTION_MEDIA_MOUNTED));
if (StorageUtils.storageAvailable()) {
leaveErrorState();
} else {
registerReceiver(mediaUpdate, new IntentFilter(
Intent.ACTION_MEDIA_MOUNTED));
}
}
private void leaveErrorState() {
finish();
startActivity(new Intent(this, PodfetcherActivity.class));
}
private BroadcastReceiver mediaUpdate = new BroadcastReceiver() {
@ -39,7 +54,7 @@ public class StorageErrorActivity extends SherlockActivity {
if (intent.getAction().equals(Intent.ACTION_MEDIA_MOUNTED)) {
if (intent.getBooleanExtra("read-only", true)) {
Log.d(TAG, "Media was mounted; Finishing activity");
finish();
leaveErrorState();
} else {
Log.d(TAG, "Media seemed to have been mounted read only");
}