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 | 7 | android:orientation="vertical" > |
8 | 8 | |
9 | 9 | <!-- Vista en llista --> |
10 | - | |
10 | + | |
11 | 11 | <TextView |
12 | 12 | android:id="@+id/textViewTitle" |
13 | 13 | android:layout_width="wrap_content" |
14 | 14 | android:layout_height="wrap_content" |
15 | + android:layout_gravity="left" | |
15 | 16 | android:layout_marginLeft="14dp" |
16 | 17 | android:text="@string/title" |
17 | 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 | 73 | |
74 | 74 | |
75 | 75 | |
76 | - protected Object doInBackground() { | |
76 | + protected String doInBackground() { | |
77 | 77 | try { |
78 | 78 | URLConnection conn = new URL(url).openConnection(); |
79 | 79 | BufferedReader in = new BufferedReader(new InputStreamReader( | ... | ... |
src/com/upc/pbe/upcnews/Directoris.java
... | ... | @@ -9,24 +9,30 @@ import android.util.Log; |
9 | 9 | import android.view.Menu; |
10 | 10 | import android.view.MenuItem; |
11 | 11 | import android.view.View; |
12 | +import android.view.View.OnClickListener; | |
12 | 13 | import android.widget.Button; |
13 | 14 | |
14 | -public class Directoris extends Activity { | |
15 | +public class Directoris extends Activity implements OnClickListener { | |
15 | 16 | |
16 | 17 | final static String TAG = "Directoris"; |
17 | 18 | String s; |
19 | + Descarrega d; | |
20 | + String url; | |
21 | + String file = "ejemplo.xml"; | |
22 | + String folder = "Environment.getExternalStorageDirectory.getPath()"; | |
18 | 23 | |
19 | 24 | ArrayList<Button> buttons = new ArrayList<Button>(); |
20 | 25 | Button button1, button2, button3, button4; |
21 | - | |
26 | + | |
22 | 27 | public void onCreate(Bundle savedInstanceState) { |
23 | - | |
28 | + | |
24 | 29 | Log.d(TAG, "onCreated"); |
25 | - | |
30 | + url = ((UpcApp) getApplication()).getUrl(); | |
31 | + | |
26 | 32 | super.onCreate(savedInstanceState); |
27 | 33 | setContentView(R.layout.dirs); |
28 | 34 | |
29 | - this.crearButtons(); | |
35 | + this.crearButtons(); | |
30 | 36 | |
31 | 37 | s = ((UpcApp) getApplication()).getDesc(); |
32 | 38 | HTMLParser pars = new HTMLParser(); |
... | ... | @@ -36,7 +42,7 @@ public class Directoris extends Activity { |
36 | 42 | Log.d(TAG, "Directori " + i); |
37 | 43 | buttons.get(i).setVisibility(View.VISIBLE); |
38 | 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 | 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 | 106 | buttons.add(button1); |
75 | 107 | buttons.add(button2); |
76 | 108 | buttons.add(button3); |
77 | 109 | buttons.add(button4); |
78 | 110 | |
111 | + button1.setOnClickListener(this); | |
112 | + button2.setOnClickListener(this); | |
113 | + button3.setOnClickListener(this); | |
114 | + button4.setOnClickListener(this); | |
115 | + | |
79 | 116 | button1.setVisibility(View.GONE); |
80 | 117 | button2.setVisibility(View.GONE); |
81 | 118 | button3.setVisibility(View.GONE); | ... | ... |
src/com/upc/pbe/upcnews/HTMLParser.java
... | ... | @@ -27,7 +27,7 @@ public class HTMLParser { |
27 | 27 | |
28 | 28 | public String findvideo(String name, String code, String direccio){ |
29 | 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 | 31 | if(split[i].contains(".m3u8")){ |
32 | 32 | String nomarxiu = split[i].substring((split[i].indexOf("href="))+6, (split[i].indexOf("/\""))); |
33 | 33 | return direccio+nomarxiu+"/"; | ... | ... |
src/com/upc/pbe/upcnews/UpcApp.java
... | ... | @@ -11,7 +11,7 @@ public class UpcApp extends Application implements OnSharedPreferenceChangeListe |
11 | 11 | |
12 | 12 | final static String TAG = "Application"; |
13 | 13 | SharedPreferences prefs; |
14 | - String defaultUrl = "imanolbarba.myftp.biz"; | |
14 | + String defaultUrl = "10.0.2.100"; | |
15 | 15 | String url = null; |
16 | 16 | String desc; |
17 | 17 | ... | ... |