Commit 2822a5ee12f05dbd3de8c6d7d58cd5a78d390558
1 parent
0ddda711
--no commit message
Showing
1 changed file
with
17 additions
and
22 deletions
src/com/upc/pbe/upcnews/MainActivity.java
@@ -32,8 +32,7 @@ public class MainActivity extends Activity implements OnClickListener { | @@ -32,8 +32,7 @@ public class MainActivity extends Activity implements OnClickListener { | ||
32 | Log.d(TAG, "onCreated"); | 32 | Log.d(TAG, "onCreated"); |
33 | //Especifiquem la ruta de descarrega | 33 | //Especifiquem la ruta de descarrega |
34 | File tempFolder = new File(((UpcApp)getApplication()).getLocalPath()); | 34 | File tempFolder = new File(((UpcApp)getApplication()).getLocalPath()); |
35 | - if(tempFolder.mkdirs()) | ||
36 | - { | 35 | + if(tempFolder.mkdirs()) { |
37 | Log.d(TAG,"Directory " + tempFolder.toString() + " created"); | 36 | Log.d(TAG,"Directory " + tempFolder.toString() + " created"); |
38 | } | 37 | } |
39 | //Creem els botons i text | 38 | //Creem els botons i text |
@@ -47,8 +46,7 @@ public class MainActivity extends Activity implements OnClickListener { | @@ -47,8 +46,7 @@ public class MainActivity extends Activity implements OnClickListener { | ||
47 | //Al polsar el boto s'inicia la descarrega | 46 | //Al polsar el boto s'inicia la descarrega |
48 | Log.d(TAG, "onClicked"); | 47 | Log.d(TAG, "onClicked"); |
49 | this.descarregar(); | 48 | this.descarregar(); |
50 | - if(!html.equals("EMPTY")) | ||
51 | - { | 49 | + if(!html.equals("EMPTY")) { |
52 | ((UpcApp) getApplication()).setDesc(html); | 50 | ((UpcApp) getApplication()).setDesc(html); |
53 | startActivity(new Intent(this, Directoris.class)); | 51 | startActivity(new Intent(this, Directoris.class)); |
54 | } | 52 | } |
@@ -59,26 +57,23 @@ public class MainActivity extends Activity implements OnClickListener { | @@ -59,26 +57,23 @@ public class MainActivity extends Activity implements OnClickListener { | ||
59 | //Si hi ha errors, els mostrem en Toasts | 57 | //Si hi ha errors, els mostrem en Toasts |
60 | Descarrega d = new Descarrega(); | 58 | Descarrega d = new Descarrega(); |
61 | html="EMPTY"; | 59 | html="EMPTY"; |
62 | - try | ||
63 | - { | 60 | + try { |
64 | html = (String) d.doInBackground(((UpcApp)getApplication()).getUrl()); | 61 | html = (String) d.doInBackground(((UpcApp)getApplication()).getUrl()); |
65 | } | 62 | } |
66 | - catch(MalformedURLException e) | ||
67 | - { | 63 | + catch(MalformedURLException e) { |
68 | Toast.makeText(this, "Invalid URL", Toast.LENGTH_LONG).show(); | 64 | Toast.makeText(this, "Invalid URL", Toast.LENGTH_LONG).show(); |
69 | } | 65 | } |
70 | - catch(IOException e) | ||
71 | - { | 66 | + catch(IOException e) { |
72 | Toast.makeText(this, "Can't find URL", Toast.LENGTH_LONG).show(); | 67 | Toast.makeText(this, "Can't find URL", Toast.LENGTH_LONG).show(); |
73 | } | 68 | } |
74 | } | 69 | } |
75 | 70 | ||
76 | - public void onResume(){ | 71 | + public void onResume() { |
77 | super.onResume(); | 72 | super.onResume(); |
78 | updateURL(); | 73 | updateURL(); |
79 | } | 74 | } |
80 | 75 | ||
81 | - public void updateURL(){ | 76 | + public void updateURL() { |
82 | URLText.setText(((UpcApp)getApplication()).getUrl()); | 77 | URLText.setText(((UpcApp)getApplication()).getUrl()); |
83 | } | 78 | } |
84 | 79 | ||
@@ -92,16 +87,16 @@ public class MainActivity extends Activity implements OnClickListener { | @@ -92,16 +87,16 @@ public class MainActivity extends Activity implements OnClickListener { | ||
92 | public boolean onOptionsItemSelected(MenuItem item) { | 87 | public boolean onOptionsItemSelected(MenuItem item) { |
93 | //Determina el funcionament al clickar en el menu d'opcions | 88 | //Determina el funcionament al clickar en el menu d'opcions |
94 | switch (item.getItemId()) { | 89 | switch (item.getItemId()) { |
95 | - case R.id.itemprefs: | ||
96 | - startActivity(new Intent(this, Prefs.class)); | ||
97 | - Log.d(TAG, "Preferences"); | ||
98 | - return true; | ||
99 | - case R.id.itemhelp: | ||
100 | - startActivity(new Intent(this, Help.class)); | ||
101 | - Log.d(TAG, "Help"); | ||
102 | - return true; | ||
103 | - default: | ||
104 | - return false; | 90 | + case R.id.itemprefs: |
91 | + startActivity(new Intent(this, Prefs.class)); | ||
92 | + Log.d(TAG, "Preferences"); | ||
93 | + return true; | ||
94 | + case R.id.itemhelp: | ||
95 | + startActivity(new Intent(this, Help.class)); | ||
96 | + Log.d(TAG, "Help"); | ||
97 | + return true; | ||
98 | + default: | ||
99 | + return false; | ||
105 | } | 100 | } |
106 | } | 101 | } |
107 | /* | 102 | /* |