From 35974b8b2c2738ec4d94a4a28a3bcc309fdf5f89 Mon Sep 17 00:00:00 2001 From: Equip de Desenvolupadors de PBE Date: Fri, 30 Nov 2012 16:39:55 +0000 Subject: [PATCH] --- src/com/upc/pbe/upcnews/Directoris.java | 59 ++++++++++++++++++++++++++++++++++++----------------------- src/com/upc/pbe/upcnews/HTMLParser.java | 3 ++- 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/com/upc/pbe/upcnews/Directoris.java b/src/com/upc/pbe/upcnews/Directoris.java index 21631e0..92f7dee 100644 --- a/src/com/upc/pbe/upcnews/Directoris.java +++ b/src/com/upc/pbe/upcnews/Directoris.java @@ -42,7 +42,7 @@ public class Directoris extends Activity implements OnClickListener { for (int i = 0; i < dirs.size(); i++) { Log.d(TAG, "Directori " + dirs.get(i).toString()); buttons.get(i).setVisibility(View.VISIBLE); - buttons.get(i).setText(pars.processar(dirs.get(i))); + buttons.get(i).setText(pars.processar((dirs.get(i)))); } } @@ -69,23 +69,23 @@ public class Directoris extends Activity implements OnClickListener { public void onClick(View c) { switch (c.getId()) { - case R.id.button1: { - this.buttonClicked(buttons.get(0)); - break; - - } - case R.id.button2: { - 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; - } + case R.id.button1: { + this.buttonClicked(buttons.get(0)); + break; + + } + case R.id.button2: { + 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; + } } } @@ -95,7 +95,7 @@ public class Directoris extends Activity implements OnClickListener { buttons.add((Button) findViewById(R.id.button3)); buttons.add((Button) findViewById(R.id.button4)); buttons.add((Button) findViewById(R.id.button5)); - + for (int i = 0; i < buttons.size(); i++) { buttons.get(i).setOnClickListener(this); buttons.get(i).setVisibility(View.GONE); @@ -112,16 +112,29 @@ public class Directoris extends Activity implements OnClickListener { Log.d(TAG, urlvideo); - if (urlvideo == "No s'ha trobat") { + if (urlvideo.equalsIgnoreCase("No s'ha trobat")) { Toast.makeText( this, "The directory " + b.getText() - + " does not contain any '.m3u8' file", Toast.LENGTH_LONG) - .show(); + + " does not contain any '.m3u8' file", + Toast.LENGTH_LONG).show(); } else { d = new Descarrega(urlvideo, file, folder); String m3u8 = d.doInBackground(); + + // m3u8 --> PARSE! + Parser p = new Parser(); + try { + ArrayList m3u8parsed = p.parseFile(m3u8); + + } catch (ErrorException e) { + e.printStackTrace(); + } catch (WarningException e) { + e.printStackTrace(); + } catch (InfoException e) { + e.printStackTrace(); + } } - // m3u8 --> PARSE! + } } \ No newline at end of file diff --git a/src/com/upc/pbe/upcnews/HTMLParser.java b/src/com/upc/pbe/upcnews/HTMLParser.java index ab30f0a..8924e69 100644 --- a/src/com/upc/pbe/upcnews/HTMLParser.java +++ b/src/com/upc/pbe/upcnews/HTMLParser.java @@ -19,7 +19,7 @@ public class HTMLParser { //Si hi ha un directori, tallem l'string per obtenir-ne el nom. for(int i = 0; i < split.length; i++){ if(split[i].contains("href") && split[i].contains("/index.html\"")){ - directoris.add(processar(split[i].substring((split[i].indexOf("href="))+6, (split[i].indexOf("/index.html\""))))); + directoris.add((split[i].substring((split[i].indexOf("href="))+6, (split[i].indexOf("/index.html\""))))); } } return directoris; @@ -40,6 +40,7 @@ public class HTMLParser { public String processar(String text){ //Elimina els carącters no desitjats dels noms dels directoris. + char[] c = text.toCharArray(); for (int i=0; i