Subversion Repositories ES

Compare Revisions

Last modification

Ignore whitespace Rev 18 → Rev 17

/trunk/src/de/pointedears/converter/app/CurrenciesActivity.java
102,8 → 102,6
{
if (intent.getAction().equals(UpdateService.ACTION_UPDATE))
{
CurrenciesActivity.this.fillTableRates();
 
Bundle extras = intent.getExtras();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$
Notifier.sendMessage(CurrenciesActivity.this,
/trunk/src/de/pointedears/converter/helpers/UpdateService.java
29,7 → 29,6
"de.pointedears.converter.extra_num_rates"; //$NON-NLS-1$
public static final String EXTRA_DATE = "de.pointedears.converter.extra_date"; //$NON-NLS-1$
 
/* NOTE: Don't remove; may be used later for automated updates */
// private sendTimerTask sendTime = null;
 
// /** inner class implements the broadcast timer */
101,7 → 100,7
if (this.updateThread == null)
{
this.ratesUpdater =
new RatesUpdater(UpdateService.activityContext, this);
new RatesUpdater(UpdateService.getActivityContext(), this);
this.updateThread =
new ConverterThread(this.ratesUpdater, this.handler);
this.ratesUpdater.setUpdateThread(this.updateThread);
140,6 → 139,14
}
 
/**
* @return the activityContext
*/
public static CurrenciesActivity getActivityContext()
{
return UpdateService.activityContext;
}
 
/**
* @param activityContext
* the activityContext to set
*/
/trunk/src/de/pointedears/converter/net/RatesUpdater.java
40,13 → 40,6
*/
public class RatesUpdater implements Runnable
{
/*
* XML markup attributes
*/
private static final String ATTR_RATE = "rate"; //$NON-NLS-1$
private static final String ATTR_CURRENCY = "currency"; //$NON-NLS-1$
private static final String ATTR_TIME = "time"; //$NON-NLS-1$
 
private static final String URL_ECB =
"http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"; //$NON-NLS-1$
 
56,11 → 49,8
private final UpdateService service;
 
/**
* @param activityContext
* The activityContext for this updater.
* FIXME: Required only for database access
* @param updateService
* The service that started this updater
*
*/
public RatesUpdater(CurrenciesActivity activityContext,
UpdateService updateService)
79,7 → 69,6
 
/**
* @param updateThread
* the thread that this updater is running in
*/
public void setUpdateThread(ConverterThread updateThread)
{
144,13 → 133,12
 
try
{
updated =
df.parse(parentCube.getAttribute(RatesUpdater.ATTR_TIME));
updated = df.parse(parentCube.getAttribute("time"));
}
catch (ParseException e)
{
Log.e(this.getClass().toString(),
"Could not parse the `time' attribute into a Date", e); //$NON-NLS-1$
"Could not parse the `time' attribute into a Date", e);
}
 
expr =
167,12 → 155,12
for (int i = 0; i < len; ++i)
{
Element item = (Element) childCubes.item(i);
String currency = item.getAttribute(RatesUpdater.ATTR_CURRENCY);
String currency = item.getAttribute("currency");
 
try
{
Double rate =
Double.parseDouble(item.getAttribute(RatesUpdater.ATTR_RATE));
Double.parseDouble(item.getAttribute("rate")); //$NON-NLS-1$
conversionRates
.put(currency, new ConversionData(rate, updated));
}
183,27 → 171,28
}
 
this.activityContext.getDatabase().writeConversionsToDatabase(null);
this.activityContext.fillTableRates();
}
catch (XPathExpressionException e)
{
Log.e(this.getClass().toString(), "Error in XPath expression", e); //$NON-NLS-1$
Log.e(this.getClass().toString(), "Error in XPath expression", e);
}
}
catch (SAXException e)
{
Log.e(this.getClass().toString(),
"Exception while parsing external XML resource", e); //$NON-NLS-1$
"Exception while parsing external XML resource", e);
}
catch (IOException e)
{
Log.e(this.getClass().toString(),
"I/O exception while parsing external XML resource", e); //$NON-NLS-1$
"I/O exception while parsing external XML resource", e);
}
}
catch (ParserConfigurationException e)
{
Log.e(this.getClass().toString(),
"Document builder cannot be created", e); //$NON-NLS-1$
"Document builder cannot be created", e);
}
 
if (len > 0)
/trunk/bin/Converter.apk
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/bin/resources.ap_
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/bin/classes.dex
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/res/values/strings.xml
14,6 → 14,6
<string name="currencies_currency"><b>Currency</b></string>
<string name="currencies_rate"><b>Rate (1 EUR)</b></string>
<string name="currencies_updated"><b>Updated</b></string>
<string name="caption_update">Update exchange rates</string>
<string name="caption_update">Update table rates</string>
<string name="option_quit">Quit</string>
</resources>
/trunk/res/drawable-hdpi/aum.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: trunk/res/drawable-hdpi/icon.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/res/drawable-ldpi/aum.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/res/drawable-ldpi/aum.png
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: trunk/res/drawable-ldpi/icon.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/res/drawable-mdpi/aum.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/res/drawable-mdpi/aum.png
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: trunk/res/drawable-mdpi/icon.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/res/raw/main_new.xml
===================================================================
--- trunk/res/raw/main_new.xml (nonexistent)
+++ trunk/res/raw/main_new.xml (revision 17)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+
+
+<TextView
+ style="@android:style/TextAppearance.Large"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Android Einheiten Umrechner"
+ />
+
+<Button
+ android:id="@+id/sf_starte_menue01"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/activity_length" />
+
+<Button
+ android:id="@+id/sf_starte_menue02"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/activity_temperatures" />
+
+<Button
+ android:id="@+id/sf_starte_menue03"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/activity_currencies" />
+
+<ImageView
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:layout_gravity="center_horizontal"
+ android:src="@drawable/aum" />
+
+</LinearLayout>
/trunk/res/raw/main_new.xml
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: trunk/doc/currencies.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/doc/currencies.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: trunk/doc/Datenbank.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/doc/Datenbank.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: trunk/doc/main_menu.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/doc/main_menu.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: trunk/doc/Architektur.xmi
===================================================================
--- trunk/doc/Architektur.xmi (revision 18)
+++ trunk/doc/Architektur.xmi (nonexistent)
@@ -1,109 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<XMI verified="false" xmi.version="1.2" timestamp="2011-01-27T20:02:25" xmlns:UML="http://schema.omg.org/spec/UML/1.3">
- <XMI.header>
- <XMI.documentation>
- <XMI.exporter>umbrello uml modeller http://uml.sf.net</XMI.exporter>
- <XMI.exporterVersion>1.5.8</XMI.exporterVersion>
- <XMI.exporterEncoding>UnicodeUTF8</XMI.exporterEncoding>
- </XMI.documentation>
- <XMI.metamodel xmi.version="1.3" href="UML.xml" xmi.name="UML"/>
- </XMI.header>
- <XMI.content>
- <UML:Model isSpecification="false" isAbstract="false" isLeaf="false" xmi.id="m1" isRoot="false" name="UML-Modell">
- <UML:Namespace.ownedElement>
- <UML:Stereotype visibility="public" isSpecification="false" namespace="m1" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="folder" name="folder"/>
- <UML:Stereotype visibility="public" isSpecification="false" namespace="m1" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="datatype" name="datatype"/>
- <UML:Model stereotype="folder" visibility="public" isSpecification="false" namespace="m1" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="Logical View" name="Logical View">
- <UML:Namespace.ownedElement>
- <UML:Package stereotype="folder" visibility="public" isSpecification="false" namespace="Logical View" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="Datatypes" name="Datatypes">
- <UML:Namespace.ownedElement>
- <UML:DataType stereotype="datatype" visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="GuIDPEDWQEpo" name="int"/>
- <UML:DataType stereotype="datatype" visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="KsHFV0NYie4P" name="char"/>
- <UML:DataType stereotype="datatype" visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="fFnZwH5ABLLa" name="bool"/>
- <UML:DataType stereotype="datatype" visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="ZY50lsm5j3LE" name="float"/>
- <UML:DataType stereotype="datatype" visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="3gmjKq8x3uXx" name="double"/>
- <UML:DataType stereotype="datatype" visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="Ba6KuRvT0yRj" name="short"/>
- <UML:DataType stereotype="datatype" visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="oDoXE7lGlVz3" name="long"/>
- <UML:DataType stereotype="datatype" visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="J61M0YIB6OV0" name="unsigned int"/>
- <UML:DataType stereotype="datatype" visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="nOSlKtU95JgH" name="unsigned short"/>
- <UML:DataType stereotype="datatype" visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="OQXAvVDDZCXZ" name="unsigned long"/>
- <UML:DataType stereotype="datatype" visibility="public" isSpecification="false" namespace="Datatypes" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="ipipBDnzaFku" name="string"/>
- </UML:Namespace.ownedElement>
- </UML:Package>
- <UML:Package visibility="public" isSpecification="false" namespace="Logical View" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="WiRs8x01SCC1" name="de.pointedears.converter">
- <UML:Namespace.ownedElement>
- <UML:Class visibility="public" isSpecification="false" namespace="WiRs8x01SCC1" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="OkY7XGujRhg1" name="R"/>
- </UML:Namespace.ownedElement>
- </UML:Package>
- </UML:Namespace.ownedElement>
- <XMI.extension xmi.extender="umbrello">
- <diagrams>
- <diagram showopsig="1" linecolor="#ff0000" snapx="10" showattribassocs="1" snapy="10" linewidth="0" showattsig="1" showpubliconly="1" showpackage="1" showstereotype="1" name="Klassendiagramm" font="Haettenschweiler,12,-1,5,50,0,0,0,0,0" canvasheight="578" canvaswidth="1136" localid="" snapcsgrid="0" showgrid="0" showops="1" usefillcolor="1" fillcolor="#ffff00" zoom="100" xmi.id="1JN85Vvcj75j" documentation="" showscope="1" snapgrid="0" showatts="1" type="1">
- <widgets>
- <packagewidget width="143" showstereotype="1" x="11" y="10" usesdiagramusefillcolor="1" usesdiagramfillcolor="1" isinstance="0" fillcolor="none" height="45" linecolor="none" xmi.id="WiRs8x01SCC1" usefillcolor="1" linewidth="none" font="Haettenschweiler,12,-1,5,75,0,0,0,0,0"/>
- <classwidget linecolor="none" usesdiagramfillcolor="1" linewidth="none" showoperations="1" usesdiagramusefillcolor="1" showpubliconly="1" showpackage="1" x="63" showattsigs="601" showstereotype="1" y="223" showattributes="1" font="Haettenschweiler,12,-1,5,75,0,0,0,0,0" width="155" isinstance="0" usefillcolor="1" fillcolor="none" xmi.id="OkY7XGujRhg1" showscope="1" height="33" showopsigs="601"/>
- </widgets>
- <messages/>
- <associations>
- <assocwidget indexa="1" indexb="1" visibilityA="0" widgetaid="WiRs8x01SCC1" visibilityB="0" roleBdoc="" roleAdoc="" linecolor="none" changeabilityA="900" totalcounta="2" changeabilityB="900" widgetbid="OkY7XGujRhg1" totalcountb="2" type="509" documentation="" linewidth="none">
- <linepath>
- <startpoint startx="154" starty="55"/>
- <endpoint endx="154" endy="223"/>
- </linepath>
- </assocwidget>
- </associations>
- </diagram>
- </diagrams>
- </XMI.extension>
- </UML:Model>
- <UML:Model stereotype="folder" visibility="public" isSpecification="false" namespace="m1" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="Use Case View" name="Use Case View">
- <UML:Namespace.ownedElement/>
- </UML:Model>
- <UML:Model stereotype="folder" visibility="public" isSpecification="false" namespace="m1" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="Component View" name="Component View">
- <UML:Namespace.ownedElement/>
- </UML:Model>
- <UML:Model stereotype="folder" visibility="public" isSpecification="false" namespace="m1" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="Deployment View" name="Deployment View">
- <UML:Namespace.ownedElement/>
- </UML:Model>
- <UML:Model stereotype="folder" visibility="public" isSpecification="false" namespace="m1" isAbstract="false" isLeaf="false" isRoot="false" xmi.id="Entity Relationship Model" name="Entity Relationship Model">
- <UML:Namespace.ownedElement/>
- </UML:Model>
- </UML:Namespace.ownedElement>
- </UML:Model>
- </XMI.content>
- <XMI.extensions xmi.extender="umbrello">
- <docsettings viewid="1JN85Vvcj75j" uniqueid="psTLmeXMpbIt" documentation=""/>
- <listview>
- <listitem open="1" type="800" id="Views">
- <listitem open="1" type="801" id="Logical View">
- <listitem open="0" type="807" id="1JN85Vvcj75j" label="Klassendiagramm"/>
- <listitem open="1" type="818" id="WiRs8x01SCC1">
- <listitem open="1" type="813" id="OkY7XGujRhg1">
- <listitem open="1" type="814" label="neues_attribut"/>
- </listitem>
- </listitem>
- <listitem open="0" type="830" id="Datatypes">
- <listitem open="1" type="829" id="fFnZwH5ABLLa"/>
- <listitem open="1" type="829" id="KsHFV0NYie4P"/>
- <listitem open="1" type="829" id="3gmjKq8x3uXx"/>
- <listitem open="1" type="829" id="ZY50lsm5j3LE"/>
- <listitem open="1" type="829" id="GuIDPEDWQEpo"/>
- <listitem open="1" type="829" id="oDoXE7lGlVz3"/>
- <listitem open="1" type="829" id="Ba6KuRvT0yRj"/>
- <listitem open="1" type="829" id="ipipBDnzaFku"/>
- <listitem open="1" type="829" id="J61M0YIB6OV0"/>
- <listitem open="1" type="829" id="OQXAvVDDZCXZ"/>
- <listitem open="1" type="829" id="nOSlKtU95JgH"/>
- </listitem>
- </listitem>
- <listitem open="1" type="802" id="Use Case View"/>
- <listitem open="1" type="821" id="Component View"/>
- <listitem open="1" type="827" id="Deployment View"/>
- <listitem open="1" type="836" id="Entity Relationship Model"/>
- </listitem>
- </listview>
- <codegeneration>
- <codegenerator language="C++"/>
- </codegeneration>
- </XMI.extensions>
-</XMI>
/trunk/doc/Architektur.xmi
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-text/plain
\ No newline at end of property
Index: trunk/doc/Converter.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/doc/Converter.pdf
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: trunk/doc/temperatures.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/doc/temperatures.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: trunk/doc/Internet.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/doc/Internet.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: trunk/doc/Converter.zargo
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/doc/Converter.zargo
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: trunk/doc/MenuActivity.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/doc/MenuActivity.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: trunk/doc/lengths.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/doc/lengths.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: trunk/doc/Converter.odt
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/doc/Converter.odt
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: trunk/doc/UseCase.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/trunk/doc/UseCase.png
Property changes:
Deleted: svn:mime-type
## -1 +0,0 ##
-application/octet-stream
\ No newline at end of property
Index: trunk/lib/HTTPClient.java
===================================================================
--- trunk/lib/HTTPClient.java (nonexistent)
+++ trunk/lib/HTTPClient.java (revision 17)
@@ -0,0 +1,131 @@
+import java.io.IOException;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpVersion;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.impl.client.BasicResponseHandler;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
+
+import android.util.Log;
+
+public class WebClient {
+ private static final String TAG = "WebClient";
+ private static final DefaultHttpClient sClient;
+
+ static {
+ final HttpParams params = new BasicHttpParams();
+
+ HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+ HttpProtocolParams.setContentCharset(params, "UTF-8");
+
+ HttpConnectionParams.setStaleCheckingEnabled(params, false);
+ HttpConnectionParams.setConnectionTimeout(params, 20 * 1000);
+ HttpConnectionParams.setSoTimeout(params, 20 * 1000);
+ HttpConnectionParams.setSocketBufferSize(params, 8192);
+
+ SchemeRegistry schemeRegistry = new SchemeRegistry();
+ schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
+ schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
+
+ ClientConnectionManager manager = new ThreadSafeClientConnManager(params, schemeRegistry);
+ sClient = new DefaultHttpClient(manager, params);
+ }
+
+ /**
+ * Grab the source code for a given URL, returns null otherwise.
+ * Method: GET
+ *
+ * @param url The URL we want to read
+ * @return The Source code read from this URL (or null)
+ */
+ public static String readSource(String url) {
+ HttpGet get = new HttpGet(url);
+
+ try {
+ ResponseHandler<String> handler = new BasicResponseHandler();
+ String body = sClient.execute(get, handler);
+ return body;
+ } catch (ClientProtocolException e) {
+ Log.e(TAG, e.getMessage());
+ return null;
+ } catch (IOException e) {
+ Log.e(TAG, e.getMessage());
+ return null;
+ }
+ }
+
+ /**
+ * Grab the source code for a given URL, sending POST data specified.
+ * Method: POST
+ *
+ * @param post The HttpPost object for the client to execute
+ * @return The source code read from this URL (or null)
+ */
+ public static String readSource(HttpPost post) {
+ try {
+ ResponseHandler<String> handler = new BasicResponseHandler();
+ String body = sClient.execute(post, handler);
+ return body;
+ } catch (ClientProtocolException e) {
+ Log.e(TAG, e.getMessage());
+ return null;
+ } catch (IOException e) {
+ Log.e(TAG, e.getMessage());
+ return null;
+ }
+ }
+
+ /**
+ * Return a responses status code as an Integer. Returns 0 on a caught Exception
+ * Method: GET
+ *
+ * @param url The URL we're requesting
+ * @return The responses status code (ie: 401, 404, 200)
+ */
+ public static int getStatusCode(String url) {
+ HttpGet get = new HttpGet(url);
+ try {
+ HttpResponse response = sClient.execute(get);
+ return response.getStatusLine().getStatusCode();
+ } catch (ClientProtocolException e) {
+ Log.e(TAG, e.getMessage());
+ return 0;
+ } catch (IOException e) {
+ Log.e(TAG, e.getMessage());
+ return 0;
+ }
+ }
+
+ /**
+ * Return a responses status code as an Integer. Returns 0 on a caught Exception
+ * Method: POST
+ *
+ * @param post The HttpPost object for the client to execute
+ * @return The responses status code (ie: 401, 404, 200)
+ */
+ public static int getStatusCode(HttpPost post) {
+ try {
+ HttpResponse response = sClient.execute(post);
+ return response.getStatusLine().getStatusCode();
+ } catch (ClientProtocolException e) {
+ Log.e(TAG, e.getMessage());
+ return 0;
+ } catch (IOException e) {
+ Log.e(TAG, e.getMessage());
+ return 0;
+ }
+ }
+}
\ No newline at end of file
/trunk/lib/HTTPClient.java
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property