sreichholf / dreamDroid

DreamDroid is an open-source enigma2 client for android based devices.
https://dreamdroid.org
GNU General Public License v3.0
106 stars 43 forks source link

@improvement add backward compatibility to WebInterface 1.5 #19

Closed xylo closed 13 years ago

xylo commented 13 years ago

It would be great if I could use the "Current (Service)" menu, although I'm using an outdated WebInterface version (1.5). Here is the patch that provides the backward compatibility:

Index: src/net/reichholf/dreamdroid/helpers/enigma2/Event.java
===================================================================
--- src/net/reichholf/dreamdroid/helpers/enigma2/Event.java (revision 1b0ceede43a8c1b60c476b8a10c68bd2fc5e9d8e)
+++ src/net/reichholf/dreamdroid/helpers/enigma2/Event.java (revision )
@@ -41,7 +41,13 @@

            String start = DateTime.getDateTimeString(eventstart);
            String starttime = DateTime.getTimeString(eventstart);
-           String duration = DateTime.getDurationString(event.getString(EVENT_DURATION), eventstart);
+           String duration;
+           try {
+               duration = DateTime.getDurationString(event.getString(EVENT_DURATION), eventstart);
+           } catch (NumberFormatException e) {
+               // deal with WebInterface 1.5 => EVENT_DURATION is already a string
+               duration = event.getString(EVENT_DURATION);
+           }

            event.put(EVENT_START_READABLE, start);
            event.put(EVENT_START_TIME_READABLE, starttime);
@@ -50,7 +56,13 @@

        String eventtitle = event.getString(EVENT_TITLE);
        if (Python.NONE.equals(eventtitle) || eventtitle == null) {
+           // deal with WebInterface 1.5 => try EVENT_NAME instead of EVENT_TITLE
+           eventtitle = event.getString(EVENT_NAME);
+           if (eventtitle != null) {
+               event.put(EVENT_TITLE, eventtitle);
+           } else {
-           event.put(EVENT_TITLE, "N/A");
-       }
-   }
-}
+               event.put(EVENT_TITLE, "N/A");
+           }
+       }
+   }
+}
sreichholf commented 13 years ago

implemented locally

xylo commented 13 years ago

Thanks.

BTW, can you tell me how to tag an issue, e.g. with "Improvement"? I tried different options and search already several minutes on the web, but could not find an answer.

xylo commented 13 years ago

OK, tagging issues seems to be impossible for external users according to this post: http://groups.google.com/group/github/browse_thread/thread/853c2ee70ed38cb4

This should be really part of the github FAQ.