Fixed bugs in the noStorage error handler
This commit is contained in:
parent
d1c73645c4
commit
63c76b80f8
|
@ -88,6 +88,7 @@
|
||||||
<action android:name="de.podfetcher.feedupdatereceiver.refreshFeeds"/>
|
<action android:name="de.podfetcher.feedupdatereceiver.refreshFeeds"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
<activity android:name=".activity.StorageErrorActivity"></activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
|
@ -10,10 +10,11 @@ import android.util.Log;
|
||||||
import com.actionbarsherlock.app.SherlockActivity;
|
import com.actionbarsherlock.app.SherlockActivity;
|
||||||
|
|
||||||
import de.podfetcher.R;
|
import de.podfetcher.R;
|
||||||
|
import de.podfetcher.util.StorageUtils;
|
||||||
|
|
||||||
public class StorageErrorActivity extends SherlockActivity {
|
public class StorageErrorActivity extends SherlockActivity {
|
||||||
private static final String TAG = "StorageErrorActivity";
|
private static final String TAG = "StorageErrorActivity";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -23,15 +24,29 @@ public class StorageErrorActivity extends SherlockActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
unregisterReceiver(mediaUpdate);
|
try {
|
||||||
|
unregisterReceiver(mediaUpdate);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.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() {
|
private BroadcastReceiver mediaUpdate = new BroadcastReceiver() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,13 +54,13 @@ public class StorageErrorActivity extends SherlockActivity {
|
||||||
if (intent.getAction().equals(Intent.ACTION_MEDIA_MOUNTED)) {
|
if (intent.getAction().equals(Intent.ACTION_MEDIA_MOUNTED)) {
|
||||||
if (intent.getBooleanExtra("read-only", true)) {
|
if (intent.getBooleanExtra("read-only", true)) {
|
||||||
Log.d(TAG, "Media was mounted; Finishing activity");
|
Log.d(TAG, "Media was mounted; Finishing activity");
|
||||||
finish();
|
leaveErrorState();
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Media seemed to have been mounted read only");
|
Log.d(TAG, "Media seemed to have been mounted read only");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue