Commit 05494523497144ad03c1496c7ef2de8aa3d25135

Authored by Imanol-Mikel Barba Sabariego
1 parent 04d72730

He canviat només un parell de coses del layout/main_activity.xml

gen/com/upc/pbe/upcnews/R.java
@@ -15,9 +15,11 @@ public final class R { @@ -15,9 +15,11 @@ public final class R {
15 public static final int ic_launcher=0x7f020001; 15 public static final int ic_launcher=0x7f020001;
16 } 16 }
17 public static final class id { 17 public static final class id {
18 - public static final int button=0x7f070000;  
19 - public static final int menu_settings=0x7f070002;  
20 - public static final int textView1=0x7f070001; 18 + public static final int AbsoluteLayout1=0x7f070000;
  19 + public static final int button=0x7f070003;
  20 + public static final int menu_settings=0x7f070004;
  21 + public static final int textViewRoute=0x7f070002;
  22 + public static final int textViewXml=0x7f070001;
21 } 23 }
22 public static final class layout { 24 public static final class layout {
23 public static final int main_activity=0x7f030000; 25 public static final int main_activity=0x7f030000;
res/layout/main_activity.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 -<LinearLayout android:layout_width="match_parent" 2 +<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + android:id="@+id/AbsoluteLayout1"
  5 + android:layout_width="wrap_content"
3 android:layout_height="match_parent" 6 android:layout_height="match_parent"
4 - android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">  
5 - 7 + tools:ignore="Deprecated" >
  8 +
  9 + <TextView
  10 + android:id="@+id/textViewXml"
  11 + android:layout_width="301dp"
  12 + android:layout_height="386dp"
  13 + android:layout_x="11dp"
  14 + android:layout_y="81dp"
  15 + android:gravity="clip_vertical"
  16 + android:hint="@string/hint"
  17 + android:scrollbarStyle="insideInset"
  18 + android:scrollbars="vertical" />
  19 +
  20 + <TextView
  21 + android:id="@+id/textViewRoute"
  22 + android:layout_width="250dp"
  23 + android:layout_height="22dp"
  24 + android:layout_x="35dp"
  25 + android:layout_y="8dp"
  26 + android:textSize="@android:dimen/thumbnail_height" />
  27 +
6 <Button 28 <Button
7 android:id="@+id/button" 29 android:id="@+id/button"
8 - android:layout_width="match_parent" 30 + android:layout_width="258dp"
9 android:layout_height="wrap_content" 31 android:layout_height="wrap_content"
  32 + android:layout_x="31dp"
  33 + android:layout_y="30dp"
10 android:text="@string/descarregar" /> 34 android:text="@string/descarregar" />
11 -  
12 - <TextView  
13 - android:id="@+id/textView1"  
14 - android:layout_width="match_parent"  
15 - android:layout_height="match_parent"  
16 - android:hint="@string/hint" />  
17 35
18 -</LinearLayout>  
19 \ No newline at end of file 36 \ No newline at end of file
  37 +</AbsoluteLayout>
20 \ No newline at end of file 38 \ No newline at end of file
res/values/strings.xml
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <string name="hello_world">Hello world!</string> 4 <string name="hello_world">Hello world!</string>
5 <string name="menu_settings">Settings</string> 5 <string name="menu_settings">Settings</string>
6 <string name="title_activity_main">MainActivity</string> 6 <string name="title_activity_main">MainActivity</string>
7 - <string name="descarregar">Descarrega</string>  
8 - <string name="hint">Esperant contingut...</string> 7 + <string name="descarregar">Start</string>
  8 + <string name="hint">Click to Start Button...</string>
9 9
10 </resources> 10 </resources>
11 \ No newline at end of file 11 \ No newline at end of file
src/com/upc/pbe/upcnews/Descarrega.java
@@ -82,10 +82,11 @@ public class Descarrega extends AsyncTask&lt;Object, Object, Object&gt;{ @@ -82,10 +82,11 @@ public class Descarrega extends AsyncTask&lt;Object, Object, Object&gt;{
82 + " >> Tamany: " + conn.getContentLength() + " bytes"); 82 + " >> Tamany: " + conn.getContentLength() + " bytes");
83 String inputLine; 83 String inputLine;
84 while ((inputLine = in.readLine()) != null) { 84 while ((inputLine = in.readLine()) != null) {
85 - Log.d(TAG, inputLine);  
86 - html = html + "\n" + inputLine; 85 + //Log.d(TAG, inputLine);
  86 + html = html + "\r" + inputLine;
87 } 87 }
88 Log.d(TAG, "Descarrega finalitzada"); 88 Log.d(TAG, "Descarrega finalitzada");
  89 +
89 in.close(); 90 in.close();
90 } catch (MalformedURLException e) { 91 } catch (MalformedURLException e) {
91 Log.d(TAG, "excepcio 1"); 92 Log.d(TAG, "excepcio 1");
src/com/upc/pbe/upcnews/MainActivity.java
1 package com.upc.pbe.upcnews; 1 package com.upc.pbe.upcnews;
2 2
3 -import com.upc.pbe.upcnews.R;  
4 3
5 import android.app.Activity; 4 import android.app.Activity;
6 import android.os.Bundle; 5 import android.os.Bundle;
@@ -9,14 +8,15 @@ import android.view.View; @@ -9,14 +8,15 @@ import android.view.View;
9 import android.view.View.OnClickListener; 8 import android.view.View.OnClickListener;
10 import android.widget.Button; 9 import android.widget.Button;
11 import android.widget.TextView; 10 import android.widget.TextView;
  11 +import android.widget.Toast;
12 12
13 public class MainActivity extends Activity implements OnClickListener { 13 public class MainActivity extends Activity implements OnClickListener {
14 final static String TAG = "Main"; 14 final static String TAG = "Main";
15 Button buttonDescarrega; 15 Button buttonDescarrega;
16 - String url = "http://10.0.2.100";  
17 - String file = "example.m3u8"; 16 + String url = "http://www.google.es";
  17 + String file = "ejemplo.xml";
18 String folder = "C:\\Users\\Usuario\\Downloads\\"; 18 String folder = "C:\\Users\\Usuario\\Downloads\\";
19 - TextView show; 19 + TextView showText, showRoute;
20 20
21 @Override 21 @Override
22 public void onCreate(Bundle savedInstanceState) { 22 public void onCreate(Bundle savedInstanceState) {
@@ -25,15 +25,19 @@ public class MainActivity extends Activity implements OnClickListener { @@ -25,15 +25,19 @@ public class MainActivity extends Activity implements OnClickListener {
25 Log.d(TAG, "onCreated"); 25 Log.d(TAG, "onCreated");
26 buttonDescarrega = (Button) findViewById(R.id.button); 26 buttonDescarrega = (Button) findViewById(R.id.button);
27 buttonDescarrega.setOnClickListener(this); 27 buttonDescarrega.setOnClickListener(this);
28 - show = (TextView) findViewById(R.id.textView1); 28 + showText = (TextView) findViewById(R.id.textViewXml);
  29 + showRoute = (TextView) findViewById(R.id.textViewRoute);
  30 + showRoute.setText("Server: " + url);
29 31
30 } 32 }
31 33
32 public void onClick(View v) { 34 public void onClick(View v) {
  35 +
33 Log.d(TAG, "onClicked"); 36 Log.d(TAG, "onClicked");
34 Descarrega d = new Descarrega(url, file, folder); 37 Descarrega d = new Descarrega(url, file, folder);
  38 + Toast.makeText(this, "Download succesfull", Toast.LENGTH_LONG).show();
35 CharSequence html = (CharSequence) d.doInBackground(); 39 CharSequence html = (CharSequence) d.doInBackground();
36 - show.setText(html); 40 + showText.setText(html);
37 41
38 42
39 } 43 }