From adb2f8c87973b0a54655882e96029f04b04e6fb3 Mon Sep 17 00:00:00 2001 From: Equip de Desenvolupadors de PBE Date: Wed, 5 Dec 2012 13:31:30 +0000 Subject: [PATCH] --- src/com/upc/pbe/upcnews/Descarrega.java | 32 +++++++++++++++----------------- src/com/upc/pbe/upcnews/Directoris.java | 15 ++++++--------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/com/upc/pbe/upcnews/Descarrega.java b/src/com/upc/pbe/upcnews/Descarrega.java index a6ee140..ce48016 100644 --- a/src/com/upc/pbe/upcnews/Descarrega.java +++ b/src/com/upc/pbe/upcnews/Descarrega.java @@ -14,25 +14,26 @@ import java.net.URLConnection; import android.os.AsyncTask; import android.util.Log; - -public class Descarrega extends AsyncTask{ +public class Descarrega extends AsyncTask { final static String TAG = "Descarrega"; private String url; - private String nomarxiu; private String carpeta; + private String nomarxiu; private String html; private File arxiu; public Descarrega() { + nomarxiu = "ejemplo.xml"; + carpeta = "Environment.getExternalStorageDirectory.getPath()"; - + this.carpeta = null; this.html = null; this.arxiu = null; } - public void descarregarguardar(String u, String nomarxiu, String carpeta) { - this.nomarxiu = nomarxiu; - this.carpeta = carpeta; + public void descarregarguardar(String u, String nom, String car) { + this.nomarxiu = nom; + this.carpeta = car; this.url = u; // Creem el directori File dir = new File(carpeta); @@ -73,8 +74,6 @@ public class Descarrega extends AsyncTask{ } } - - protected String doInBackground(String u) { this.url = u; try { @@ -82,30 +81,29 @@ public class Descarrega extends AsyncTask{ BufferedReader in = new BufferedReader(new InputStreamReader( conn.getInputStream())); Log.d(TAG, "\nDescarregant: \n"); - Log.d(TAG, ">> URL: " + url + " >> Tamany: " + conn.getContentLength() + " bytes"); + Log.d(TAG, + ">> URL: " + url + " >> Tamany: " + conn.getContentLength() + + " bytes"); String inputLine; while ((inputLine = in.readLine()) != null) { html = html + "\n" + inputLine; } Log.d(TAG, "Descarrega finalitzada"); - + in.close(); } catch (MalformedURLException e) { Log.d(TAG, "excepcio 1, no sha trobat la URL"); } catch (IOException e) { Log.d(TAG, "excepcio 2"); } - + return html; - - + } - - @Override protected Object doInBackground(Object... arg0) { - + return null; } } diff --git a/src/com/upc/pbe/upcnews/Directoris.java b/src/com/upc/pbe/upcnews/Directoris.java index 0cf72e0..841a870 100644 --- a/src/com/upc/pbe/upcnews/Directoris.java +++ b/src/com/upc/pbe/upcnews/Directoris.java @@ -19,8 +19,6 @@ public class Directoris extends Activity implements OnClickListener { String s; Descarrega d; String url; - String file = "ejemplo.xml"; - String folder = "Environment.getExternalStorageDirectory.getPath()"; ArrayList