Source:
<code>public static Future<?> deleteFeedMediaOfItem(final Context context, final long mediaId) { return dbExec.submit(() -> { final FeedMedia media = DBReader.getFeedMedia(mediaId); if (media != null) { Log.i(TAG, String.format("Requested to delete FeedMedia [id=%d, title=%s, downloaded=%s", media.getId(), media.getEpisodeTitle(), String.valueOf(media.isDownloaded()))); if (media.isDownloaded()) { 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.", <START> Toast.LENGTH_LONG).show(); <END> return; } } media.setDownloaded(false); media.setFile_url(null); media.setHasEmbeddedPicture(false); PodDBAdapter adapter = PodDBAdapter.getInstance(); adapter.open(); adapter.setMedia(media); adapter.close(); SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(context); if (PlaybackPreferences.getCurrentlyPlayingMedia() == FeedMedia.PLAYABLE_TYPE_FEEDMEDIA) { if (media.getId() == PlaybackPreferences .getCurrentlyPlayingFeedMediaId()) { SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean( PlaybackPreferences.PREF_CURRENT_EPISODE_IS_STREAM, true); editor.commit(); } if (PlaybackPreferences .getCurrentlyPlayingFeedMediaId() == media .getId()) { context.sendBroadcast(new Intent( PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE)); } } if(GpodnetPreferences.loggedIn()) { FeedItem item = media.getItem(); GpodnetEpisodeAction action = new GpodnetEpisodeAction.Builder(item, GpodnetEpisodeAction.Action.DELETE) .currentDeviceId() .currentTimestamp() .build(); GpodnetPreferences.enqueueEpisodeAction(action); } } EventBus.getDefault().post(FeedItemEvent.deletedMedia(Collections.singletonList(media.getItem()))); EventDistributor.getInstance().sendUnreadItemsUpdateBroadcast(); } }); }</code><technical_language>hard coded strings shown user, a string resource instead</technical_language>

Target:
public static Future<?> deleteFeedMediaOfItem(final Context context, final long mediaId) { return dbExec.submit(() -> { final FeedMedia media = DBReader.getFeedMedia(mediaId); if (media != null) { Log.i(TAG, String.format("Requested to delete FeedMedia [id=%d, title=%s, downloaded=%s", media.getId(), media.getEpisodeTitle(), String.valueOf(media.isDownloaded()))); if (media.isDownloaded()) { File mediaFile = new File(media.getFile_url()); 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); media.setHasEmbeddedPicture(false); PodDBAdapter adapter = PodDBAdapter.getInstance(); adapter.open(); adapter.setMedia(media); adapter.close(); SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(context); if (PlaybackPreferences.getCurrentlyPlayingMedia() == FeedMedia.PLAYABLE_TYPE_FEEDMEDIA) { if (media.getId() == PlaybackPreferences .getCurrentlyPlayingFeedMediaId()) { SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean( PlaybackPreferences.PREF_CURRENT_EPISODE_IS_STREAM, true); editor.commit(); } if (PlaybackPreferences .getCurrentlyPlayingFeedMediaId() == media .getId()) { context.sendBroadcast(new Intent( PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE)); } } if(GpodnetPreferences.loggedIn()) { FeedItem item = media.getItem(); GpodnetEpisodeAction action = new GpodnetEpisodeAction.Builder(item, GpodnetEpisodeAction.Action.DELETE) .currentDeviceId() .currentTimestamp() .build(); GpodnetPreferences.enqueueEpisodeAction(action); } } EventBus.getDefault().post(FeedItemEvent.deletedMedia(Collections.singletonList(media.getItem()))); EventDistributor.getInstance().sendUnreadItemsUpdateBroadcast(); } }); }