Commit 35974b8b2c2738ec4d94a4a28a3bcc309fdf5f89

Authored by Imanol-Mikel Barba Sabariego
1 parent 28b8ba02

--no commit message

src/com/upc/pbe/upcnews/Directoris.java
... ... @@ -42,7 +42,7 @@ public class Directoris extends Activity implements OnClickListener {
42 42 for (int i = 0; i < dirs.size(); i++) {
43 43 Log.d(TAG, "Directori " + dirs.get(i).toString());
44 44 buttons.get(i).setVisibility(View.VISIBLE);
45   - buttons.get(i).setText(pars.processar(dirs.get(i)));
  45 + buttons.get(i).setText(pars.processar((dirs.get(i))));
46 46 }
47 47 }
48 48  
... ... @@ -69,23 +69,23 @@ public class Directoris extends Activity implements OnClickListener {
69 69  
70 70 public void onClick(View c) {
71 71 switch (c.getId()) {
72   - case R.id.button1: {
73   - this.buttonClicked(buttons.get(0));
74   - break;
75   -
76   - }
77   - case R.id.button2: {
78   - this.buttonClicked(buttons.get(1));
79   - break;
80   - }
81   - case R.id.button3: {
82   - this.buttonClicked(buttons.get(2));
83   - break;
84   - }
85   - case R.id.button4: {
86   - this.buttonClicked(buttons.get(3));
87   - break;
88   - }
  72 + case R.id.button1: {
  73 + this.buttonClicked(buttons.get(0));
  74 + break;
  75 +
  76 + }
  77 + case R.id.button2: {
  78 + this.buttonClicked(buttons.get(1));
  79 + break;
  80 + }
  81 + case R.id.button3: {
  82 + this.buttonClicked(buttons.get(2));
  83 + break;
  84 + }
  85 + case R.id.button4: {
  86 + this.buttonClicked(buttons.get(3));
  87 + break;
  88 + }
89 89 }
90 90 }
91 91  
... ... @@ -95,7 +95,7 @@ public class Directoris extends Activity implements OnClickListener {
95 95 buttons.add((Button) findViewById(R.id.button3));
96 96 buttons.add((Button) findViewById(R.id.button4));
97 97 buttons.add((Button) findViewById(R.id.button5));
98   -
  98 +
99 99 for (int i = 0; i < buttons.size(); i++) {
100 100 buttons.get(i).setOnClickListener(this);
101 101 buttons.get(i).setVisibility(View.GONE);
... ... @@ -112,16 +112,29 @@ public class Directoris extends Activity implements OnClickListener {
112 112  
113 113 Log.d(TAG, urlvideo);
114 114  
115   - if (urlvideo == "No s'ha trobat") {
  115 + if (urlvideo.equalsIgnoreCase("No s'ha trobat")) {
116 116 Toast.makeText(
117 117 this,
118 118 "The directory " + b.getText()
119   - + " does not contain any '.m3u8' file", Toast.LENGTH_LONG)
120   - .show();
  119 + + " does not contain any '.m3u8' file",
  120 + Toast.LENGTH_LONG).show();
121 121 } else {
122 122 d = new Descarrega(urlvideo, file, folder);
123 123 String m3u8 = d.doInBackground();
  124 +
  125 + // m3u8 --> PARSE!
  126 + Parser p = new Parser();
  127 + try {
  128 + ArrayList<ParentList> m3u8parsed = p.parseFile(m3u8);
  129 +
  130 + } catch (ErrorException e) {
  131 + e.printStackTrace();
  132 + } catch (WarningException e) {
  133 + e.printStackTrace();
  134 + } catch (InfoException e) {
  135 + e.printStackTrace();
  136 + }
124 137 }
125   - // m3u8 --> PARSE!
  138 +
126 139 }
127 140 }
128 141 \ No newline at end of file
... ...
src/com/upc/pbe/upcnews/HTMLParser.java
... ... @@ -19,7 +19,7 @@ public class HTMLParser {
19 19 //Si hi ha un directori, tallem l'string per obtenir-ne el nom.
20 20 for(int i = 0; i < split.length; i++){
21 21 if(split[i].contains("href") && split[i].contains("/index.html\"")){
22   - directoris.add(processar(split[i].substring((split[i].indexOf("href="))+6, (split[i].indexOf("/index.html\"")))));
  22 + directoris.add((split[i].substring((split[i].indexOf("href="))+6, (split[i].indexOf("/index.html\"")))));
23 23 }
24 24 }
25 25 return directoris;
... ... @@ -40,6 +40,7 @@ public class HTMLParser {
40 40  
41 41 public String processar(String text){
42 42 //Elimina els caràcters no desitjats dels noms dels directoris.
  43 +
43 44 char[] c = text.toCharArray();
44 45 for (int i=0; i<c.length; i++){
45 46 if(c[i]=='-'){
... ...