Skip to content

Commit ce4ebe7

Browse files
committed
+pokud se pri praci s daty stala chyba, zobrazi se uzivateli
Ve tride DownloadAndParseJSON. Uzivateli se zobrazi typ vyjimky.
1 parent b4598a5 commit ce4ebe7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/eu/vancl/martin/tmep/DownloadAndParseJSON.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class DownloadAndParseJSON {
1919
private String vlhkost;
2020
private String casMereni;
2121

22+
private String chyba;
23+
2224
private String url;
2325

2426
public void downloadAndParse() {
@@ -51,10 +53,13 @@ public void downloadAndParse() {
5153
casMereni = jsonObject.getString("cas");
5254

5355
} catch (MalformedURLException e) {
56+
chyba = "MalformedURLException";
5457
e.printStackTrace();
5558
} catch (IOException e) {
59+
chyba = "IOException";
5660
e.printStackTrace();
5761
} catch (JSONException e) {
62+
chyba = "JSONException";
5863
e.printStackTrace();
5964
}
6065
}
@@ -94,6 +99,15 @@ public String getUrl() {
9499
public void setUrl(String url) {
95100
this.url = url;
96101
}
102+
103+
public String getChyba() {
104+
return chyba;
105+
}
106+
107+
public void setChyba(String chyba) {
108+
this.chyba = chyba;
109+
}
110+
97111

98112

99113

src/eu/vancl/martin/tmep/UpdateWidgetService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ protected void onHandleIntent(Intent arg0) {
3636
Log.d("TMEP_URL", tmepURL);
3737
DownloadAndParseJSON data = new DownloadAndParseJSON(tmepURL); // "http://teplomer.obechnanice.cz/json.php"
3838
data.downloadAndParse();
39+
40+
if (data.getChyba() != null) { // neco se nepovedlo
41+
updateWidget( "ERROR\n" + data.getChyba() );
42+
return;
43+
}
3944

4045
//DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH);
4146
try {

0 commit comments

Comments
 (0)