Commit 30f316ced7e327da3f32d12512e7d8b7931c246d
1 parent
2d7bbd5d
crash fixed
Showing
2 changed files
with
3 additions
and
21 deletions
src/com/upc/pbe/upcnews/Descarrega.java
... | ... | @@ -20,31 +20,21 @@ public class Descarrega extends AsyncTask<URL, Integer, String> |
20 | 20 | { |
21 | 21 | ctx = c; |
22 | 22 | } |
23 | - | |
24 | - @Override | |
25 | - protected void onPreExecute() { | |
26 | - //Codi previ a l'execució de la tasca en background | |
27 | - //pDialog.setMax(100); | |
28 | - //pDialog.setProgress(0); | |
29 | - } | |
30 | 23 | |
31 | 24 | @Override |
32 | 25 | protected String doInBackground(URL... urls){ |
33 | 26 | //Codi de la tasca en background |
34 | 27 | String html = ""; |
35 | - // Iniciem la connexió i creem els Streams | |
28 | + // Iniciem la connexi� i creem els Streams | |
36 | 29 | try { |
37 | 30 | URLConnection conn = urls[0].openConnection(); |
38 | 31 | BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); |
39 | - // Iniciem la descarrega, anem guardant al String i actualitzant la barra de progrés | |
32 | + // Iniciem la descarrega, anem guardant al String i actualitzant la barra de progr�s | |
40 | 33 | int totalLength = conn.getContentLength(); |
41 | - int downloaded=0; | |
42 | 34 | String inputLine; |
43 | 35 | Log.d(TAG, "\nDescarregant: \n"); |
44 | 36 | Log.d(TAG, ">> URL: " + urls[0] + " >> Tamany: " + totalLength + " bytes"); |
45 | 37 | while ((inputLine = in.readLine()) != null) { |
46 | - downloaded = downloaded + Integer.parseInt(inputLine.getBytes().toString()); | |
47 | - publishProgress((downloaded/totalLength)*100); | |
48 | 38 | html += inputLine + "\n"; |
49 | 39 | } |
50 | 40 | in.close(); |
... | ... | @@ -58,11 +48,4 @@ public class Descarrega extends AsyncTask<URL, Integer, String> |
58 | 48 | } |
59 | 49 | return html; |
60 | 50 | } |
61 | - | |
62 | - @Override | |
63 | - protected void onProgressUpdate(Integer... values) { | |
64 | - //Actualitza la barra de progrés de la descàrrega, respon a la crida de publishProgress | |
65 | - int progreso = values[0].intValue(); | |
66 | - //pDialog.setProgress(progreso); | |
67 | - } | |
68 | 51 | } |
69 | 52 | \ No newline at end of file | ... | ... |
src/com/upc/pbe/upcnews/MainActivity.java
... | ... | @@ -9,7 +9,6 @@ import java.util.concurrent.ExecutionException; |
9 | 9 | import android.app.Activity; |
10 | 10 | import android.content.Intent; |
11 | 11 | import android.content.pm.PackageInfo; |
12 | -import android.content.pm.PackageManager; | |
13 | 12 | import android.os.Bundle; |
14 | 13 | import android.util.Log; |
15 | 14 | import android.view.Menu; |
... | ... | @@ -50,7 +49,7 @@ public class MainActivity extends Activity implements OnClickListener { |
50 | 49 | buttonDescarrega = (ImageButton) findViewById(R.id.button); |
51 | 50 | buttonDescarrega.setOnClickListener(this); |
52 | 51 | updateURL(); |
53 | - //Si vitamio no està instal·lat, mostrem el missatge d'alerta | |
52 | + //Si vitamio no est� instal�lat, mostrem el missatge d'alerta | |
54 | 53 | List<PackageInfo> apps = getPackageManager().getInstalledPackages(0); |
55 | 54 | for(int i = 0; i < apps.size(); i++) |
56 | 55 | { | ... | ... |