File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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  {
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments