Commit ed8b2172cb8f2c4384fe58bc4ff03e5e583294ff

Authored by Imanol-Mikel Barba Sabariego
1 parent ba5a364f

--no commit message

res/layout/help.xml
@@ -23,6 +23,7 @@ @@ -23,6 +23,7 @@
23 android:id="@+id/textView2" 23 android:id="@+id/textView2"
24 android:layout_width="match_parent" 24 android:layout_width="match_parent"
25 android:layout_height="0dp" 25 android:layout_height="0dp"
  26 + android:gravity="center_horizontal"
26 android:text="@string/helpText" /> 27 android:text="@string/helpText" />
27 28
28 </ScrollView> 29 </ScrollView>
src/com/upc/pbe/upcnews/BandwidthMeasurer.java
@@ -2,22 +2,20 @@ package com.upc.pbe.upcnews; @@ -2,22 +2,20 @@ package com.upc.pbe.upcnews;
2 2
3 import android.net.TrafficStats; 3 import android.net.TrafficStats;
4 4
5 -public class BandwidthMeasurer  
6 -{  
7 - public double Measure(long rxBytes, long Time)  
8 - { 5 +//Mesura la velocitat (Bandwidth) d'Internet
  6 +public class BandwidthMeasurer{
  7 +
  8 + public double Measure(long rxBytes, long Time){
9 long AfterTime = System.currentTimeMillis(); 9 long AfterTime = System.currentTimeMillis();
10 double bps; 10 double bps;
11 long TotalRxAfterTest = TrafficStats.getTotalRxBytes(); 11 long TotalRxAfterTest = TrafficStats.getTotalRxBytes();
12 double TimeDifference = AfterTime - Time; 12 double TimeDifference = AfterTime - Time;
13 double rxDiff = TotalRxAfterTest - rxBytes; 13 double rxDiff = TotalRxAfterTest - rxBytes;
14 14
15 - if(rxDiff != 0)  
16 - { 15 + if(rxDiff != 0){
17 bps = ((rxDiff*8) / (TimeDifference/1000)); // total rx bits per second. 16 bps = ((rxDiff*8) / (TimeDifference/1000)); // total rx bits per second.
18 } 17 }
19 - else  
20 - { 18 + else{
21 bps = -1; //No transmitted data 19 bps = -1; //No transmitted data
22 } 20 }
23 return bps; 21 return bps;
src/com/upc/pbe/upcnews/Descarrega.java
@@ -14,47 +14,43 @@ import java.net.URLConnection; @@ -14,47 +14,43 @@ import java.net.URLConnection;
14 import android.os.AsyncTask; 14 import android.os.AsyncTask;
15 import android.util.Log; 15 import android.util.Log;
16 16
  17 +//Descarrega un arxiu i el guarda o retorna en String
17 public class Descarrega extends AsyncTask<Object, Object, Object> { 18 public class Descarrega extends AsyncTask<Object, Object, Object> {
  19 +
18 final static String TAG = "Descarrega"; 20 final static String TAG = "Descarrega";
19 - private String url;  
20 - private String carpeta;  
21 - private String nomarxiu;  
22 - private String html; 21 + private String url, carpeta, nomarxiu, html;
23 private File arxiu; 22 private File arxiu;
24 23
25 public Descarrega() { 24 public Descarrega() {
26 nomarxiu = "ejemplo.xml"; 25 nomarxiu = "ejemplo.xml";
27 carpeta = "Environment.getExternalStorageDirectory.getPath()"; 26 carpeta = "Environment.getExternalStorageDirectory.getPath()";
28 -  
29 this.carpeta = null; 27 this.carpeta = null;
30 this.html = ""; 28 this.html = "";
31 this.arxiu = null; 29 this.arxiu = null;
32 } 30 }
33 31
34 public void descarregarguardar(String u, String nom, String car) { 32 public void descarregarguardar(String u, String nom, String car) {
  33 + //Descarrega un arxiu i el guarda
35 this.nomarxiu = nom; 34 this.nomarxiu = nom;
36 this.carpeta = car; 35 this.carpeta = car;
37 this.url = u; 36 this.url = u;
38 - // Creem el directori 37 + //Creem el directori
39 File dir = new File(carpeta); 38 File dir = new File(carpeta);
40 if (!dir.exists()) { 39 if (!dir.exists()) {
41 if (!dir.mkdir()) { 40 if (!dir.mkdir()) {
42 return; // No s'ha pogut crear (ja existeix) 41 return; // No s'ha pogut crear (ja existeix)
43 } 42 }
44 } 43 }
45 -  
46 - // Creem l'arxiu 44 + //Creem l'arxiu
47 arxiu = new File(carpeta + nomarxiu); 45 arxiu = new File(carpeta + nomarxiu);
48 -  
49 - // Iniciem la descรƒย rrega 46 + //Iniciem la descarrega
50 try { 47 try {
51 URLConnection conn = new URL(url).openConnection(); 48 URLConnection conn = new URL(url).openConnection();
52 conn.connect(); 49 conn.connect();
53 Log.d(TAG, "\nDescarregant: \n"); 50 Log.d(TAG, "\nDescarregant: \n");
54 Log.d(TAG, " >> URL: " + url + " >> Nom: " + nomarxiu 51 Log.d(TAG, " >> URL: " + url + " >> Nom: " + nomarxiu
55 + " >> Tamany: " + conn.getContentLength() + " bytes"); 52 + " >> Tamany: " + conn.getContentLength() + " bytes");
56 -  
57 - // Llegeix cada byte i l'escriu en un arxiu fins que arriba a -1 53 + //Llegeix cada byte i l'escriu en un arxiu fins que arriba a -1
58 InputStream in = conn.getInputStream(); 54 InputStream in = conn.getInputStream();
59 OutputStream out = new FileOutputStream(arxiu); 55 OutputStream out = new FileOutputStream(arxiu);
60 int b = 0; 56 int b = 0;
@@ -66,7 +62,6 @@ public class Descarrega extends AsyncTask&lt;Object, Object, Object&gt; { @@ -66,7 +62,6 @@ public class Descarrega extends AsyncTask&lt;Object, Object, Object&gt; {
66 } 62 }
67 out.close(); 63 out.close();
68 in.close(); 64 in.close();
69 -  
70 } catch (MalformedURLException e) { 65 } catch (MalformedURLException e) {
71 e.printStackTrace(); 66 e.printStackTrace();
72 } catch (IOException e) { 67 } catch (IOException e) {
@@ -75,30 +70,27 @@ public class Descarrega extends AsyncTask&lt;Object, Object, Object&gt; { @@ -75,30 +70,27 @@ public class Descarrega extends AsyncTask&lt;Object, Object, Object&gt; {
75 } 70 }
76 71
77 protected String doInBackground(String u) throws IOException { 72 protected String doInBackground(String u) throws IOException {
  73 + //Descarrega un arxiu i el retorna en un String
78 this.url = u; 74 this.url = u;
79 html = ""; 75 html = "";
80 -  
81 - URLConnection conn = new URL(url).openConnection();  
82 - BufferedReader in = new BufferedReader(new InputStreamReader(  
83 - conn.getInputStream()));  
84 - Log.d(TAG, "\nDescarregant: \n");  
85 - Log.d(TAG,  
86 - ">> URL: " + url + " >> Tamany: " + conn.getContentLength()  
87 - + " bytes");  
88 - String inputLine;  
89 - while ((inputLine = in.readLine()) != null) {  
90 - html = html + "\n" + inputLine;  
91 - }  
92 - Log.d(TAG, "Descarrega finalitzada");  
93 -  
94 - in.close(); 76 + //Iniciem la connexiรณ i creem els Streams
  77 + URLConnection conn = new URL(url).openConnection();
  78 + BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  79 + //Iniciem la descarrega i anem guardant al String
  80 + Log.d(TAG, "\nDescarregant: \n");
  81 + Log.d(TAG, ">> URL: " + url + " >> Tamany: " + conn.getContentLength()+ " bytes");
  82 + String inputLine;
  83 + while ((inputLine = in.readLine()) != null) {
  84 + html = html + "\n" + inputLine;
  85 + }
  86 + Log.d(TAG, "Descarrega finalitzada");
  87 + in.close();
95 return html; 88 return html;
96 -  
97 } 89 }
98 90
99 @Override 91 @Override
100 protected Object doInBackground(Object... arg0) { 92 protected Object doInBackground(Object... arg0) {
101 - 93 + //Metode Overrided, no te utilitat
102 return null; 94 return null;
103 } 95 }
104 } 96 }
src/com/upc/pbe/upcnews/Directoris.java
@@ -17,71 +17,44 @@ import android.widget.TextView; @@ -17,71 +17,44 @@ import android.widget.TextView;
17 import android.widget.AdapterView.OnItemClickListener; 17 import android.widget.AdapterView.OnItemClickListener;
18 import android.widget.Toast; 18 import android.widget.Toast;
19 19
20 -public class Directoris extends Activity implements OnItemClickListener  
21 -{ 20 +//Segona Activity, mostra els directoris i arxius del servidor
  21 +public class Directoris extends Activity implements OnItemClickListener {
  22 +
22 final static String TAG = "Directoris"; 23 final static String TAG = "Directoris";
23 private Descarrega d = new Descarrega(); 24 private Descarrega d = new Descarrega();
24 - private String URL;  
25 - private String currentFolder; 25 + private String URL, currentFolder;
26 private HTMLParser parser; 26 private HTMLParser parser;
27 27
28 - public void onCreate(Bundle savedInstanceState)  
29 - { 28 + public void onCreate(Bundle savedInstanceState){
  29 + //Creem el layout
30 Log.d(TAG, "onCreated"); 30 Log.d(TAG, "onCreated");
31 -  
32 -  
33 super.onCreate(savedInstanceState); 31 super.onCreate(savedInstanceState);
  32 + //Passem del layout anterior al actual
34 setContentView(R.layout.dirs); 33 setContentView(R.layout.dirs);
35 - 34 + //Canviem la direccio de la URL a la actual
36 currentFolder = ((UpcApp) getApplication()).getUrl() + "/"; 35 currentFolder = ((UpcApp) getApplication()).getUrl() + "/";
37 URL = currentFolder; 36 URL = currentFolder;
  37 + //Creem un HTMLParser
38 parser = new HTMLParser(URL); 38 parser = new HTMLParser(URL);
39 - 39 + //Fem una llista ListView i la omplim amb la informacio trobada
40 ((ListView)findViewById(R.id.listView1)).setOnItemClickListener(this); 40 ((ListView)findViewById(R.id.listView1)).setOnItemClickListener(this);
41 -  
42 this.showResources(); 41 this.showResources();
43 } 42 }
44 -  
45 - public boolean onCreateOptionsMenu(Menu menu)  
46 - {  
47 - getMenuInflater().inflate(R.menu.menu, menu);  
48 - Log.d(TAG, "Menu");  
49 - return true;  
50 - }  
51 -  
52 - public boolean onOptionsItemSelected(MenuItem item)  
53 - {  
54 - switch (item.getItemId())  
55 - {  
56 - case R.id.itemprefs:  
57 - startActivity(new Intent(this, Prefs.class));  
58 - Log.d(TAG, "Preferences");  
59 - return true;  
60 - case R.id.itemhelp:  
61 - startActivity(new Intent(this, Help.class));  
62 - Log.d(TAG, "Help");  
63 - return true;  
64 - default:  
65 - return false;  
66 - }  
67 - }  
68 43
69 - public void showResources()  
70 - { 44 + public void showResources(){
  45 + //Actualitza la informacio que mostra la ListView a mesura que ens desplacem pels directoris
71 ArrayList<String> entries; 46 ArrayList<String> entries;
72 - try  
73 - { 47 + try{
74 entries = parser.parse(d.doInBackground(currentFolder)); 48 entries = parser.parse(d.doInBackground(currentFolder));
75 this.createEntries(entries); 49 this.createEntries(entries);
76 } 50 }
77 - catch (IOException e)  
78 - {  
79 - // Nunca llegarรƒยก aquรƒยญ la cosa, y si lo hace ES CULPA DEL SERVIDOR!! 51 + catch (IOException e){
  52 + // Nunca llegara aqui la cosa, y si lo hace ES CULPA DEL SERVIDOR!!
80 } 53 }
81 } 54 }
82 55
83 - public void createEntries(ArrayList<String> directories)  
84 - { 56 + public void createEntries(ArrayList<String> directories){
  57 + //Crea les entrades de la ListView
85 String[] entries = directories.toArray(new String[directories.size()]); 58 String[] entries = directories.toArray(new String[directories.size()]);
86 ListView listView = (ListView) findViewById(R.id.listView1); 59 ListView listView = (ListView) findViewById(R.id.listView1);
87 listView.setAdapter(null); 60 listView.setAdapter(null);
@@ -89,68 +62,79 @@ public class Directoris extends Activity implements OnItemClickListener @@ -89,68 +62,79 @@ public class Directoris extends Activity implements OnItemClickListener
89 listView.setAdapter(adapter); 62 listView.setAdapter(adapter);
90 } 63 }
91 64
92 - public void onItemClick(AdapterView<?> parent, View view, int position, long id)  
93 - { 65 + public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  66 + //Determina el funcionament al clickar en una de les entrades de al ListView
94 String path = ((TextView)view).getText().toString(); 67 String path = ((TextView)view).getText().toString();
95 - if(path.endsWith(".m3u8"))  
96 - { 68 + //Si es un m3u8, el descarrega, parseja i inicia la reproducciรณ
  69 + if(path.endsWith(".m3u8")){
97 path = currentFolder + path; 70 path = currentFolder + path;
98 String playlist; 71 String playlist;
99 - try  
100 - {  
101 - playlist = d.doInBackground(path);  
102 - 72 + try{
  73 + playlist = d.doInBackground(path);
103 Parser p = new Parser(path.substring(0, path.lastIndexOf("/") + 1), this); 74 Parser p = new Parser(path.substring(0, path.lastIndexOf("/") + 1), this);
104 - try  
105 - { 75 + try{
106 ArrayList<ParentList> m3u8parsed = p.parseFile(playlist); 76 ArrayList<ParentList> m3u8parsed = p.parseFile(playlist);
107 Log.d(TAG, "parsing completed"); 77 Log.d(TAG, "parsing completed");
108 HLS h = new HLS(m3u8parsed,((UpcApp)getApplication()).getLocalPath()); 78 HLS h = new HLS(m3u8parsed,((UpcApp)getApplication()).getLocalPath());
109 h.start(); 79 h.start();
110 } 80 }
111 - catch (ErrorException e)  
112 - { 81 + catch (ErrorException e){
113 Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); 82 Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
114 Log.d(TAG, e.getMessage()); 83 Log.d(TAG, e.getMessage());
115 } 84 }
116 - catch (WarningException e)  
117 - { 85 + catch (WarningException e){
118 Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); 86 Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
119 Log.d(TAG, e.getMessage()); 87 Log.d(TAG, e.getMessage());
120 } 88 }
121 - catch (InfoException e)  
122 - { 89 + catch (InfoException e){
123 Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); 90 Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
124 Log.d(TAG, e.getMessage()); 91 Log.d(TAG, e.getMessage());
125 } 92 }
126 } 93 }
127 - catch (IOException e1)  
128 - {  
129 - // Nunca llegarรƒยก aquรƒยญ la cosa, y si lo hace ES CULPA DEL SERVIDOR!! 94 + catch (IOException e1){
  95 + // Nunca llegara aqui la cosa, y si lo hace ES CULPA DEL SERVIDOR!!
130 } 96 }
131 97
132 } 98 }
133 - else //Se trata de una carpeta  
134 - {  
135 - if(!path.startsWith("http://"))  
136 - { 99 + //Si es una carpeta, hi entra i mostra el seu contingut
  100 + else{
  101 + if(!path.startsWith("http://")){
137 currentFolder += path; 102 currentFolder += path;
138 } 103 }
139 - else  
140 - { 104 + else{
141 currentFolder = path; 105 currentFolder = path;
142 } 106 }
143 showResources(); 107 showResources();
144 } 108 }
145 - }  
146 - 109 + }
  110 +
  111 + public boolean onCreateOptionsMenu(Menu menu){
  112 + //Determina el funcionament al apretar la tecla d'opcions
  113 + getMenuInflater().inflate(R.menu.menu, menu);
  114 + Log.d(TAG, "Menu");
  115 + return true;
  116 + }
  117 +
  118 + public boolean onOptionsItemSelected(MenuItem item){
  119 + //Determina el funcionament al clickar en el menu d'opcions
  120 + switch (item.getItemId()){
  121 + case R.id.itemprefs:
  122 + startActivity(new Intent(this, Prefs.class));
  123 + Log.d(TAG, "Preferences");
  124 + return true;
  125 + case R.id.itemhelp:
  126 + startActivity(new Intent(this, Help.class));
  127 + Log.d(TAG, "Help");
  128 + return true;
  129 + default:
  130 + return false;
  131 + }
  132 + }
147 133
148 -  
149 public boolean onKeyDown(int keyCode, KeyEvent event) { 134 public boolean onKeyDown(int keyCode, KeyEvent event) {
150 - if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)  
151 - {  
152 - if(currentFolder.equals(URL))  
153 - { 135 + //Determina el funcionament al apretar la tecla de tornar enrere
  136 + if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0){
  137 + if(currentFolder.equals(URL)){
154 super.finish(); 138 super.finish();
155 return true; 139 return true;
156 } 140 }
src/com/upc/pbe/upcnews/ErrorException.java
1 package com.upc.pbe.upcnews; 1 package com.upc.pbe.upcnews;
2 2
3 -public class ErrorException extends Exception  
4 -{ 3 +//Excepcio d'error critic, finalitza l'aplicacio
  4 +public class ErrorException extends Exception {
  5 +
5 private static final long serialVersionUID = 1L; 6 private static final long serialVersionUID = 1L;
6 - public ErrorException(String message)  
7 - { 7 +
  8 + public ErrorException(String message){
8 super(message); 9 super(message);
9 } 10 }
10 } 11 }
src/com/upc/pbe/upcnews/HLS.java
@@ -4,20 +4,20 @@ import java.util.ArrayList; @@ -4,20 +4,20 @@ import java.util.ArrayList;
4 4
5 import android.util.Log; 5 import android.util.Log;
6 6
  7 +//Gestor del protocol HTTP Live Streaming
7 public class HLS { 8 public class HLS {
8 9
9 private static final String TAG = "HLS"; 10 private static final String TAG = "HLS";
10 private ArrayList<ParentList> videos; 11 private ArrayList<ParentList> videos;
11 private int currentVideo ; 12 private int currentVideo ;
12 - private int currentQuality; //0 es la mรกs alta 13 + private int currentQuality; //0 es la mas alta
13 private int currentSegment; 14 private int currentSegment;
14 private boolean endReached; 15 private boolean endReached;
15 private String localFolder; 16 private String localFolder;
16 //private fileDownloader fd; 17 //private fileDownloader fd;
17 private BandwidthMeasurer bm; 18 private BandwidthMeasurer bm;
18 19
19 - public HLS(ArrayList<ParentList> parsed, String localFolder)  
20 - { 20 + public HLS(ArrayList<ParentList> parsed, String localFolder){
21 currentVideo = currentQuality = currentSegment = 0; 21 currentVideo = currentQuality = currentSegment = 0;
22 this.videos = parsed; 22 this.videos = parsed;
23 endReached = false; 23 endReached = false;
@@ -25,32 +25,26 @@ public class HLS { @@ -25,32 +25,26 @@ public class HLS {
25 bm = new BandwidthMeasurer(); 25 bm = new BandwidthMeasurer();
26 } 26 }
27 27
28 - public void start()  
29 - {  
30 - for(currentVideo = 0; currentVideo < videos.size(); currentVideo++)  
31 - { 28 + public void start(){
  29 + for(currentVideo = 0; currentVideo < videos.size(); currentVideo++){
32 ArrayList<Video> qualities = videos.get(currentVideo++).getLists(); 30 ArrayList<Video> qualities = videos.get(currentVideo++).getLists();
33 - while(!endReached)  
34 - { 31 + while(!endReached){
35 ArrayList<Segment> segments = qualities.get(currentQuality).getSegments(); 32 ArrayList<Segment> segments = qualities.get(currentQuality).getSegments();
36 - while(true)  
37 - { 33 + while(true){
38 Segment seg = segments.get(currentSegment++); 34 Segment seg = segments.get(currentSegment++);
39 Log.d(TAG, seg.getName() + " " + seg.getURL()); 35 Log.d(TAG, seg.getName() + " " + seg.getURL());
40 long startTime = System.currentTimeMillis(); 36 long startTime = System.currentTimeMillis();
41 //long segmentBytes = fd.Download(seg.getURL(),localFolder); 37 //long segmentBytes = fd.Download(seg.getURL(),localFolder);
42 long segmentBytes = 0; 38 long segmentBytes = 0;
43 double bps = bm.Measure(segmentBytes,startTime); 39 double bps = bm.Measure(segmentBytes,startTime);
44 - if((bps < qualities.get(currentQuality).getQuality()) && (bps != -1))  
45 - { 40 + if((bps < qualities.get(currentQuality).getQuality()) && (bps != -1)){
46 currentQuality++; 41 currentQuality++;
47 break; 42 break;
48 } 43 }
49 /* 44 /*
50 * REPRODUCIR SEGMENTO 45 * REPRODUCIR SEGMENTO
51 */ 46 */
52 - if(currentSegment == segments.size())  
53 - { 47 + if(currentSegment == segments.size()){
54 endReached = true; 48 endReached = true;
55 break; 49 break;
56 } 50 }
@@ -58,4 +52,4 @@ public class HLS { @@ -58,4 +52,4 @@ public class HLS {
58 } 52 }
59 } 53 }
60 } 54 }
61 -} 55 +}
62 \ No newline at end of file 56 \ No newline at end of file
src/com/upc/pbe/upcnews/HTMLParser.java
@@ -4,23 +4,23 @@ import java.util.ArrayList; @@ -4,23 +4,23 @@ import java.util.ArrayList;
4 4
5 import android.util.Log; 5 import android.util.Log;
6 6
7 -public class HTMLParser  
8 -{ 7 +//Parseja arxius HTML
  8 +public class HTMLParser {
  9 +
9 private final static String TAG = "HTMLParser"; 10 private final static String TAG = "HTMLParser";
10 - private ArrayList<String> resources;  
11 - private String server; 11 + private ArrayList<String> resources; //Llista de recursos trobats
  12 + private String server; //URL Server
12 13
13 - public HTMLParser(String u)  
14 - { 14 + public HTMLParser(String u){
  15 + //Separem host i server en la direccio donada
15 String host = u.substring(7); 16 String host = u.substring(7);
16 server = u.substring(0,host.indexOf("/")+7); 17 server = u.substring(0,host.indexOf("/")+7);
17 resources = new ArrayList<String>(); 18 resources = new ArrayList<String>();
18 } 19 }
19 20
20 - public ArrayList<String> parse(String code)  
21 - {  
22 - if(!resources.isEmpty())  
23 - { 21 + public ArrayList<String> parse(String code){
  22 + //Metode principal, nejetem la llista si hi ha continguts i parsejem
  23 + if(!resources.isEmpty()){
24 resources.clear(); 24 resources.clear();
25 } 25 }
26 parseDirectories(resources,code); 26 parseDirectories(resources,code);
@@ -28,38 +28,28 @@ public class HTMLParser @@ -28,38 +28,28 @@ public class HTMLParser
28 return resources; 28 return resources;
29 } 29 }
30 30
31 - public void parseDirectories(ArrayList<String> resources, String code)  
32 - {  
33 - // Separem el codi en linies 31 + public void parseDirectories(ArrayList<String> resources, String code){
  32 + //Busca directoris en un arxiu HTML
  33 + //Separem el codi en linies
34 String[] split = code.split("\n"); 34 String[] split = code.split("\n");
35 - /*  
36 - * Busquemos el tag <a>, descartando comentarios:  
37 - */  
38 - for (int i = 0; i < split.length; i++)  
39 - {  
40 - while (split[i].startsWith("<!--"))  
41 - {  
42 - if (split[i++].endsWith("-->"))  
43 - { 35 + //Busquem el tag <a>, descartant comentaris:
  36 + for (int i = 0; i < split.length; i++){
  37 + while (split[i].startsWith("<!--")){
  38 + if (split[i++].endsWith("-->")){
44 break; 39 break;
45 } 40 }
46 } 41 }
47 - // Posible comentario descartado  
48 - if (split[i].indexOf("<a ") != -1) //Enlace  
49 - {  
50 - if (split[i].indexOf("href=") != -1) //Esto tiene buena pinta  
51 - {  
52 - String dirpath = split[i].substring(split[i].indexOf("href=\"") + 6); //Eliminamos morralla del principio.  
53 - dirpath = dirpath.substring(0, dirpath.indexOf("\"")); //Quitamos la morralla del final, nos queda el valor de href sรƒยณlo.  
54 - if(dirpath.lastIndexOf("/") != -1) //Mira que sea una carpeta y no un fichero suelto.  
55 - {  
56 - dirpath = dirpath.substring(0,dirpath.lastIndexOf("/")+1); //Elimina parte que no es carpeta  
57 - if(dirpath.startsWith("/"))  
58 - { 42 + // Posible comentari descartat
  43 + if (split[i].indexOf("<a ") != -1){ //Enllaรง
  44 + if (split[i].indexOf("href=") != -1) { //Aixo te bona pinta
  45 + String dirpath = split[i].substring(split[i].indexOf("href=\"") + 6); //Eliminem morralla del principi.
  46 + dirpath = dirpath.substring(0, dirpath.indexOf("\"")); //Treiem la morralla del final, ens queda el valor de href.
  47 + if(dirpath.lastIndexOf("/") != -1) { //Mira que sigui una carpeta y no un arxiu sol.
  48 + dirpath = dirpath.substring(0,dirpath.lastIndexOf("/")+1); //Elimina la part que no es carpeta
  49 + if(dirpath.startsWith("/")){
59 dirpath = server + dirpath; 50 dirpath = server + dirpath;
60 } 51 }
61 - if(!resources.contains(dirpath)) //No seamos repetitivos  
62 - { 52 + if(!resources.contains(dirpath)) { //No siguem repetitius
63 resources.add(dirpath); 53 resources.add(dirpath);
64 } 54 }
65 Log.d(TAG, "DIRECTORY FOUND: " + dirpath); 55 Log.d(TAG, "DIRECTORY FOUND: " + dirpath);
@@ -69,40 +59,32 @@ public class HTMLParser @@ -69,40 +59,32 @@ public class HTMLParser
69 } 59 }
70 } 60 }
71 61
72 - public void parseFiles(ArrayList<String> resources, String code)  
73 - { 62 + public void parseFiles(ArrayList<String> resources, String code){
  63 + //Parseja arxius en un arxiu HTML
  64 + //Separem el codi en linies
74 String[] split = code.split("\n"); 65 String[] split = code.split("\n");
75 - for (int i = 0; i < split.length; i++)  
76 - {  
77 - while (split[i].startsWith("<!--"))  
78 - {  
79 - if (split[i++].endsWith("-->"))  
80 - { 66 + for (int i = 0; i < split.length; i++){
  67 + while (split[i].startsWith("<!--")){
  68 + if (split[i++].endsWith("-->")){
81 break; 69 break;
82 } 70 }
83 } 71 }
84 - // Posible comentario descartado  
85 - if (split[i].contains("<a ")) //Enlace  
86 - {  
87 - if (split[i].contains("href=")) //Esto tiene buena pinta  
88 - {  
89 - String filepath = split[i].substring(split[i].indexOf("href=\"") + 6); //Eliminamos morralla del principio.  
90 - filepath = filepath.substring(0, filepath.indexOf("\"")); //Quitamos la morralla del final, nos queda el valor de href sรƒยณlo.  
91 - if(filepath.endsWith(".m3u8")) //Mira que sea una lista.  
92 - { 72 + // Possible comentari descartat
  73 + if (split[i].contains("<a ")) { //Enllaรง
  74 + if (split[i].contains("href=")) { //Aixo te bona pinta
  75 + String filepath = split[i].substring(split[i].indexOf("href=\"") + 6); //Eliminem morralla del principi.
  76 + filepath = filepath.substring(0, filepath.indexOf("\"")); //Treiem la morralla del final, ens queda el valor de href.
  77 + if(filepath.endsWith(".m3u8")) { //Mira que sigui una llista.
93 String filename; 78 String filename;
94 - //Deteccion de ficheros ocultos  
95 - if(filepath.indexOf("/") != -1)  
96 - { 79 + //Deteccio d'arxius ocults
  80 + if(filepath.indexOf("/") != -1){
97 filename = filepath.substring(filepath.lastIndexOf("/")); 81 filename = filepath.substring(filepath.lastIndexOf("/"));
98 } 82 }
99 - else  
100 - { 83 + else{
101 filename = filepath; 84 filename = filepath;
102 } 85 }
103 - if(!filename.startsWith("."))  
104 - {  
105 - if(!resources.contains(filepath)) //No seamos repetitivos 86 + if(!filename.startsWith(".")){
  87 + if(!resources.contains(filepath)) //No siguem repetitius
106 { 88 {
107 resources.add(filepath); 89 resources.add(filepath);
108 } 90 }
src/com/upc/pbe/upcnews/Help.java
@@ -3,8 +3,8 @@ package com.upc.pbe.upcnews; @@ -3,8 +3,8 @@ package com.upc.pbe.upcnews;
3 import android.app.Activity; 3 import android.app.Activity;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 import android.util.Log; 5 import android.util.Log;
6 -import android.widget.TextView;  
7 6
  7 +//Menu Help
8 public class Help extends Activity{ 8 public class Help extends Activity{
9 9
10 final static String TAG = "Help"; 10 final static String TAG = "Help";
src/com/upc/pbe/upcnews/InfoException.java
1 package com.upc.pbe.upcnews; 1 package com.upc.pbe.upcnews;
2 2
  3 +//Excepcio que dona informacio util
3 public class InfoException extends Exception 4 public class InfoException extends Exception
4 { 5 {
5 private static final long serialVersionUID = 1L; 6 private static final long serialVersionUID = 1L;
src/com/upc/pbe/upcnews/MainActivity.java
@@ -16,48 +16,35 @@ import android.widget.ImageButton; @@ -16,48 +16,35 @@ import android.widget.ImageButton;
16 import android.widget.TextView; 16 import android.widget.TextView;
17 import android.widget.Toast; 17 import android.widget.Toast;
18 18
  19 +//Finestra incial i principal del programa
19 public class MainActivity extends Activity implements OnClickListener { 20 public class MainActivity extends Activity implements OnClickListener {
  21 +
20 private final static String TAG = "Main"; 22 private final static String TAG = "Main";
21 private static String html; 23 private static String html;
22 private ImageButton buttonDescarrega; 24 private ImageButton buttonDescarrega;
23 private TextView URLText; 25 private TextView URLText;
24 -  
25 26
26 @Override 27 @Override
27 - public void onCreate(Bundle savedInstanceState)  
28 - { 28 + public void onCreate(Bundle savedInstanceState){
  29 + //Creem el layout
29 super.onCreate(savedInstanceState); 30 super.onCreate(savedInstanceState);
30 setContentView(R.layout.main_activity); 31 setContentView(R.layout.main_activity);
31 Log.d(TAG, "onCreated"); 32 Log.d(TAG, "onCreated");
  33 + //Especifiquem la ruta de descร rrega
32 File tempFolder = new File(((UpcApp)getApplication()).getLocalPath()); 34 File tempFolder = new File(((UpcApp)getApplication()).getLocalPath());
33 if(tempFolder.mkdirs()) 35 if(tempFolder.mkdirs())
34 { 36 {
35 Log.d(TAG,"Directory " + tempFolder.toString() + " created"); 37 Log.d(TAG,"Directory " + tempFolder.toString() + " created");
36 } 38 }
  39 + //Creem els botons i text
37 URLText = (TextView) findViewById(R.id.textViewUrl); 40 URLText = (TextView) findViewById(R.id.textViewUrl);
38 buttonDescarrega = (ImageButton) findViewById(R.id.button); 41 buttonDescarrega = (ImageButton) findViewById(R.id.button);
39 buttonDescarrega.setOnClickListener(this); 42 buttonDescarrega.setOnClickListener(this);
40 updateURL(); 43 updateURL();
41 } 44 }
42 45
43 - public void onResume()  
44 - {  
45 - super.onResume();  
46 - updateURL();  
47 - }  
48 -  
49 - public void updateURL()  
50 - {  
51 - URLText.setText(((UpcApp)getApplication()).getUrl());  
52 - }  
53 -  
54 - public boolean onCreateOptionsMenu(Menu menu) {  
55 - getMenuInflater().inflate(R.menu.menu, menu);  
56 - Log.d(TAG, "Menu");  
57 - return true;  
58 - }  
59 -  
60 public void onClick(View v) { 46 public void onClick(View v) {
  47 + //Al polsar el boto s'inicia la descarrega
61 Log.d(TAG, "onClicked"); 48 Log.d(TAG, "onClicked");
62 this.descarregar(); 49 this.descarregar();
63 if(!html.equals("EMPTY")) 50 if(!html.equals("EMPTY"))
@@ -66,8 +53,10 @@ public class MainActivity extends Activity implements OnClickListener { @@ -66,8 +53,10 @@ public class MainActivity extends Activity implements OnClickListener {
66 startActivity(new Intent(this, Directoris.class)); 53 startActivity(new Intent(this, Directoris.class));
67 } 54 }
68 } 55 }
69 - 56 +
70 public void descarregar() { 57 public void descarregar() {
  58 + //Descarrega del document HTML de la URL especificada
  59 + //Si hi ha errors, els mostrem en Toasts
71 Descarrega d = new Descarrega(); 60 Descarrega d = new Descarrega();
72 html="EMPTY"; 61 html="EMPTY";
73 try 62 try
@@ -83,8 +72,25 @@ public class MainActivity extends Activity implements OnClickListener { @@ -83,8 +72,25 @@ public class MainActivity extends Activity implements OnClickListener {
83 Toast.makeText(this, "Can't find URL", Toast.LENGTH_LONG).show(); 72 Toast.makeText(this, "Can't find URL", Toast.LENGTH_LONG).show();
84 } 73 }
85 } 74 }
  75 +
  76 + public void onResume(){
  77 + super.onResume();
  78 + updateURL();
  79 + }
  80 +
  81 + public void updateURL(){
  82 + URLText.setText(((UpcApp)getApplication()).getUrl());
  83 + }
  84 +
  85 + public boolean onCreateOptionsMenu(Menu menu) {
  86 + //Determina el funcionament al apretar la tecla d'opcions
  87 + getMenuInflater().inflate(R.menu.menu, menu);
  88 + Log.d(TAG, "Menu");
  89 + return true;
  90 + }
86 91
87 public boolean onOptionsItemSelected(MenuItem item) { 92 public boolean onOptionsItemSelected(MenuItem item) {
  93 + //Determina el funcionament al clickar en el menu d'opcions
88 switch (item.getItemId()) { 94 switch (item.getItemId()) {
89 case R.id.itemprefs: 95 case R.id.itemprefs:
90 startActivity(new Intent(this, Prefs.class)); 96 startActivity(new Intent(this, Prefs.class));
src/com/upc/pbe/upcnews/ParentList.java
@@ -7,7 +7,7 @@ public class ParentList @@ -7,7 +7,7 @@ public class ParentList
7 private String ID; 7 private String ID;
8 private int currentQuality; 8 private int currentQuality;
9 private String Type, Name; 9 private String Type, Name;
10 - private boolean Default; //Estos 3 รบltimos son para los ext-x-media, los ext-x-stream lo IGNORAN 10 + private boolean Default; //Estos 3 ultimos son para los ext-x-media, los ext-x-stream lo IGNORAN
11 private ArrayList<Video> lists; //per cada qualitat 11 private ArrayList<Video> lists; //per cada qualitat
12 12
13 13
@@ -71,6 +71,4 @@ public class ParentList @@ -71,6 +71,4 @@ public class ParentList
71 { 71 {
72 return lists; 72 return lists;
73 } 73 }
74 -  
75 -  
76 -} 74 +}
77 \ No newline at end of file 75 \ No newline at end of file
src/com/upc/pbe/upcnews/Parser.java
@@ -7,63 +7,51 @@ import java.util.ArrayList; @@ -7,63 +7,51 @@ import java.util.ArrayList;
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.widget.Toast; 8 import android.widget.Toast;
9 9
10 -public class Parser  
11 -{ 10 +//Parser d'arxius m3u8
  11 +public class Parser{
  12 +
12 private static final String STARTWORD = "#EXTM3U"; 13 private static final String STARTWORD = "#EXTM3U";
13 - private String path; // CWD, completes implicit paths such as "file.m3u8"  
14 - // appending the CWD in order to download the file  
15 - private int fileType; // indicates if segment list or media list 14 + private String path; //CWD, completes implicit paths such as "file.m3u8" appending the CWD in order to download the file
  15 + private int fileType; //Indica si es segment list o media list
16 private int currentLine; 16 private int currentLine;
17 - private int currentSegment; // Cada segmento de cada calidad distinta  
18 - private int currentList; // Indice de cada recurso distinto 17 + private int currentSegment; //Cada segment de cada qualitat distinta
  18 + private int currentList; //Index de cada recurso distint
19 private boolean expectSegment = false; 19 private boolean expectSegment = false;
20 private boolean expectList = false; 20 private boolean expectList = false;
21 private Descarrega download; 21 private Descarrega download;
22 - private Activity caller; // Where to send notifications and warnings  
23 - private boolean validated; // Wether if list starts with #EXTM3U or not 22 + private Activity caller; //On enviar les notificacions i warnings
  23 + private boolean validated; //Indica si la llista comenรงa amb #EXTM3U o no
24 24
25 - public Parser(String p, Activity caller)  
26 - { 25 + public Parser(String p, Activity caller){
27 this.caller = caller; 26 this.caller = caller;
28 path = p; 27 path = p;
29 currentLine = 0; 28 currentLine = 0;
30 currentSegment = 0; 29 currentSegment = 0;
31 currentList = 0; 30 currentList = 0;
32 - fileType = -1;  
33 - /*  
34 - * -1 indicates UNDETERMINED 0 indicates SEGMENTS 1 indicates MEDIA  
35 - */ 31 + fileType = -1;//-1 indica UNDETERMINED, 0 indica SEGMENTS, 1 indica MEDIA
36 download = new Descarrega(); 32 download = new Descarrega();
37 validated = false; 33 validated = false;
38 } 34 }
39 35
40 - public ArrayList<ParentList> parseFile(String file) throws ErrorException, WarningException, InfoException  
41 - { 36 + public ArrayList<ParentList> parseFile(String file) throws ErrorException, WarningException, InfoException {
  37 + //Parseja un arxiu m3u8
42 ArrayList<ParentList> lists = new ArrayList<ParentList>(); 38 ArrayList<ParentList> lists = new ArrayList<ParentList>();
43 lists.add(new ParentList("")); 39 lists.add(new ParentList(""));
44 lists.get(0).getLists().add(new Video(-1)); 40 lists.get(0).getLists().add(new Video(-1));
45 String[] lines = file.split("\n"); 41 String[] lines = file.split("\n");
46 - for (int i = 0; i < lines.length; i++)  
47 - {  
48 - if (lines[i].endsWith("\\"))  
49 - {  
50 - /*  
51 - * Merge multiline entries, which are those lines ending with  
52 - * backslash.  
53 - */ 42 + for (int i = 0; i < lines.length; i++){
  43 + if (lines[i].endsWith("\\")){
  44 + //Barreja les entrades multilinea, que son les que acaben en backslash
54 lines[++i] = lines[i - 1].substring(0, lines[i - 1].indexOf("\\") - 1) 45 lines[++i] = lines[i - 1].substring(0, lines[i - 1].indexOf("\\") - 1)
55 + lines[i]; 46 + lines[i];
56 } 47 }
57 - try  
58 - { 48 + try{
59 parseLine(lines[i], lists); 49 parseLine(lines[i], lists);
60 } 50 }
61 - catch (InfoException iE)  
62 - { 51 + catch (InfoException iE){
63 Toast.makeText(caller, iE.getMessage(), Toast.LENGTH_SHORT).show(); 52 Toast.makeText(caller, iE.getMessage(), Toast.LENGTH_SHORT).show();
64 } 53 }
65 - catch (WarningException wE)  
66 - { 54 + catch (WarningException wE){
67 Toast.makeText(caller, wE.getMessage(), Toast.LENGTH_SHORT).show(); 55 Toast.makeText(caller, wE.getMessage(), Toast.LENGTH_SHORT).show();
68 } 56 }
69 } 57 }
@@ -73,20 +61,18 @@ public class Parser @@ -73,20 +61,18 @@ public class Parser
73 * Si no te gusta mis VERSOS, 61 * Si no te gusta mis VERSOS,
74 * te mando a la mierda sin SUTILIDADES. 62 * te mando a la mierda sin SUTILIDADES.
75 * 63 *
76 - * -- Imanol, hasta las cejas de cafeรƒยญna. 64 + * -- Imanol, hasta las cejas de cafeina.
77 * 65 *
78 - * PD: En el รƒยบltimo nivel de profundidad hay una lista de segmentos  
79 - * (debajo de calidades). Allรƒยญ estรƒยก el autรƒยฉntico tesoro de Narnia. 66 + * PD: En el ultimo nivel de profundidad hay una lista de segmentos
  67 + * (debajo de calidades). Alli esta el autentico tesoro de Narnia.
80 */ 68 */
81 - for (int i = 0; i < lists.size(); i++)  
82 - { 69 + for (int i = 0; i < lists.size(); i++){
83 sortQuality(lists.get(i)); 70 sortQuality(lists.get(i));
84 } 71 }
85 return lists; 72 return lists;
86 } 73 }
87 74
88 - private int searchID(String ID, ArrayList<ParentList> lists)  
89 - { 75 + private int searchID(String ID, ArrayList<ParentList> lists){
90 for (int i = 0; i < lists.size(); i++) 76 for (int i = 0; i < lists.size(); i++)
91 { 77 {
92 if (lists.get(i).getID().equals(ID)) 78 if (lists.get(i).getID().equals(ID))
@@ -97,159 +83,110 @@ public class Parser @@ -97,159 +83,110 @@ public class Parser
97 return -1; 83 return -1;
98 } 84 }
99 85
100 - private void sortQuality(ParentList ppls)  
101 - { 86 + private void sortQuality(ParentList ppls){
102 ArrayList<Video> lists = ppls.getLists(); 87 ArrayList<Video> lists = ppls.getLists();
103 - if (lists.get(0).getQuality() == -1)  
104 - {  
105 - /*  
106 - * That's the case of Media lists and Segment lists, they don't have  
107 - * distinct qualities.  
108 - */ 88 + if (lists.get(0).getQuality() == -1){
  89 + //Es el cas de Media Lists i Segment Lists, no tenen diferenciacio de qualitats
109 return; 90 return;
110 } 91 }
111 - // Bubblesort  
112 - while (true)  
113 - { 92 + //Bubblesort
  93 + while (true){
114 boolean sorted = true; 94 boolean sorted = true;
115 int i = 0; 95 int i = 0;
116 - do  
117 - {  
118 - if (lists.get(i).getQuality() < lists.get(i + 1).getQuality())  
119 - { 96 + do{
  97 + if (lists.get(i).getQuality() < lists.get(i + 1).getQuality()){
120 sorted = false; 98 sorted = false;
121 Video aux = lists.get(i); 99 Video aux = lists.get(i);
122 lists.set(i, lists.get(i + 1)); 100 lists.set(i, lists.get(i + 1));
123 lists.set(i + 1, aux); 101 lists.set(i + 1, aux);
124 } 102 }
125 103
126 - }  
127 - while (++i != lists.size() - 1);  
128 - if (sorted)  
129 - { 104 + }while (++i != lists.size() - 1);
  105 + if (sorted){
130 break; 106 break;
131 } 107 }
132 } 108 }
133 109
134 } 110 }
135 111
136 - public void parseLine(String line, ArrayList<ParentList> lists) throws ErrorException, WarningException, InfoException  
137 - {  
138 - if (line.isEmpty())  
139 - { 112 + public void parseLine(String line, ArrayList<ParentList> lists) throws ErrorException, WarningException, InfoException {
  113 + //Parseja una linea de l'arxiu
  114 + if (line.isEmpty()){
140 currentLine++; 115 currentLine++;
141 return; 116 return;
142 } 117 }
143 - else  
144 - { 118 + else{
145 ParentList ppls = lists.get(currentList); 119 ParentList ppls = lists.get(currentList);
146 Video pls = ppls.getLists().get(ppls.getLists().size() - 1); 120 Video pls = ppls.getLists().get(ppls.getLists().size() - 1);
147 - if (!validated)  
148 - {  
149 - if (line.equals(STARTWORD))  
150 - { 121 + if (!validated){
  122 + if (line.equals(STARTWORD)){
151 validated = true; 123 validated = true;
152 } 124 }
153 - else  
154 - {  
155 - throw new ErrorException("Playlist is not valid"); 125 + else{
  126 + throw new ErrorException("Playlist no valida");
156 } 127 }
157 } 128 }
158 - else  
159 - {  
160 - if (line.charAt(0) == '#')  
161 - {  
162 - if (line.substring(0, 4).equals("#EXT"))  
163 - {  
164 - if (expectSegment && !line.startsWith("#EXT-X-BYTERANGE"))  
165 - {  
166 - throw new ErrorException("Expected segment URI, got an EXT-TAG instead"); 129 + else{
  130 + if (line.charAt(0) == '#'){
  131 + if (line.substring(0, 4).equals("#EXT")){
  132 + if (expectSegment && !line.startsWith("#EXT-X-BYTERANGE")){
  133 + throw new ErrorException("S'esperava segment URI, en comptes tenim EXT-TAG");
167 } 134 }
168 - if (expectList)  
169 - {  
170 - throw new ErrorException("Expected List, got an EXT-TAG instead"); 135 + if (expectList){
  136 + throw new ErrorException("S'esperava llista, en comptes tenim EXT-TAG");
171 } 137 }
172 String[] extTag = line.split(":", 2); 138 String[] extTag = line.split(":", 2);
173 - if (extTag[0].equals("#EXT-X-MEDIA-SEQUENCE"))  
174 - { 139 + if (extTag[0].equals("#EXT-X-MEDIA-SEQUENCE")){
175 pls.setSequence(Integer.parseInt(extTag[1])); 140 pls.setSequence(Integer.parseInt(extTag[1]));
176 } 141 }
177 - else if (extTag[0].equals("#EXT-X-TARGETDURATION"))  
178 - { 142 + else if (extTag[0].equals("#EXT-X-TARGETDURATION")){
179 pls.setMaxDuration(Integer.parseInt(extTag[1])); 143 pls.setMaxDuration(Integer.parseInt(extTag[1]));
180 } 144 }
181 - else if (extTag[0].equals("#EXTINF"))  
182 - {  
183 - if (fileType == -1)  
184 - { 145 + else if (extTag[0].equals("#EXTINF")){
  146 + if (fileType == -1){
185 fileType = 0; 147 fileType = 0;
186 } 148 }
187 - else if (fileType == 1)  
188 - {  
189 - throw new ErrorException("Invalid file, should contain Lists, "  
190 - + "but segments were found."); 149 + else if (fileType == 1){
  150 + throw new ErrorException("Arxiu invalid, hauria de contenir llistes pero s'han trobat segments");
191 } 151 }
192 String[] args = extTag[1].split(","); 152 String[] args = extTag[1].split(",");
193 float duration = Float.parseFloat(args[0]); 153 float duration = Float.parseFloat(args[0]);
194 - if (duration > pls.getMaxDuration())  
195 - {  
196 - throw new ErrorException("Segment "  
197 - + currentSegment + 1 + " on line "  
198 - + currentLine + " exceeds max duration"); 154 + if (duration > pls.getMaxDuration()){
  155 + throw new ErrorException("Segment " + currentSegment + 1 + " en linea " + currentLine + " supera la duracio maxima");
199 } 156 }
200 Segment s = new Segment(duration); 157 Segment s = new Segment(duration);
201 - if (args.length == 1)  
202 - { 158 + if (args.length == 1){
203 s.setName(""); 159 s.setName("");
204 } 160 }
205 - else  
206 - { 161 + else{
207 s.setName(args[1]); 162 s.setName(args[1]);
208 } 163 }
209 pls.getSegments().add(s); 164 pls.getSegments().add(s);
210 expectSegment = true; 165 expectSegment = true;
211 } 166 }
212 -  
213 - else if (extTag[0].equals("#EXT-X-STREAM-INF"))  
214 - {  
215 - if (fileType == -1)  
216 - { 167 + else if (extTag[0].equals("#EXT-X-STREAM-INF")){
  168 + if (fileType == -1){
217 fileType = 1; 169 fileType = 1;
218 } 170 }
219 - else if (fileType == 0)  
220 - {  
221 - throw new ErrorException("Invalid file, should contain Segments, "  
222 - + "but lists were found."); 171 + else if (fileType == 0){
  172 + throw new ErrorException("Arxiu invalid, hauria de contenir segments pero s'han trobat llistes");
223 } 173 }
224 expectList = true; 174 expectList = true;
225 String programID = ""; 175 String programID = "";
226 double bandwidth = -1; 176 double bandwidth = -1;
227 String[] arguments = extTag[1].split(","); 177 String[] arguments = extTag[1].split(",");
228 - for (int i = 0; i < arguments.length; i++)  
229 - { 178 + for (int i = 0; i < arguments.length; i++){
230 String[] argument = arguments[i].split("="); 179 String[] argument = arguments[i].split("=");
231 - /*  
232 - * In case current argument contains several  
233 - * values like "val1,val2,val3" detect the "  
234 - * character and merge them all in one single  
235 - * string  
236 - */  
237 - if (argument[1].startsWith("\"")  
238 - && !argument[1].endsWith("\""))  
239 - { 180 + //Si l'argument en questio conte diferents valors, detecta el caracter " i els ajunta en un String
  181 + if (argument[1].startsWith("\"") && !argument[1].endsWith("\"")){
240 int j = i; 182 int j = i;
241 - while (true)  
242 - {  
243 - if (i == arguments.length - 1)  
244 - {  
245 - throw new ErrorException("Malformed argument on line "  
246 - + currentLine); 183 + while (true){
  184 + if (i == arguments.length - 1){
  185 + throw new ErrorException("Argument mal expressat en linea " + currentLine);
247 } 186 }
248 - if (arguments[++i].endsWith("\""))  
249 - { 187 + if (arguments[++i].endsWith("\"")){
250 String end = arguments[i]; 188 String end = arguments[i];
251 - for (int k = j + 1; k < i; k++)  
252 - { 189 + for (int k = j + 1; k < i; k++){
253 argument[1] += arguments[k]; 190 argument[1] += arguments[k];
254 } 191 }
255 argument[1] += end; 192 argument[1] += end;
@@ -257,44 +194,26 @@ public class Parser @@ -257,44 +194,26 @@ public class Parser
257 } 194 }
258 } 195 }
259 } 196 }
260 - if (argument[0].equals("PROGRAM-ID"))  
261 - { 197 + if (argument[0].equals("PROGRAM-ID")){
262 programID = argument[1]; 198 programID = argument[1];
263 } 199 }
264 - else if (argument[0].equals("BANDWIDTH"))  
265 - { 200 + else if (argument[0].equals("BANDWIDTH")){
266 bandwidth = Double.parseDouble(argument[1]); 201 bandwidth = Double.parseDouble(argument[1]);
267 } 202 }
268 } 203 }
269 - if (programID.equals("") || bandwidth == -1)  
270 - {  
271 - throw new ErrorException("Playlist on line "  
272 - + currentLine  
273 - + " has missing arguments"); 204 + if (programID.equals("") || bandwidth == -1){
  205 + throw new ErrorException("Playlist en linea " + currentLine + " no te arguments");
274 } 206 }
275 - if (!programID.equals(ppls.getID()))  
276 - {  
277 - /*  
278 - * If Program-ID doesn't match, search it or  
279 - * create a new one.  
280 - */  
281 - if (ppls.getID().equals(""))  
282 - {  
283 - /*  
284 - * If working with the default ParentList,  
285 - * then modify it, don't create a new one.  
286 - */ 207 + if (!programID.equals(ppls.getID())){
  208 + //Si el Program-ID no coincideix, buscar o crear un de nou
  209 + if (ppls.getID().equals("")){
  210 + //Si es treballa amb la ParentList per defecte, modificar, no crear una nova
287 lists.get(0).setID(programID); 211 lists.get(0).setID(programID);
288 } 212 }
289 - else  
290 - { 213 + else{
291 currentList = searchID(programID, lists); 214 currentList = searchID(programID, lists);
292 - if (currentList == -1)  
293 - {  
294 - /*  
295 - * ParentList not found, creating a new  
296 - * one.  
297 - */ 215 + if (currentList == -1){
  216 + //No s'ha trobat ParentList, es crea una nova
298 lists.add(new ParentList(programID)); 217 lists.add(new ParentList(programID));
299 currentList = lists.size() - 1; 218 currentList = lists.size() - 1;
300 } 219 }
@@ -302,35 +221,21 @@ public class Parser @@ -302,35 +221,21 @@ public class Parser
302 pls = ppls.getLists().get(ppls.getLists().size() - 1); 221 pls = ppls.getLists().get(ppls.getLists().size() - 1);
303 } 222 }
304 } 223 }
305 - /*  
306 - * Now we create a new List inside the correct  
307 - * ParentList.  
308 - */  
309 - if ((ppls.getLists().size() == 1)  
310 - && (pls.getQuality() == -1)  
311 - && pls.getSegments().isEmpty())  
312 - {  
313 - /*  
314 - * If working with the default List, then modify  
315 - * it, don't create a new one.  
316 - */ 224 + //Creem una List dins el ParentList correcte
  225 + if ((ppls.getLists().size() == 1) && (pls.getQuality() == -1) && pls.getSegments().isEmpty()){
  226 + //Si es treballa amb la List per defecte, modificar, no crear una nova
317 pls.setQuality(bandwidth); 227 pls.setQuality(bandwidth);
318 } 228 }
319 - else  
320 - { 229 + else{
321 ppls.getLists().add(new Video(bandwidth)); 230 ppls.getLists().add(new Video(bandwidth));
322 } 231 }
323 } 232 }
324 - else if (extTag[0].equals("#EXT-X-MEDIA"))  
325 - {  
326 - if (fileType == -1)  
327 - { 233 + else if (extTag[0].equals("#EXT-X-MEDIA")){
  234 + if (fileType == -1){
328 fileType = 1; 235 fileType = 1;
329 } 236 }
330 - else if (fileType == 0)  
331 - {  
332 - throw new ErrorException("Invalid file, should contain Segments, "  
333 - + "but lists were found."); 237 + else if (fileType == 0){
  238 + throw new ErrorException("Arxiu invalid, hauria de contenir segments pero s'han trobat llistes");
334 } 239 }
335 String Type = ""; 240 String Type = "";
336 String Name = ""; 241 String Name = "";
@@ -338,31 +243,18 @@ public class Parser @@ -338,31 +243,18 @@ public class Parser
338 String URI = ""; 243 String URI = "";
339 boolean Default = false; 244 boolean Default = false;
340 String[] arguments = extTag[1].split(","); 245 String[] arguments = extTag[1].split(",");
341 - for (int i = 0; i < arguments.length; i++)  
342 - { 246 + for (int i = 0; i < arguments.length; i++){
343 String[] argument = arguments[i].split("="); 247 String[] argument = arguments[i].split("=");
344 - /*  
345 - * In case current argument contains several  
346 - * values like "val1,val2,val3" detect the "  
347 - * character and merge them all in one single  
348 - * string  
349 - */  
350 - if (argument[1].startsWith("\"")  
351 - && !argument[1].endsWith("\""))  
352 - { 248 + //Si l'argument en questio conte diferents valors, detecta el caracter " i els ajunta en un String
  249 + if (argument[1].startsWith("\"") && !argument[1].endsWith("\"")){
353 int j = i; 250 int j = i;
354 - while (true)  
355 - {  
356 - if (i == arguments.length - 1)  
357 - {  
358 - throw new ErrorException("Malformed argument on line "  
359 - + currentLine); 251 + while (true){
  252 + if (i == arguments.length - 1){
  253 + throw new ErrorException("Argument mal expressat en linea " + currentLine);
360 } 254 }
361 - if (arguments[++i].endsWith("\""))  
362 - { 255 + if (arguments[++i].endsWith("\"")){
363 String end = arguments[i]; 256 String end = arguments[i];
364 - for (int k = j + 1; k < i; k++)  
365 - { 257 + for (int k = j + 1; k < i; k++){
366 argument[1] += arguments[k]; 258 argument[1] += arguments[k];
367 } 259 }
368 argument[1] += end; 260 argument[1] += end;
@@ -370,82 +262,55 @@ public class Parser @@ -370,82 +262,55 @@ public class Parser
370 } 262 }
371 } 263 }
372 } 264 }
373 - if (argument[0].equals("NAME"))  
374 - { 265 + if (argument[0].equals("NAME")){
375 Name = argument[1].substring(1, argument[1].length() - 1); 266 Name = argument[1].substring(1, argument[1].length() - 1);
376 } 267 }
377 - else if (argument[0].equals("TYPE"))  
378 - { 268 + else if (argument[0].equals("TYPE")){
379 Type = argument[1]; 269 Type = argument[1];
380 } 270 }
381 - else if (argument[0].equals("GROUP-ID"))  
382 - { 271 + else if (argument[0].equals("GROUP-ID")){
383 GroupID = argument[1].substring(1, argument[1].length() - 1); 272 GroupID = argument[1].substring(1, argument[1].length() - 1);
384 } 273 }
385 - else if (argument[0].equals("DEFAULT"))  
386 - {  
387 - if (argument[1].equals("YES"))  
388 - { 274 + else if (argument[0].equals("DEFAULT")){
  275 + if (argument[1].equals("YES")){
389 Default = true; 276 Default = true;
390 } 277 }
391 - else if (argument[1].equals("NO"))  
392 - { 278 + else if (argument[1].equals("NO")){
393 Default = true; 279 Default = true;
394 } 280 }
395 - else  
396 - {  
397 - throw new ErrorException("Invalid value for argument DEFAULT on line "  
398 - + currentLine); 281 + else{
  282 + throw new ErrorException("Valor invalid per l'argument DEFAULT en linea " + currentLine);
399 } 283 }
400 } 284 }
401 - else if (argument[0].equals("URI"))  
402 - {  
403 - if (!argument[1].contains("http://"))  
404 - {  
405 - /*  
406 - * In case the path read is RELATIVE  
407 - */  
408 - URI = path  
409 - + argument[1].substring(1, argument[1].length() - 1); 285 + else if (argument[0].equals("URI")){
  286 + if (!argument[1].contains("http://")){
  287 + //En cas de que la ruta llegida es RELATIVE
  288 + URI = path + argument[1].substring(1, argument[1].length() - 1);
410 } 289 }
411 - else  
412 - { 290 + else{
413 URI = argument[1].substring(1, argument[1].length() - 1); 291 URI = argument[1].substring(1, argument[1].length() - 1);
414 } 292 }
415 } 293 }
416 } 294 }
417 - if (Type.equals("") || Name.equals("")  
418 - || URI.equals("") || GroupID.equals(""))  
419 - {  
420 - throw new ErrorException("Playlist on line "  
421 - + currentLine  
422 - + " has missing arguments"); 295 + if (Type.equals("") || Name.equals("") || URI.equals("") || GroupID.equals("")) {
  296 + throw new ErrorException("Playlist en linea " + currentLine + " no te arguments");
423 } 297 }
424 Parser p = new Parser(URI.substring(0, URI.lastIndexOf("/") + 1), caller); 298 Parser p = new Parser(URI.substring(0, URI.lastIndexOf("/") + 1), caller);
425 Video newList; 299 Video newList;
426 - try  
427 - { 300 + try{
428 newList = p.parseFile(download.doInBackground(URI)).get(0).getLists().get(0); 301 newList = p.parseFile(download.doInBackground(URI)).get(0).getLists().get(0);
429 - if (!GroupID.equals(ppls.getID()))  
430 - {  
431 - if (ppls.getID().equals(""))  
432 - {  
433 - /*  
434 - * If working with the default ParentList,  
435 - * then modify it, don't create a new one.  
436 - */ 302 + if (!GroupID.equals(ppls.getID())){
  303 + if (ppls.getID().equals("")){
  304 + //Si es treballa amb la ParentList per defecte, modificar, no crear una nova
437 ppls.setDefault(Default); 305 ppls.setDefault(Default);
438 ppls.setName(Name); 306 ppls.setName(Name);
439 ppls.setType(Type); 307 ppls.setType(Type);
440 ppls.getLists().set(0, newList); 308 ppls.getLists().set(0, newList);
441 ppls.setID(GroupID); 309 ppls.setID(GroupID);
442 } 310 }
443 - else  
444 - {  
445 - 311 + else{
446 currentList = searchID(GroupID, lists); 312 currentList = searchID(GroupID, lists);
447 - if (currentList == -1)  
448 - { 313 + if (currentList == -1){
449 ParentList pl = new ParentList(GroupID); 314 ParentList pl = new ParentList(GroupID);
450 pl.setDefault(Default); 315 pl.setDefault(Default);
451 pl.setName(Name); 316 pl.setName(Name);
@@ -457,92 +322,65 @@ public class Parser @@ -457,92 +322,65 @@ public class Parser
457 ppls.getLists().add(newList); 322 ppls.getLists().add(newList);
458 } 323 }
459 } 324 }
460 - else  
461 - { 325 + else{
462 ppls.getLists().add(newList); 326 ppls.getLists().add(newList);
463 } 327 }
464 } 328 }
465 - catch (IOException e)  
466 - {  
467 - // Nunca llegarรƒยก aquรƒยญ la cosa, y si lo hace ES CULPA DEL SERVIDOR!! 329 + catch (IOException e){
  330 + // Nunca llegara aqui la cosa, y si lo hace ES CULPA DEL SERVIDOR!!
468 } 331 }
469 } 332 }
470 -  
471 - else if (extTag[0].equals("#EXT-X-ENDLIST"))  
472 - {  
473 - if (expectSegment || expectList)  
474 - {  
475 - throw new ErrorException("Unexpected end of list!"); 333 + else if (extTag[0].equals("#EXT-X-ENDLIST")){
  334 + if (expectSegment || expectList){
  335 + throw new ErrorException("Final de llista no esperat!");
476 } 336 }
477 } 337 }
478 -  
479 - else if (extTag[0].equals("#EXT-X-VERSION"))  
480 - {  
481 - // IGNORE 338 + else if (extTag[0].equals("#EXT-X-VERSION")){
  339 + //IGNORE
482 } 340 }
483 -  
484 - else if (extTag[0].equals("#EXT-X-PLAYLIST-TYPE"))  
485 - {  
486 - // IGNORE 341 + else if (extTag[0].equals("#EXT-X-PLAYLIST-TYPE")){
  342 + //IGNORE
487 } 343 }
488 -  
489 - else  
490 - { 344 + else{
491 currentLine++; 345 currentLine++;
492 - throw new WarningException("Tag not implemented: "  
493 - + extTag[0]); 346 + throw new WarningException("Tag no implementat: " + extTag[0]);
494 } 347 }
495 } 348 }
496 - else  
497 - { 349 + else{
498 String comment = line.substring(1); 350 String comment = line.substring(1);
499 - throw new InfoException("Comment on line "  
500 - + currentLine++ + " " + comment); 351 + throw new InfoException("Comentari en linea " + currentLine++ + " " + comment);
501 } 352 }
502 } 353 }
503 - else  
504 - {  
505 - if (expectSegment)  
506 - { 354 + else{
  355 + if (expectSegment){
507 expectSegment = false; 356 expectSegment = false;
508 - try  
509 - { 357 + try{
510 pls.getSegments().get(currentSegment).setURL(line); 358 pls.getSegments().get(currentSegment).setURL(line);
511 } 359 }
512 - catch (MalformedURLException e)  
513 - { 360 + catch (MalformedURLException e){
514 throw new ErrorException(e.getMessage()); 361 throw new ErrorException(e.getMessage());
515 } 362 }
516 currentSegment++; 363 currentSegment++;
517 } 364 }
518 - else if (expectList)  
519 - {  
520 - /*  
521 - * Download list and merge the entries with the current  
522 - * list  
523 - */ 365 + else if (expectList){
  366 + //Descarregar llista i juntar les entrades amb les de la llista actual
524 expectList = false; 367 expectList = false;
525 Parser p = new Parser(line.substring(0, line.lastIndexOf("/") + 1), caller); 368 Parser p = new Parser(line.substring(0, line.lastIndexOf("/") + 1), caller);
526 Video newList; 369 Video newList;
527 - try  
528 - { 370 + try{
529 newList = p.parseFile(download.doInBackground(line)).get(0).getLists().get(0); 371 newList = p.parseFile(download.doInBackground(line)).get(0).getLists().get(0);
530 pls.setMaxDuration(newList.getMaxDuration()); 372 pls.setMaxDuration(newList.getMaxDuration());
531 pls.setSequence(newList.getSequence()); 373 pls.setSequence(newList.getSequence());
532 - for (int i = 0; i < newList.getSegments().size(); i++)  
533 - { 374 + for (int i = 0; i < newList.getSegments().size(); i++){
534 pls.getSegments().add(newList.getSegments().get(i)); 375 pls.getSegments().add(newList.getSegments().get(i));
535 } 376 }
536 } 377 }
537 - catch (IOException e)  
538 - {  
539 - // Nunca llegarรƒยก aquรƒยญ la cosa, y si lo hace ES CULPA DEL SERVIDOR!! 378 + catch (IOException e){
  379 + // Nunca llegara aqui la cosa, y si lo hace ES CULPA DEL SERVIDOR!!
540 } 380 }
541 } 381 }
542 - else  
543 - {  
544 - throw new ErrorException("ERROR: Unexpected string "  
545 - + line); 382 + else{
  383 + throw new ErrorException("ERROR: String no esperat" + line);
546 } 384 }
547 } 385 }
548 } 386 }
src/com/upc/pbe/upcnews/Prefs.java
@@ -4,6 +4,7 @@ import android.os.Bundle; @@ -4,6 +4,7 @@ import android.os.Bundle;
4 import android.preference.PreferenceActivity; 4 import android.preference.PreferenceActivity;
5 import android.util.Log; 5 import android.util.Log;
6 6
  7 +//Menu de preferencies
7 public class Prefs extends PreferenceActivity { 8 public class Prefs extends PreferenceActivity {
8 9
9 final static String TAG = "Preferences"; 10 final static String TAG = "Preferences";
src/com/upc/pbe/upcnews/ResourceAdapter.java
@@ -10,15 +10,14 @@ import android.view.ViewGroup; @@ -10,15 +10,14 @@ import android.view.ViewGroup;
10 import android.widget.ArrayAdapter; 10 import android.widget.ArrayAdapter;
11 import android.widget.TextView; 11 import android.widget.TextView;
12 12
13 -public class ResourceAdapter extends ArrayAdapter<String>  
14 -{ 13 +//Modificacio de l'Adapter d'Adnroid, creat al nostre gust per donar estil als elements de la ListView de directoris i arxius
  14 +public class ResourceAdapter extends ArrayAdapter<String> {
15 15
16 Context context; 16 Context context;
17 int layoutResourceId; 17 int layoutResourceId;
18 String[] entries = null; 18 String[] entries = null;
19 19
20 - public ResourceAdapter(Context context, int layoutResourceId, String[] data)  
21 - { 20 + public ResourceAdapter(Context context, int layoutResourceId, String[] data) {
22 super(context, layoutResourceId, data); 21 super(context, layoutResourceId, data);
23 this.layoutResourceId = layoutResourceId; 22 this.layoutResourceId = layoutResourceId;
24 this.context = context; 23 this.context = context;
@@ -26,29 +25,24 @@ public class ResourceAdapter extends ArrayAdapter&lt;String&gt; @@ -26,29 +25,24 @@ public class ResourceAdapter extends ArrayAdapter&lt;String&gt;
26 } 25 }
27 26
28 @Override 27 @Override
29 - public View getView(int position, View convertView, ViewGroup parent)  
30 - { 28 + public View getView(int position, View convertView, ViewGroup parent) {
31 TextView row; 29 TextView row;
32 30
33 - if (convertView == null)  
34 - { 31 + if (convertView == null) {
35 LayoutInflater inflater = ((Activity)context).getLayoutInflater(); 32 LayoutInflater inflater = ((Activity)context).getLayoutInflater();
36 row = (TextView) inflater.inflate(R.layout.rowlayout, parent, false); 33 row = (TextView) inflater.inflate(R.layout.rowlayout, parent, false);
37 } 34 }
38 - else  
39 - { 35 + else {
40 row = (TextView) convertView; 36 row = (TextView) convertView;
41 } 37 }
42 -  
43 final String text = entries[position]; 38 final String text = entries[position];
44 row.setText(text); 39 row.setText(text);
45 - if(text.endsWith(".m3u8")) //Playlists  
46 - {  
47 - //row.setTypeface(null, Typeface.BOLD); 40 + //Si es un m3u8, posem el text en verd
  41 + if(text.endsWith(".m3u8")) {
48 row.setTextColor(Color.parseColor("#5FB404")); 42 row.setTextColor(Color.parseColor("#5FB404"));
49 } 43 }
50 - else //Normal entries  
51 - { 44 + //Si no, posem el text en blau
  45 + else{
52 row.setTypeface(null,Typeface.NORMAL); 46 row.setTypeface(null,Typeface.NORMAL);
53 row.setTextColor(((Activity)context).getResources().getColor(R.color.BlueAndroid)); 47 row.setTextColor(((Activity)context).getResources().getColor(R.color.BlueAndroid));
54 } 48 }
src/com/upc/pbe/upcnews/Segment.java
@@ -3,39 +3,33 @@ package com.upc.pbe.upcnews; @@ -3,39 +3,33 @@ package com.upc.pbe.upcnews;
3 import java.net.MalformedURLException; 3 import java.net.MalformedURLException;
4 import java.net.URL; 4 import java.net.URL;
5 5
6 -public class Segment  
7 -{ 6 +public class Segment {
  7 +
8 private String name; 8 private String name;
9 private float duration; 9 private float duration;
10 private URL url; 10 private URL url;
11 11
12 - public Segment(float dur)  
13 - { 12 + public Segment(float dur) {
14 name = ""; 13 name = "";
15 duration = dur; 14 duration = dur;
16 } 15 }
17 16
18 - public void setName(String nam)  
19 - { 17 + public void setName(String nam) {
20 name = nam; 18 name = nam;
21 } 19 }
22 20
23 - public String getName()  
24 - { 21 + public String getName() {
25 return name; 22 return name;
26 } 23 }
27 24
28 - public float getDuration()  
29 - { 25 + public float getDuration() {
30 return duration; 26 return duration;
31 } 27 }
32 - public void setURL(String url) throws MalformedURLException  
33 - { 28 + public void setURL(String url) throws MalformedURLException {
34 this.url = new URL(url); 29 this.url = new URL(url);
35 } 30 }
36 31
37 - public String getURL()  
38 - { 32 + public String getURL() {
39 return url.toString(); 33 return url.toString();
40 } 34 }
41 } 35 }
src/com/upc/pbe/upcnews/Video.java
@@ -2,53 +2,43 @@ package com.upc.pbe.upcnews; @@ -2,53 +2,43 @@ package com.upc.pbe.upcnews;
2 2
3 import java.util.ArrayList; 3 import java.util.ArrayList;
4 4
5 -public class Video  
6 -{ 5 +public class Video {
7 6
8 - private double quality; 7 + private double quality; //Indica la qualitat
9 private int sequenceFirst; 8 private int sequenceFirst;
10 private int maxDuration; 9 private int maxDuration;
11 private ArrayList<Segment> segments; //Lista de SEGMENTOS 10 private ArrayList<Segment> segments; //Lista de SEGMENTOS
12 11
13 - public Video(double q)  
14 - { 12 + public Video(double q){
15 quality = q; 13 quality = q;
16 segments = new ArrayList<Segment>(); 14 segments = new ArrayList<Segment>();
17 } 15 }
18 16
19 - public void setSequence(int seq)  
20 - { 17 + public void setSequence(int seq){
21 sequenceFirst = seq; 18 sequenceFirst = seq;
22 } 19 }
23 20
24 - public int getSequence()  
25 - { 21 + public int getSequence(){
26 return sequenceFirst; 22 return sequenceFirst;
27 } 23 }
28 24
29 - public void setMaxDuration(int dur)  
30 - { 25 + public void setMaxDuration(int dur){
31 maxDuration = dur; 26 maxDuration = dur;
32 } 27 }
33 28
34 - public int getMaxDuration()  
35 - { 29 + public int getMaxDuration(){
36 return maxDuration; 30 return maxDuration;
37 } 31 }
38 32
39 - public double getQuality()  
40 - { 33 + public double getQuality(){
41 return quality; 34 return quality;
42 } 35 }
43 36
44 - public void setQuality(double q)  
45 - { 37 + public void setQuality(double q){
46 quality = q; 38 quality = q;
47 } 39 }
48 40
49 - public ArrayList<Segment> getSegments()  
50 - { 41 + public ArrayList<Segment> getSegments(){
51 return segments; 42 return segments;
52 } 43 }
53 -}  
54 - 44 +}
55 \ No newline at end of file 45 \ No newline at end of file
src/com/upc/pbe/upcnews/WarningException.java
1 package com.upc.pbe.upcnews; 1 package com.upc.pbe.upcnews;
2 2
  3 +//Excepcio que indica error no critic, hi ha un error pero es pot continuar amb l'execucio
3 public class WarningException extends Exception 4 public class WarningException extends Exception
4 { 5 {
5 private static final long serialVersionUID = 1L; 6 private static final long serialVersionUID = 1L;