Commit 8eda87988db324100a63088a677da416f35c0384

Authored by Imanol-Mikel Barba Sabariego
1 parent 2afb5b52

He arreglat un crash tope de random

src/com/upc/pbe/upcnews/Descarrega.java
... ... @@ -14,6 +14,7 @@ import android.widget.Toast;
14 14 public class Descarrega extends AsyncTask<URL, Integer, String> {
15 15 final static String TAG = "Descarrega";
16 16 private Context ctx;
  17 + boolean failed = false;
17 18  
18 19 public Descarrega(Context c) {
19 20 ctx = c;
... ... @@ -41,10 +42,19 @@ public class Descarrega extends AsyncTask&lt;URL, Integer, String&gt; {
41 42 in.close();
42 43 Log.d(TAG, "Descarrega finalitzada");
43 44 } catch (IOException e) {
44   - this.cancel(true);
45   - Toast.makeText(ctx, e.getMessage(), Toast.LENGTH_LONG).show();
46   - return "";
  45 + failed = true;
  46 + return urls[0].toString();
47 47 }
48 48 return html;
49 49 }
  50 +
  51 + protected void onPostExecute(String url)
  52 + {
  53 + if(failed)
  54 + {
  55 + failed = false;
  56 + this.cancel(true);
  57 + Toast.makeText(ctx, "No s'ha pogut connectar a " + url, Toast.LENGTH_LONG).show();
  58 + }
  59 + }
50 60 }
51 61 \ No newline at end of file
... ...