gpoddernet: do not crash on unknown remote actions

According to [1] and my own episode actions feed, "action":"flattr" is a
valid action.  Future-proof the episode actions code by ignoring actions
that we don't know and care about.

This fixes the

    java.lang.IllegalArgumentException: FLATTR is not a constant

exception when fetching the episode actions list.

[1]: https://gpoddernet.readthedocs.org/en/latest/api/reference/events.html
This commit is contained in:
Simon Schubert 2015-06-25 11:12:59 +02:00
parent 5e8c75a1da
commit e3d0f8fbe5
1 changed files with 6 additions and 1 deletions

View File

@ -93,7 +93,12 @@ public class GpodnetEpisodeAction {
if(StringUtils.isEmpty(podcast) || StringUtils.isEmpty(episode) || StringUtils.isEmpty(actionString)) {
return null;
}
GpodnetEpisodeAction.Action action = GpodnetEpisodeAction.Action.valueOf(actionString.toUpperCase());
GpodnetEpisodeAction.Action action;
try {
action = GpodnetEpisodeAction.Action.valueOf(actionString.toUpperCase());
} catch (IllegalArgumentException e) {
return null;
}
String deviceId = object.optString("device", "");
GpodnetEpisodeAction.Builder builder = new GpodnetEpisodeAction.Builder(podcast, episode, action)
.deviceId(deviceId);