Commit adb2f8c87973b0a54655882e96029f04b04e6fb3

Authored by Imanol-Mikel Barba Sabariego
1 parent ad1210f1

--no commit message

src/com/upc/pbe/upcnews/Descarrega.java
... ... @@ -14,25 +14,26 @@ import java.net.URLConnection;
14 14 import android.os.AsyncTask;
15 15 import android.util.Log;
16 16  
17   -
18   -public class Descarrega extends AsyncTask<Object, Object, Object>{
  17 +public class Descarrega extends AsyncTask<Object, Object, Object> {
19 18 final static String TAG = "Descarrega";
20 19 private String url;
21   - private String nomarxiu;
22 20 private String carpeta;
  21 + private String nomarxiu;
23 22 private String html;
24 23 private File arxiu;
25 24  
26 25 public Descarrega() {
  26 + nomarxiu = "ejemplo.xml";
  27 + carpeta = "Environment.getExternalStorageDirectory.getPath()";
27 28  
28   -
  29 + this.carpeta = null;
29 30 this.html = null;
30 31 this.arxiu = null;
31 32 }
32 33  
33   - public void descarregarguardar(String u, String nomarxiu, String carpeta) {
34   - this.nomarxiu = nomarxiu;
35   - this.carpeta = carpeta;
  34 + public void descarregarguardar(String u, String nom, String car) {
  35 + this.nomarxiu = nom;
  36 + this.carpeta = car;
36 37 this.url = u;
37 38 // Creem el directori
38 39 File dir = new File(carpeta);
... ... @@ -73,8 +74,6 @@ public class Descarrega extends AsyncTask&lt;Object, Object, Object&gt;{
73 74 }
74 75 }
75 76  
76   -
77   -
78 77 protected String doInBackground(String u) {
79 78 this.url = u;
80 79 try {
... ... @@ -82,30 +81,29 @@ public class Descarrega extends AsyncTask&lt;Object, Object, Object&gt;{
82 81 BufferedReader in = new BufferedReader(new InputStreamReader(
83 82 conn.getInputStream()));
84 83 Log.d(TAG, "\nDescarregant: \n");
85   - Log.d(TAG, ">> URL: " + url + " >> Tamany: " + conn.getContentLength() + " bytes");
  84 + Log.d(TAG,
  85 + ">> URL: " + url + " >> Tamany: " + conn.getContentLength()
  86 + + " bytes");
86 87 String inputLine;
87 88 while ((inputLine = in.readLine()) != null) {
88 89 html = html + "\n" + inputLine;
89 90 }
90 91 Log.d(TAG, "Descarrega finalitzada");
91   -
  92 +
92 93 in.close();
93 94 } catch (MalformedURLException e) {
94 95 Log.d(TAG, "excepcio 1, no sha trobat la URL");
95 96 } catch (IOException e) {
96 97 Log.d(TAG, "excepcio 2");
97 98 }
98   -
  99 +
99 100 return html;
100   -
101   -
  101 +
102 102 }
103   -
104   -
105 103  
106 104 @Override
107 105 protected Object doInBackground(Object... arg0) {
108   -
  106 +
109 107 return null;
110 108 }
111 109 }
... ...
src/com/upc/pbe/upcnews/Directoris.java
... ... @@ -19,8 +19,6 @@ public class Directoris extends Activity implements OnClickListener {
19 19 String s;
20 20 Descarrega d;
21 21 String url;
22   - String file = "ejemplo.xml";
23   - String folder = "Environment.getExternalStorageDirectory.getPath()";
24 22  
25 23 ArrayList<Button> buttons = new ArrayList<Button>();
26 24  
... ... @@ -31,9 +29,9 @@ public class Directoris extends Activity implements OnClickListener {
31 29 super.onCreate(savedInstanceState);
32 30 setContentView(R.layout.dirs);
33 31  
34   - this.crearButtons();
35 32  
36 33 //Descarrega del HTML de l'index, busqueda de directoris i creacio dels botons
  34 + this.crearButtons();
37 35 s = ((UpcApp) getApplication()).getDesc();
38 36  
39 37 HTMLParser pars = new HTMLParser();
... ... @@ -121,15 +119,14 @@ public class Directoris extends Activity implements OnClickListener {
121 119 Parser p = new Parser();
122 120 try {
123 121 ArrayList<ParentList> m3u8parsed = p.parseFile(m3u8);
124   - /*
125   - * Imanol: Recorda'm que et comenti una cosa sobre les excepcions!
126   - */
  122 +
  123 +
127 124 } catch (ErrorException e) {
128   - e.printStackTrace();
  125 + Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
129 126 } catch (WarningException e) {
130   - e.printStackTrace();
  127 + Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
131 128 } catch (InfoException e) {
132   - e.printStackTrace();
  129 + Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
133 130 }
134 131 }
135 132  
... ...