Commit 5878d887ed515a7d4c1d279f5ac279fdc197cf0b
1 parent
625f7d45
--no commit message
Showing
4 changed files
with
35 additions
and
45 deletions
AndroidManifest.xml
... | ... | @@ -9,6 +9,7 @@ |
9 | 9 | <uses-permission android:name="android.permission.INTERNET"/> |
10 | 10 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
11 | 11 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> |
12 | + <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/> | |
12 | 13 | |
13 | 14 | |
14 | 15 | <application | ... | ... |
src/com/upc/pbe/upcnews/Descarrega.java
... | ... | @@ -82,7 +82,6 @@ public class Descarrega extends AsyncTask<Object, Object, Object>{ |
82 | 82 | Log.d(TAG, ">> URL: " + url + " >> Tamany: " + conn.getContentLength() + " bytes"); |
83 | 83 | String inputLine; |
84 | 84 | while ((inputLine = in.readLine()) != null) { |
85 | - //Log.d(TAG, inputLine); | |
86 | 85 | html = html + "\n" + inputLine; |
87 | 86 | } |
88 | 87 | Log.d(TAG, "Descarrega finalitzada"); | ... | ... |
src/com/upc/pbe/upcnews/Directoris.java
... | ... | @@ -36,13 +36,11 @@ public class Directoris extends Activity implements OnClickListener { |
36 | 36 | |
37 | 37 | s = ((UpcApp) getApplication()).getDesc(); |
38 | 38 | |
39 | - | |
40 | 39 | HTMLParser pars = new HTMLParser(); |
41 | 40 | ArrayList<String> dirs = pars.parse(s); |
42 | 41 | |
43 | - Log.d(TAG, dirs.toString()); | |
44 | 42 | for (int i = 0; i < dirs.size(); i++) { |
45 | - Log.d(TAG, "Directori " + i); | |
43 | + Log.d(TAG, "Directori " + dirs.get(i).toString()); | |
46 | 44 | buttons.get(i).setVisibility(View.VISIBLE); |
47 | 45 | buttons.get(i).setText(dirs.get(i)); |
48 | 46 | |
... | ... | @@ -76,56 +74,21 @@ public class Directoris extends Activity implements OnClickListener { |
76 | 74 | switch (c.getId()) { |
77 | 75 | |
78 | 76 | case R.id.button1: { |
79 | - Log.d(TAG, "Click on button1"); | |
80 | - d = new Descarrega(url + "/" + buttons.get(0).getText() + "/", | |
81 | - file, folder); | |
82 | - String str = d.doInBackground(); | |
83 | - | |
84 | - HTMLParser pars = new HTMLParser(); | |
85 | - String urlvideo = pars.findvideo(str, url + "/" | |
86 | - + buttons.get(0).getText() + "/"); | |
87 | - | |
88 | - Log.d(TAG, urlvideo); | |
89 | - | |
90 | - if (urlvideo == "No s'ha trobat") { | |
91 | - Toast.makeText(this, "El directori " + buttons.get(1).getText() + " no conté cap .m3u8", | |
92 | - Toast.LENGTH_LONG).show(); | |
93 | - } else { | |
94 | - d = new Descarrega(urlvideo, file, folder); | |
95 | - String m3u8 = d.doInBackground(); | |
96 | - } | |
97 | - // m3u8 --> PARSE! | |
77 | + this.buttonClicked(buttons.get(0)); | |
98 | 78 | break; |
99 | 79 | |
100 | 80 | } |
101 | 81 | case R.id.button2: { |
102 | - Log.d(TAG, "Click on button2"); | |
103 | - d = new Descarrega(url + "/" + buttons.get(1).getText() + "/", | |
104 | - file, folder); | |
105 | - String str = d.doInBackground(); | |
106 | - | |
107 | - HTMLParser pars = new HTMLParser(); | |
108 | - String urlvideo = pars.findvideo(str, url + "/" | |
109 | - + buttons.get(1).getText() + "/"); | |
110 | - | |
111 | - Log.d(TAG, urlvideo); | |
112 | - | |
113 | - if (urlvideo == "No s'ha trobat") { | |
114 | - Toast.makeText(this, "El directori " + buttons.get(1).getText() + " no conté cap .m3u8", | |
115 | - Toast.LENGTH_LONG).show(); | |
116 | - } else { | |
117 | - | |
118 | - d = new Descarrega(urlvideo, file, folder); | |
119 | - String m3u8 = d.doInBackground(); | |
120 | - } | |
121 | - // m3u8 --> PARSE! | |
82 | + this.buttonClicked(buttons.get(1)); | |
122 | 83 | break; |
123 | 84 | } |
124 | 85 | case R.id.button3: { |
125 | - | |
86 | + this.buttonClicked(buttons.get(2)); | |
87 | + break; | |
126 | 88 | } |
127 | 89 | case R.id.button4: { |
128 | - | |
90 | + this.buttonClicked(buttons.get(3)); | |
91 | + break; | |
129 | 92 | } |
130 | 93 | } |
131 | 94 | } |
... | ... | @@ -143,4 +106,28 @@ public class Directoris extends Activity implements OnClickListener { |
143 | 106 | buttons.get(i).setVisibility(View.GONE); |
144 | 107 | } |
145 | 108 | } |
109 | + | |
110 | + public void buttonClicked(Button b) { | |
111 | + | |
112 | + Log.d(TAG, "Click on " + b.getText()); | |
113 | + d = new Descarrega(url + "/" + b.getText() + "/", file, folder); | |
114 | + String str = d.doInBackground(); | |
115 | + | |
116 | + HTMLParser pars = new HTMLParser(); | |
117 | + String urlvideo = pars.findvideo(str, url + "/" + b.getText() + "/"); | |
118 | + | |
119 | + Log.d(TAG, urlvideo); | |
120 | + | |
121 | + if (urlvideo == "No s'ha trobat") { | |
122 | + Toast.makeText( | |
123 | + this, | |
124 | + "El directori " + b.getText() | |
125 | + + " no conté cap fitxer .m3u8", Toast.LENGTH_LONG) | |
126 | + .show(); | |
127 | + } else { | |
128 | + d = new Descarrega(urlvideo, file, folder); | |
129 | + String m3u8 = d.doInBackground(); | |
130 | + } | |
131 | + // m3u8 --> PARSE! | |
132 | + } | |
146 | 133 | } |
147 | 134 | \ No newline at end of file | ... | ... |
src/com/upc/pbe/upcnews/MainActivity.java
... | ... | @@ -54,11 +54,14 @@ public class MainActivity extends Activity implements OnClickListener { |
54 | 54 | |
55 | 55 | public void onClick(View v) { |
56 | 56 | Log.d(TAG, "onClicked"); |
57 | + | |
58 | + //Wifi Info | |
57 | 59 | wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); |
58 | 60 | WifiInfo info = wifi.getConnectionInfo(); |
59 | 61 | int speed = info.getLinkSpeed(); |
60 | 62 | String str = "Speed: "+speed; |
61 | 63 | Log.d(TAG, str); |
64 | + | |
62 | 65 | this.descarregar(); |
63 | 66 | ((UpcApp) getApplication()).setDesc(html); |
64 | 67 | startActivity(new Intent(this, Directoris.class)); | ... | ... |