diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 208ec4b..f09ec66 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -9,6 +9,7 @@
+
{
Log.d(TAG, ">> URL: " + url + " >> Tamany: " + conn.getContentLength() + " bytes");
String inputLine;
while ((inputLine = in.readLine()) != null) {
- //Log.d(TAG, inputLine);
html = html + "\n" + inputLine;
}
Log.d(TAG, "Descarrega finalitzada");
diff --git a/src/com/upc/pbe/upcnews/Directoris.java b/src/com/upc/pbe/upcnews/Directoris.java
index 6946275..fd661f3 100644
--- a/src/com/upc/pbe/upcnews/Directoris.java
+++ b/src/com/upc/pbe/upcnews/Directoris.java
@@ -36,13 +36,11 @@ public class Directoris extends Activity implements OnClickListener {
s = ((UpcApp) getApplication()).getDesc();
-
HTMLParser pars = new HTMLParser();
ArrayList dirs = pars.parse(s);
- Log.d(TAG, dirs.toString());
for (int i = 0; i < dirs.size(); i++) {
- Log.d(TAG, "Directori " + i);
+ Log.d(TAG, "Directori " + dirs.get(i).toString());
buttons.get(i).setVisibility(View.VISIBLE);
buttons.get(i).setText(dirs.get(i));
@@ -76,56 +74,21 @@ public class Directoris extends Activity implements OnClickListener {
switch (c.getId()) {
case R.id.button1: {
- Log.d(TAG, "Click on button1");
- d = new Descarrega(url + "/" + buttons.get(0).getText() + "/",
- file, folder);
- String str = d.doInBackground();
-
- HTMLParser pars = new HTMLParser();
- String urlvideo = pars.findvideo(str, url + "/"
- + buttons.get(0).getText() + "/");
-
- Log.d(TAG, urlvideo);
-
- if (urlvideo == "No s'ha trobat") {
- Toast.makeText(this, "El directori " + buttons.get(1).getText() + " no conté cap .m3u8",
- Toast.LENGTH_LONG).show();
- } else {
- d = new Descarrega(urlvideo, file, folder);
- String m3u8 = d.doInBackground();
- }
- // m3u8 --> PARSE!
+ this.buttonClicked(buttons.get(0));
break;
}
case R.id.button2: {
- Log.d(TAG, "Click on button2");
- d = new Descarrega(url + "/" + buttons.get(1).getText() + "/",
- file, folder);
- String str = d.doInBackground();
-
- HTMLParser pars = new HTMLParser();
- String urlvideo = pars.findvideo(str, url + "/"
- + buttons.get(1).getText() + "/");
-
- Log.d(TAG, urlvideo);
-
- if (urlvideo == "No s'ha trobat") {
- Toast.makeText(this, "El directori " + buttons.get(1).getText() + " no conté cap .m3u8",
- Toast.LENGTH_LONG).show();
- } else {
-
- d = new Descarrega(urlvideo, file, folder);
- String m3u8 = d.doInBackground();
- }
- // m3u8 --> PARSE!
+ this.buttonClicked(buttons.get(1));
break;
}
case R.id.button3: {
-
+ this.buttonClicked(buttons.get(2));
+ break;
}
case R.id.button4: {
-
+ this.buttonClicked(buttons.get(3));
+ break;
}
}
}
@@ -143,4 +106,28 @@ public class Directoris extends Activity implements OnClickListener {
buttons.get(i).setVisibility(View.GONE);
}
}
+
+ public void buttonClicked(Button b) {
+
+ Log.d(TAG, "Click on " + b.getText());
+ d = new Descarrega(url + "/" + b.getText() + "/", file, folder);
+ String str = d.doInBackground();
+
+ HTMLParser pars = new HTMLParser();
+ String urlvideo = pars.findvideo(str, url + "/" + b.getText() + "/");
+
+ Log.d(TAG, urlvideo);
+
+ if (urlvideo == "No s'ha trobat") {
+ Toast.makeText(
+ this,
+ "El directori " + b.getText()
+ + " no conté cap fitxer .m3u8", Toast.LENGTH_LONG)
+ .show();
+ } else {
+ d = new Descarrega(urlvideo, file, folder);
+ String m3u8 = d.doInBackground();
+ }
+ // m3u8 --> PARSE!
+ }
}
\ No newline at end of file
diff --git a/src/com/upc/pbe/upcnews/MainActivity.java b/src/com/upc/pbe/upcnews/MainActivity.java
index 98cba5f..1127402 100644
--- a/src/com/upc/pbe/upcnews/MainActivity.java
+++ b/src/com/upc/pbe/upcnews/MainActivity.java
@@ -54,11 +54,14 @@ public class MainActivity extends Activity implements OnClickListener {
public void onClick(View v) {
Log.d(TAG, "onClicked");
+
+ //Wifi Info
wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
int speed = info.getLinkSpeed();
String str = "Speed: "+speed;
Log.d(TAG, str);
+
this.descarregar();
((UpcApp) getApplication()).setDesc(html);
startActivity(new Intent(this, Directoris.class));