Commit 76f2e51baf292058aaf2225f8499a8c704648cf6

Authored by Imanol-Mikel Barba Sabariego
1 parent cf2f1ea4

--no commit message

src/com/upc/pbe/upcnews/Directoris.java
@@ -22,7 +22,6 @@ public class Directoris extends Activity implements OnClickListener { @@ -22,7 +22,6 @@ public class Directoris extends Activity implements OnClickListener {
22 String folder = "Environment.getExternalStorageDirectory.getPath()"; 22 String folder = "Environment.getExternalStorageDirectory.getPath()";
23 23
24 ArrayList<Button> buttons = new ArrayList<Button>(); 24 ArrayList<Button> buttons = new ArrayList<Button>();
25 - Button button1, button2, button3, button4;  
26 25
27 public void onCreate(Bundle savedInstanceState) { 26 public void onCreate(Bundle savedInstanceState) {
28 27
@@ -74,13 +73,13 @@ public class Directoris extends Activity implements OnClickListener { @@ -74,13 +73,13 @@ public class Directoris extends Activity implements OnClickListener {
74 73
75 case R.id.button1: { 74 case R.id.button1: {
76 Log.d(TAG, "Click on button1"); 75 Log.d(TAG, "Click on button1");
77 - d = new Descarrega(url + "/" + button1.getText() + "/", file, 76 + d = new Descarrega(url + "/" + buttons.get(0).getText() + "/", file,
78 folder); 77 folder);
79 String str = d.doInBackground(); 78 String str = d.doInBackground();
80 79
81 HTMLParser pars = new HTMLParser(); 80 HTMLParser pars = new HTMLParser();
82 - String urlvideo = pars.findvideo((String) button1.getText(), str,  
83 - url + "/" + button1.getText() + "/"); 81 + String urlvideo = pars.findvideo((String) buttons.get(0).getText(), str,
  82 + url + "/" + buttons.get(0).getText() + "/");
84 83
85 Log.d(TAG, urlvideo); 84 Log.d(TAG, urlvideo);
86 85
@@ -104,24 +103,15 @@ public class Directoris extends Activity implements OnClickListener { @@ -104,24 +103,15 @@ public class Directoris extends Activity implements OnClickListener {
104 103
105 public void crearButtons() { 104 public void crearButtons() {
106 105
107 - button1 = (Button) findViewById(R.id.button1);  
108 - button2 = (Button) findViewById(R.id.button2);  
109 - button3 = (Button) findViewById(R.id.button3);  
110 - button4 = (Button) findViewById(R.id.button4);  
111 -  
112 - buttons.add(button1);  
113 - buttons.add(button2);  
114 - buttons.add(button3);  
115 - buttons.add(button4);  
116 -  
117 - button1.setOnClickListener(this);  
118 - button2.setOnClickListener(this);  
119 - button3.setOnClickListener(this);  
120 - button4.setOnClickListener(this);  
121 -  
122 - button1.setVisibility(View.GONE);  
123 - button2.setVisibility(View.GONE);  
124 - button3.setVisibility(View.GONE);  
125 - button4.setVisibility(View.GONE); 106 +
  107 + buttons.add((Button) findViewById(R.id.button1));
  108 + buttons.add((Button) findViewById(R.id.button2));
  109 + buttons.add((Button) findViewById(R.id.button3));
  110 + buttons.add((Button) findViewById(R.id.button4));
  111 +
  112 + for(int i = 0; i < buttons.size(); i++){
  113 + buttons.get(i).setOnClickListener(this);
  114 + buttons.get(i).setVisibility(View.GONE);
  115 + }
126 } 116 }
127 } 117 }
128 \ No newline at end of file 118 \ No newline at end of file