Commit 8a6f543ec59cdbc6b95c87562d69407c9c17f5d0
1 parent
0eb8d630
--no commit message
Showing
5 changed files
with
57 additions
and
19 deletions
res/layout/dirs.xml
@@ -7,11 +7,12 @@ | @@ -7,11 +7,12 @@ | ||
7 | android:orientation="vertical" > | 7 | android:orientation="vertical" > |
8 | 8 | ||
9 | <!-- Vista en llista --> | 9 | <!-- Vista en llista --> |
10 | - | 10 | + |
11 | <TextView | 11 | <TextView |
12 | android:id="@+id/textViewTitle" | 12 | android:id="@+id/textViewTitle" |
13 | android:layout_width="wrap_content" | 13 | android:layout_width="wrap_content" |
14 | android:layout_height="wrap_content" | 14 | android:layout_height="wrap_content" |
15 | + android:layout_gravity="left" | ||
15 | android:layout_marginLeft="14dp" | 16 | android:layout_marginLeft="14dp" |
16 | android:text="@string/title" | 17 | android:text="@string/title" |
17 | android:textAppearance="?android:attr/textAppearanceMedium" /> | 18 | android:textAppearance="?android:attr/textAppearanceMedium" /> |
src/com/upc/pbe/upcnews/Descarrega.java
@@ -73,7 +73,7 @@ public class Descarrega extends AsyncTask<Object, Object, Object>{ | @@ -73,7 +73,7 @@ public class Descarrega extends AsyncTask<Object, Object, Object>{ | ||
73 | 73 | ||
74 | 74 | ||
75 | 75 | ||
76 | - protected Object doInBackground() { | 76 | + protected String doInBackground() { |
77 | try { | 77 | try { |
78 | URLConnection conn = new URL(url).openConnection(); | 78 | URLConnection conn = new URL(url).openConnection(); |
79 | BufferedReader in = new BufferedReader(new InputStreamReader( | 79 | BufferedReader in = new BufferedReader(new InputStreamReader( |
src/com/upc/pbe/upcnews/Directoris.java
@@ -9,24 +9,30 @@ import android.util.Log; | @@ -9,24 +9,30 @@ import android.util.Log; | ||
9 | import android.view.Menu; | 9 | import android.view.Menu; |
10 | import android.view.MenuItem; | 10 | import android.view.MenuItem; |
11 | import android.view.View; | 11 | import android.view.View; |
12 | +import android.view.View.OnClickListener; | ||
12 | import android.widget.Button; | 13 | import android.widget.Button; |
13 | 14 | ||
14 | -public class Directoris extends Activity { | 15 | +public class Directoris extends Activity implements OnClickListener { |
15 | 16 | ||
16 | final static String TAG = "Directoris"; | 17 | final static String TAG = "Directoris"; |
17 | String s; | 18 | String s; |
19 | + Descarrega d; | ||
20 | + String url; | ||
21 | + String file = "ejemplo.xml"; | ||
22 | + String folder = "Environment.getExternalStorageDirectory.getPath()"; | ||
18 | 23 | ||
19 | ArrayList<Button> buttons = new ArrayList<Button>(); | 24 | ArrayList<Button> buttons = new ArrayList<Button>(); |
20 | Button button1, button2, button3, button4; | 25 | Button button1, button2, button3, button4; |
21 | - | 26 | + |
22 | public void onCreate(Bundle savedInstanceState) { | 27 | public void onCreate(Bundle savedInstanceState) { |
23 | - | 28 | + |
24 | Log.d(TAG, "onCreated"); | 29 | Log.d(TAG, "onCreated"); |
25 | - | 30 | + url = ((UpcApp) getApplication()).getUrl(); |
31 | + | ||
26 | super.onCreate(savedInstanceState); | 32 | super.onCreate(savedInstanceState); |
27 | setContentView(R.layout.dirs); | 33 | setContentView(R.layout.dirs); |
28 | 34 | ||
29 | - this.crearButtons(); | 35 | + this.crearButtons(); |
30 | 36 | ||
31 | s = ((UpcApp) getApplication()).getDesc(); | 37 | s = ((UpcApp) getApplication()).getDesc(); |
32 | HTMLParser pars = new HTMLParser(); | 38 | HTMLParser pars = new HTMLParser(); |
@@ -36,7 +42,7 @@ public class Directoris extends Activity { | @@ -36,7 +42,7 @@ public class Directoris extends Activity { | ||
36 | Log.d(TAG, "Directori " + i); | 42 | Log.d(TAG, "Directori " + i); |
37 | buttons.get(i).setVisibility(View.VISIBLE); | 43 | buttons.get(i).setVisibility(View.VISIBLE); |
38 | buttons.get(i).setText(dirs.get(i)); | 44 | buttons.get(i).setText(dirs.get(i)); |
39 | - | 45 | + |
40 | } | 46 | } |
41 | 47 | ||
42 | } | 48 | } |
@@ -61,21 +67,52 @@ public class Directoris extends Activity { | @@ -61,21 +67,52 @@ public class Directoris extends Activity { | ||
61 | return false; | 67 | return false; |
62 | } | 68 | } |
63 | } | 69 | } |
64 | - | ||
65 | - public void crearButtons(){ | ||
66 | - | ||
67 | - | ||
68 | - button1 = (Button)findViewById(R.id.button1); | ||
69 | - button2 = (Button)findViewById(R.id.button2); | ||
70 | - button3 = (Button)findViewById(R.id.button3); | ||
71 | - button4 = (Button)findViewById(R.id.button4); | ||
72 | - | 70 | + |
71 | + public void onClick(View c) { | ||
73 | 72 | ||
73 | + switch (c.getId()) { | ||
74 | + | ||
75 | + case R.id.button1: { | ||
76 | + Log.d(TAG, "Click on button1"); | ||
77 | + d = new Descarrega(url + "/" + button1.getText() + "/", file, folder); | ||
78 | + String str = d.doInBackground(); | ||
79 | + | ||
80 | + HTMLParser pars = new HTMLParser(); | ||
81 | + String urlvideo = pars.findvideo((String) button1.getText(), | ||
82 | + str, url + "/" + button1.getText() + "/"); | ||
83 | + | ||
84 | + Log.d(TAG, urlvideo); | ||
85 | + | ||
86 | + } | ||
87 | + case R.id.button2: { | ||
88 | + | ||
89 | + } | ||
90 | + case R.id.button3: { | ||
91 | + | ||
92 | + } | ||
93 | + case R.id.button4: { | ||
94 | + | ||
95 | + } | ||
96 | + } | ||
97 | + } | ||
98 | + | ||
99 | + public void crearButtons() { | ||
100 | + | ||
101 | + button1 = (Button) findViewById(R.id.button1); | ||
102 | + button2 = (Button) findViewById(R.id.button2); | ||
103 | + button3 = (Button) findViewById(R.id.button3); | ||
104 | + button4 = (Button) findViewById(R.id.button4); | ||
105 | + | ||
74 | buttons.add(button1); | 106 | buttons.add(button1); |
75 | buttons.add(button2); | 107 | buttons.add(button2); |
76 | buttons.add(button3); | 108 | buttons.add(button3); |
77 | buttons.add(button4); | 109 | buttons.add(button4); |
78 | 110 | ||
111 | + button1.setOnClickListener(this); | ||
112 | + button2.setOnClickListener(this); | ||
113 | + button3.setOnClickListener(this); | ||
114 | + button4.setOnClickListener(this); | ||
115 | + | ||
79 | button1.setVisibility(View.GONE); | 116 | button1.setVisibility(View.GONE); |
80 | button2.setVisibility(View.GONE); | 117 | button2.setVisibility(View.GONE); |
81 | button3.setVisibility(View.GONE); | 118 | button3.setVisibility(View.GONE); |
src/com/upc/pbe/upcnews/HTMLParser.java
@@ -27,7 +27,7 @@ public class HTMLParser { | @@ -27,7 +27,7 @@ public class HTMLParser { | ||
27 | 27 | ||
28 | public String findvideo(String name, String code, String direccio){ | 28 | public String findvideo(String name, String code, String direccio){ |
29 | String[] split = code.split("\n"); | 29 | String[] split = code.split("\n"); |
30 | - for(int i = 0; i< split.length; i++){ | 30 | + for(int i = 0; i < split.length; i++){ |
31 | if(split[i].contains(".m3u8")){ | 31 | if(split[i].contains(".m3u8")){ |
32 | String nomarxiu = split[i].substring((split[i].indexOf("href="))+6, (split[i].indexOf("/\""))); | 32 | String nomarxiu = split[i].substring((split[i].indexOf("href="))+6, (split[i].indexOf("/\""))); |
33 | return direccio+nomarxiu+"/"; | 33 | return direccio+nomarxiu+"/"; |
src/com/upc/pbe/upcnews/UpcApp.java
@@ -11,7 +11,7 @@ public class UpcApp extends Application implements OnSharedPreferenceChangeListe | @@ -11,7 +11,7 @@ public class UpcApp extends Application implements OnSharedPreferenceChangeListe | ||
11 | 11 | ||
12 | final static String TAG = "Application"; | 12 | final static String TAG = "Application"; |
13 | SharedPreferences prefs; | 13 | SharedPreferences prefs; |
14 | - String defaultUrl = "imanolbarba.myftp.biz"; | 14 | + String defaultUrl = "10.0.2.100"; |
15 | String url = null; | 15 | String url = null; |
16 | String desc; | 16 | String desc; |
17 | 17 |