Using MessageEvent to deliver error message

This commit is contained in:
ByteHamster 2017-06-04 14:42:42 +02:00
parent 5051a0f3d9
commit aae06389f9
2 changed files with 7 additions and 7 deletions

View File

@ -7,7 +7,8 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.core.event.MessageEvent;
import org.shredzone.flattr4j.model.Flattr;
import java.io.File;
@ -88,12 +89,10 @@ public class DBWriter {
if (media.isDownloaded()) {
// delete downloaded media file
File mediaFile = new File(media.getFile_url());
if (mediaFile.exists()) {
if (!mediaFile.delete()) {
Toast.makeText(context, "Unable to delete file. Rebooting the device could help.",
Toast.LENGTH_LONG).show();
return;
}
if (mediaFile.exists() && !mediaFile.delete()) {
MessageEvent evt = new MessageEvent(context.getString(R.string.delete_failed));
EventBus.getDefault().post(evt);
return;
}
media.setDownloaded(false);
media.setFile_url(null);

View File

@ -155,6 +155,7 @@
<string name="stream_label">Stream</string>
<string name="remove_label">Remove</string>
<string name="delete_label">Delete</string>
<string name="delete_failed">Unable to delete file. Rebooting the device could help.</string>
<string name="remove_episode_lable">Remove Episode</string>
<string name="marked_as_seen_label">Marked as seen</string>
<string name="mark_read_label">Mark as played</string>