From 30f316ced7e327da3f32d12512e7d8b7931c246d Mon Sep 17 00:00:00 2001 From: Equip de Desenvolupadors de PBE Date: Thu, 13 Dec 2012 14:43:12 +0000 Subject: [PATCH] crash fixed --- src/com/upc/pbe/upcnews/Descarrega.java | 21 ++------------------- src/com/upc/pbe/upcnews/MainActivity.java | 3 +-- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/com/upc/pbe/upcnews/Descarrega.java b/src/com/upc/pbe/upcnews/Descarrega.java index 0a9e540..5b02d86 100644 --- a/src/com/upc/pbe/upcnews/Descarrega.java +++ b/src/com/upc/pbe/upcnews/Descarrega.java @@ -20,31 +20,21 @@ public class Descarrega extends AsyncTask { ctx = c; } - - @Override - protected void onPreExecute() { - //Codi previ a l'execució de la tasca en background - //pDialog.setMax(100); - //pDialog.setProgress(0); - } @Override protected String doInBackground(URL... urls){ //Codi de la tasca en background String html = ""; - // Iniciem la connexió i creem els Streams + // Iniciem la connexi� i creem els Streams try { URLConnection conn = urls[0].openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); - // Iniciem la descarrega, anem guardant al String i actualitzant la barra de progrés + // Iniciem la descarrega, anem guardant al String i actualitzant la barra de progr�s int totalLength = conn.getContentLength(); - int downloaded=0; String inputLine; Log.d(TAG, "\nDescarregant: \n"); Log.d(TAG, ">> URL: " + urls[0] + " >> Tamany: " + totalLength + " bytes"); while ((inputLine = in.readLine()) != null) { - downloaded = downloaded + Integer.parseInt(inputLine.getBytes().toString()); - publishProgress((downloaded/totalLength)*100); html += inputLine + "\n"; } in.close(); @@ -58,11 +48,4 @@ public class Descarrega extends AsyncTask } return html; } - - @Override - protected void onProgressUpdate(Integer... values) { - //Actualitza la barra de progrés de la descàrrega, respon a la crida de publishProgress - int progreso = values[0].intValue(); - //pDialog.setProgress(progreso); - } } \ No newline at end of file diff --git a/src/com/upc/pbe/upcnews/MainActivity.java b/src/com/upc/pbe/upcnews/MainActivity.java index 522e760..9a90def 100644 --- a/src/com/upc/pbe/upcnews/MainActivity.java +++ b/src/com/upc/pbe/upcnews/MainActivity.java @@ -9,7 +9,6 @@ import java.util.concurrent.ExecutionException; import android.app.Activity; import android.content.Intent; import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; import android.os.Bundle; import android.util.Log; import android.view.Menu; @@ -50,7 +49,7 @@ public class MainActivity extends Activity implements OnClickListener { buttonDescarrega = (ImageButton) findViewById(R.id.button); buttonDescarrega.setOnClickListener(this); updateURL(); - //Si vitamio no està instal·lat, mostrem el missatge d'alerta + //Si vitamio no est� instal�lat, mostrem el missatge d'alerta List apps = getPackageManager().getInstalledPackages(0); for(int i = 0; i < apps.size(); i++) { -- libgit2 0.22.2